change to bv toast

This commit is contained in:
Moriz Wahl 2022-02-16 08:00:41 +01:00
parent dd5aa62e58
commit 72c5940e84
2 changed files with 8 additions and 10 deletions

View File

@ -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')
})
})

View File

@ -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')
})