generated from kristiania-pg6301-2022/pg6301-exam-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2eeaa60
commit ee320dc
Showing
25 changed files
with
15,724 additions
and
3,394 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from "react"; | ||
import {LoginPage} from "../src/pages/loginpage/loginPage"; | ||
import {MemoryRouter} from "react-router-dom"; | ||
import ReactDOM from "react-dom"; | ||
import {act, Simulate} from "react-dom/test-utils"; | ||
|
||
describe("login page", () => { | ||
it("redirect to log in with google", async () => { | ||
// replace window.location to be able to detect redirects | ||
const location = new URL("https://www.example.com"); | ||
delete window.location; | ||
window.location = new URL(location); | ||
|
||
const authorization_endpoint = `https://www.example.com/`; | ||
const client_id = `1095582733852-smqnbrhcoiasjjg8q28u0g1k3nu997b0.apps.googleusercontent.com`; | ||
|
||
const domElement = document.createElement("div"); | ||
ReactDOM.render( | ||
<MemoryRouter> | ||
<LoginPage/> | ||
</MemoryRouter>, | ||
domElement | ||
); | ||
|
||
console.log(domElement.querySelector("a")) | ||
|
||
const node1 = domElement.querySelector("a:nth-child(1)") | ||
const node2 = domElement.querySelector("a:nth-child(2)") | ||
|
||
expect(node1.text).toEqual( | ||
"Google login" | ||
); | ||
await act(async () => { | ||
await Simulate.click(node1); | ||
}); | ||
const redirect_uri = `${location.origin}/login/google/callback`; | ||
|
||
expect(window.location.origin + window.location.pathname).toEqual( | ||
authorization_endpoint | ||
); | ||
}); | ||
}); |
Oops, something went wrong.