diff --git a/composables/api/useLogoutUser/useLogoutUser.test.ts b/composables/api/useLogoutUser/useLogoutUser.test.ts index 1b2c95a7..30d0836d 100644 --- a/composables/api/useLogoutUser/useLogoutUser.test.ts +++ b/composables/api/useLogoutUser/useLogoutUser.test.ts @@ -2,7 +2,7 @@ import { useCurrentUser, useSessionToken } from '#imports' import type { UserViewModel } from 'lib/api/data-contracts' import useLogoutUser from '.' -const token = 'auth-token' +let token = '' const user: UserViewModel = { id: '575888bd-9702-41a9-9b75-fc87d785c22a', role: 'Confirmed', @@ -10,6 +10,17 @@ const user: UserViewModel = { createdAt: '1984-01-01T00:00:00Z', } +vi.mock('@vueuse/core', () => ({ + useLocalStorage: () => ({ + get value() { + return token + }, + set value(val) { + token = val + }, + }), +})) + afterEach(() => { fetchMock.resetMocks() vi.restoreAllMocks() @@ -19,14 +30,14 @@ afterEach(() => { describe('useLogoutUser', () => { beforeEach(() => { fetchMock.mockIf(/.*\/[Uu]ser\/me/, () => JSON.stringify(user)) - useSessionToken().value = token + token = 'auth-token' }) it('sets the `authToken` and `currentUser` back to the default values', async () => { const authToken = useSessionToken() const { data, refresh } = await useCurrentUser() - expect(authToken.value).toEqual(token) + expect(authToken.value).toEqual('auth-token') expect(data.value).toEqual(user) useLogoutUser()