Skip to content

Commit d150fd7

Browse files
committed
Fix test : mock useTranslator
1 parent cac63d9 commit d150fd7

File tree

1 file changed

+10
-0
lines changed
  • packages/sprinkle-account/app/assets/tests/stores

1 file changed

+10
-0
lines changed

packages/sprinkle-account/app/assets/tests/stores/auth.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ const form: LoginForm = {
2727
password: 'password'
2828
}
2929

30+
// Mock useTranslator load function
31+
const loadTranslator = vi.fn()
32+
vi.mock('@userfrosting/sprinkle-core/stores', () => ({
33+
useTranslator: () => ({
34+
load: loadTranslator
35+
})
36+
}))
37+
3038
describe('authStore', () => {
3139
beforeEach(() => {
3240
setActivePinia(createPinia())
@@ -67,6 +75,7 @@ describe('authStore', () => {
6775
expect(axios.post).toHaveBeenCalledWith('/account/login', form)
6876
expect(result).toStrictEqual(testUser)
6977
expect(authStore.user).toStrictEqual(testUser)
78+
expect(loadTranslator).toHaveBeenCalled()
7079
})
7180

7281
test('should throw an error when login fails', async () => {
@@ -141,6 +150,7 @@ describe('authStore', () => {
141150
// Assert
142151
expect(axios.get).toHaveBeenCalledWith('/account/logout')
143152
expect(authStore.user).toBeNull()
153+
expect(loadTranslator).toHaveBeenCalled()
144154
})
145155

146156
test('should throw an error when logout fails', async () => {

0 commit comments

Comments
 (0)