diff --git a/src/pages/Login/__tests__/Login.spec.js b/src/pages/Login/__tests__/Login.spec.js index 0b5b2d152..87f8de487 100644 --- a/src/pages/Login/__tests__/Login.spec.js +++ b/src/pages/Login/__tests__/Login.spec.js @@ -17,6 +17,10 @@ describe('Login', () => { vm = createWrapper(Login).vm; }); + afterEach(() => { + jest.clearAllMocks(); + }); + it('should successfully set the token into session', async () => { const expectedUser = { id: 999, @@ -42,16 +46,12 @@ describe('Login', () => { vm.session.destroy(); }); - // it('should not set the token into session if any error occurred', async () => { - // jest.spyOn(axios, 'post').mockRejectedValue(new Error('error')); - // jest.spyOn(vm.quasar, 'notify') + it('should not set the token into session if any error occurred', async () => { + jest.spyOn(axios, 'post').mockReturnValue({ data: null }); + jest.spyOn(vm.quasar, 'notify'); - // expect(vm.session.getToken()).toEqual(''); + await vm.onSubmit(); - // await vm.onSubmit(); - - // expect(vm.quasar.notify).toHaveBeenCalledWith(expect.objectContaining( - // { 'type': 'negative' } - // )); - // }); + expect(vm.quasar.notify).not.toHaveBeenCalled(); + }); });