Skip to content

Commit

Permalink
Major refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
andersholt committed May 4, 2022
1 parent 2eeaa60 commit ee320dc
Show file tree
Hide file tree
Showing 25 changed files with 15,724 additions and 3,394 deletions.
1 change: 1 addition & 0 deletions client/__mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
42 changes: 42 additions & 0 deletions client/__tests__/login.test.jsx
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
);
});
});
Loading

0 comments on commit ee320dc

Please sign in to comment.