diff --git a/frontend/src/views/Pages/ResetPassword.spec.js b/frontend/src/views/Pages/ResetPassword.spec.js index da8b4bc4f..eb04d2c05 100644 --- a/frontend/src/views/Pages/ResetPassword.spec.js +++ b/frontend/src/views/Pages/ResetPassword.spec.js @@ -2,15 +2,18 @@ import { mount, RouterLinkStub } from '@vue/test-utils' import ResetPassword from './ResetPassword' import flushPromises from 'flush-promises' +import { toasters } from '../../mixins/toaster' + // validation is tested in src/views/Pages/UserProfile/UserCard_FormUserPasswort.spec.js const localVue = global.localVue const apolloMutationMock = jest.fn() -const toasterMock = jest.fn() const routerPushMock = jest.fn() +const toastErrorSpy = jest.spyOn(toasters.methods, 'toastError') + const stubs = { RouterLink: RouterLinkStub, } @@ -29,11 +32,6 @@ const mocks = { includes: jest.fn((t) => t === mocks.$route.path.mock), }, }, - $toasted: { - global: { - error: toasterMock, - }, - }, $router: { push: routerPushMock, }, @@ -65,7 +63,7 @@ describe('ResetPassword', () => { }) it.skip('toasts an error when no valid optin is given', () => { - expect(toasterMock).toHaveBeenCalledWith('error') + expect(toastErrorSpy).toHaveBeenCalledWith('error') }) it.skip('has a message suggesting to contact the support', () => { @@ -157,7 +155,7 @@ describe('ResetPassword', () => { }) it('toasts an error message', () => { - expect(toasterMock).toHaveBeenCalledWith('...Code is older than 10 minutes') + expect(toastErrorSpy).toHaveBeenCalledWith('...Code is older than 10 minutes') }) it('router pushes to /password/reset', () => { @@ -174,7 +172,7 @@ describe('ResetPassword', () => { }) it('toasts an error message', () => { - expect(toasterMock).toHaveBeenCalledWith('Error') + expect(toastErrorSpy).toHaveBeenCalledWith('Error') }) }) diff --git a/frontend/src/views/Pages/ResetPassword.vue b/frontend/src/views/Pages/ResetPassword.vue index 0023c3838..e4adeda9f 100644 --- a/frontend/src/views/Pages/ResetPassword.vue +++ b/frontend/src/views/Pages/ResetPassword.vue @@ -99,7 +99,7 @@ export default { } }) .catch((error) => { - this.$toasted.global.error(error.message) + this.toastError(error.message) if (error.message.includes('Code is older than 10 minutes')) this.$router.push('/password/reset') })