use bv toast

This commit is contained in:
Moriz Wahl 2022-02-16 08:11:26 +01:00
parent cb0edbd46e
commit 051446f526
2 changed files with 8 additions and 12 deletions

View File

@ -2,25 +2,21 @@ import { mount } from '@vue/test-utils'
import UserCardFormPasswort from './UserCard_FormUserPasswort'
import flushPromises from 'flush-promises'
import { toasters } from '../../../mixins/toaster'
const localVue = global.localVue
const changePasswordProfileMock = jest.fn()
changePasswordProfileMock.mockReturnValue({ success: true })
const toastSuccessMock = jest.fn()
const toastErrorMock = jest.fn()
const toastErrorSpy = jest.spyOn(toasters.methods, 'toastError')
const toastSuccessSpy = jest.spyOn(toasters.methods, 'toastSuccess')
describe('UserCard_FormUserPasswort', () => {
let wrapper
const mocks = {
$t: jest.fn((t) => t),
$toasted: {
success: toastSuccessMock,
global: {
error: toastErrorMock,
},
},
$apollo: {
mutate: changePasswordProfileMock,
},
@ -196,7 +192,7 @@ describe('UserCard_FormUserPasswort', () => {
})
it('toasts a success message', () => {
expect(toastSuccessMock).toBeCalledWith('site.thx.reset')
expect(toastSuccessSpy).toBeCalledWith('site.thx.reset')
})
it('cancels the edit process', () => {
@ -217,7 +213,7 @@ describe('UserCard_FormUserPasswort', () => {
})
it('toasts an error message', () => {
expect(toastErrorMock).toBeCalledWith('error')
expect(toastErrorSpy).toBeCalledWith('error')
})
})
})

View File

@ -89,11 +89,11 @@ export default {
},
})
.then(() => {
this.$toasted.success(this.$t('site.thx.reset'))
this.toastSuccess(this.$t('site.thx.reset'))
this.cancelEdit()
})
.catch((error) => {
this.$toasted.global.error(error.message)
this.toastError(error.message)
})
},
},