Skip to content

Commit 97d6b6c

Browse files
committed
mock getToken for question.test.ts
1 parent ed871a9 commit 97d6b6c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

apps/frontend/__tests__/question.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ const QUESTIONS = [
8585
}
8686
]
8787

88+
jest.mock("@/app/services/login-store", () => {
89+
return {
90+
__esModule: true,
91+
getToken: jest.fn(() => TOKEN)
92+
};
93+
})
8894

8995
function createMockResponse(obj: any): Response {
9096
// @ts-ignore don't need the whole response
@@ -97,10 +103,6 @@ function createMockResponse(obj: any): Response {
97103

98104
const TOKEN = "mockjwttoken"
99105

100-
beforeEach(() => {
101-
window.localStorage["TOKEN"] = TOKEN
102-
})
103-
104106
describe("GetQuestions", () => {
105107
beforeEach(() => {
106108
global.fetch = jest.fn().mockResolvedValue({

0 commit comments

Comments
 (0)