Router not longer redirects to dashboard on page reload #13
|
@ -51,6 +51,7 @@ async function saveLanguage(value) {
|
|||
await axios.patch(query, {
|
||||
lang: value,
|
||||
});
|
||||
user.value.lang = value;
|
||||
}
|
||||
|
||||
function logout() {
|
||||
|
|
|
@ -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' }
|
||||
));
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue