-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1186 from softwaremill/invalidate-session
Invalidate session on password change/logout
- Loading branch information
Showing
12 changed files
with
169 additions
and
26 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
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
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
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
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
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
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 |
---|---|---|
@@ -1,23 +1,27 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import { screen } from "@testing-library/react"; | ||
import { userEvent } from "@testing-library/user-event"; | ||
import { MemoryRouter } from "react-router-dom"; | ||
import { UserContext, UserState, initialUserState } from "contexts"; | ||
import { Top } from "./Top"; | ||
import { userService } from "../../services"; | ||
import { renderWithClient } from "../../tests"; | ||
|
||
const loggedUserState: UserState = { | ||
apiKey: "test-api-key", | ||
user: { login: "user-login", email: "[email protected]", createdOn: "2020-10-09T09:57:17.995288Z" }, | ||
loggedIn: true, | ||
}; | ||
|
||
jest.mock("services"); | ||
|
||
const dispatch = jest.fn(); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
test("renders brand name", () => { | ||
render( | ||
renderWithClient( | ||
<MemoryRouter initialEntries={[""]}> | ||
<UserContext.Provider value={{ state: initialUserState, dispatch }}> | ||
<Top /> | ||
|
@@ -29,7 +33,7 @@ test("renders brand name", () => { | |
}); | ||
|
||
test("renders nav bar unlogged user", () => { | ||
render( | ||
renderWithClient( | ||
<MemoryRouter initialEntries={["/main"]}> | ||
<UserContext.Provider value={{ state: initialUserState, dispatch }}> | ||
<Top /> | ||
|
@@ -44,7 +48,7 @@ test("renders nav bar unlogged user", () => { | |
}); | ||
|
||
test("renders nav bar for logged user", () => { | ||
render( | ||
renderWithClient( | ||
<MemoryRouter initialEntries={["/main"]}> | ||
<UserContext.Provider value={{ state: loggedUserState, dispatch }}> | ||
<Top /> | ||
|
@@ -59,7 +63,9 @@ test("renders nav bar for logged user", () => { | |
}); | ||
|
||
test("handles logout logged user", async () => { | ||
render( | ||
(userService.logout as jest.Mock).mockResolvedValueOnce({}); | ||
|
||
renderWithClient( | ||
<MemoryRouter initialEntries={["/main"]}> | ||
<UserContext.Provider value={{ state: loggedUserState, dispatch }}> | ||
<Top /> | ||
|
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
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
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
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
Oops, something went wrong.