Skip to content

Commit

Permalink
feat: creating the logout tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
gony02 committed Mar 10, 2024
1 parent 0865fcc commit e6e9306
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions webapp/src/tests/Logout.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import axios from "axios";
import MockAdapter from "axios-mock-adapter";
import {logoutUser} from "components/game/Logout";

const mockAxios = new MockAdapter(axios);

describe("Logout User tests", () => {
beforeEach(() => {
sessionStorage.clear();
mockAxios.reset();
});

it("successfully logs out the user", async () => {
mockAxios.onGet(process.env.REACT_APP_API_ENDPOINT + "/auth/logout").replyOnce(200);

sessionStorage.setItem("jwtToken", "token");
sessionStorage.setItem("jwtRefreshToken", "refreshToken");

await logoutUser();

expect(sessionStorage.getItem("jwtToken")).toBeNull();
expect(sessionStorage.getItem("jwtRefreshToken")).toBeNull();
});
});

0 comments on commit e6e9306

Please sign in to comment.