From 20604a2441f6511c38b6392a5dbba80da6fc798a Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 6 Apr 2022 08:46:34 +0200 Subject: [PATCH] front unit test fixed after login enhancement --- src/components/__tests__/UserPanel.spec.js | 4 ++-- src/pages/Login/__tests__/Login.spec.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/__tests__/UserPanel.spec.js b/src/components/__tests__/UserPanel.spec.js index 7b8b3ba51..3d5182890 100644 --- a/src/components/__tests__/UserPanel.spec.js +++ b/src/components/__tests__/UserPanel.spec.js @@ -12,7 +12,7 @@ jest.mock('vue-router', () => ({ describe('UserPanel', () => { describe('onMounted', () => { - it('should define the user into state', async () => { + it.only('should define the user into state', async () => { const userMock = { user: { id: 1, @@ -30,7 +30,7 @@ describe('UserPanel', () => { expect(vm.state.getUser().value).toEqual(expectedUser); }); - xit('should logout and notify the expected error', async () => { + it('should logout and notify the expected error', async () => { jest.spyOn(axios, 'get').mockRejectedValue(new Error('error')); const { vm } = createWrapper(UserPanel); diff --git a/src/pages/Login/__tests__/Login.spec.js b/src/pages/Login/__tests__/Login.spec.js index 1778a6002..36323d1ed 100644 --- a/src/pages/Login/__tests__/Login.spec.js +++ b/src/pages/Login/__tests__/Login.spec.js @@ -7,6 +7,7 @@ const mockPush = jest.fn(); jest.mock('vue-router', () => ({ useRouter: () => ({ push: mockPush, + currentRoute: { value: 'myCurrentRoute' } }), })); @@ -18,6 +19,7 @@ describe('Login', () => { it('should successfully set the token into session', async () => { jest.spyOn(axios, 'post').mockResolvedValue({ data: { token: 'token' } }); + jest.spyOn(axios, 'get').mockResolvedValue({ data: { roles: [], user: { id: 1 } } }); jest.spyOn(vm.quasar, 'notify') expect(vm.session.getToken()).toEqual('');