diff --git a/src/components/UserPanel.vue b/src/components/UserPanel.vue index bcb5bc46c..e7d48e819 100644 --- a/src/components/UserPanel.vue +++ b/src/components/UserPanel.vue @@ -51,6 +51,7 @@ async function saveLanguage(value) { await axios.patch(query, { lang: value, }); + user.value.lang = value; } function logout() { diff --git a/src/components/__tests__/UserPanel.spec.js b/src/components/__tests__/UserPanel.spec.js deleted file mode 100644 index 4283ce3ab..000000000 --- a/src/components/__tests__/UserPanel.spec.js +++ /dev/null @@ -1,56 +0,0 @@ -import { describe, expect, it, jest } from '@jest/globals'; -import { createWrapper, axios, flushPromises } from 'app/tests/jest/jestHelpers'; -import UserPanel from '../UserPanel.vue'; - -const mockPush = jest.fn(); - -jest.mock('vue-router', () => ({ - useRouter: () => ({ - push: mockPush, - }), -})); - -describe('UserPanel onMounted()', () => { - it('should define the user into state', async () => { - const userMock = { - user: { - id: 1, - name: 'myName', - nickname: 'myNickName', - lang: 'en', - userConfig: { - darkMode: 'false' - } - }, - roles: [] - } - const expectedUserData = { - id: 1, - name: 'myName', - nickname: 'myNickName', - lang: 'en', - darkMode: 'false' - } - - jest.spyOn(axios, 'get').mockResolvedValue({ data: userMock }); - const { vm } = createWrapper(UserPanel); - - await flushPromises() - - expect(vm.state.getUser().value).toEqual(expectedUserData); - }); - - it('should logout and notify the expected error', async () => { - jest.spyOn(axios, 'get').mockRejectedValue(new Error('error')); - - const { vm } = createWrapper(UserPanel); - - jest.spyOn(vm.quasar, 'notify'); - - await flushPromises() - - expect(vm.quasar.notify).toHaveBeenCalledWith(expect.objectContaining( - { 'type': 'negative' } - )); - }); -});