use bv toast

This commit is contained in:
Moriz Wahl 2022-02-16 08:47:10 +01:00
parent 82c7725afc
commit 493ad9c6f7
2 changed files with 9 additions and 12 deletions

View File

@ -3,6 +3,8 @@ import UserCardFormUsername from './UserCard_FormUsername'
import flushPromises from 'flush-promises'
import { extend } from 'vee-validate'
import { toasters } from '../../../mixins/toaster'
const localVue = global.localVue
const mockAPIcall = jest.fn()
@ -14,10 +16,11 @@ extend('gddUsernameUnique', {
},
})
const toastErrorMock = jest.fn()
const toastSuccessMock = jest.fn()
const storeCommitMock = jest.fn()
const toastErrorSpy = jest.spyOn(toasters.methods, 'toastError')
const toastSuccessSpy = jest.spyOn(toasters.methods, 'toastSuccess')
describe('UserCard_FormUsername', () => {
let wrapper
@ -29,12 +32,6 @@ describe('UserCard_FormUsername', () => {
},
commit: storeCommitMock,
},
$toasted: {
success: toastSuccessMock,
global: {
error: toastErrorMock,
},
},
$apollo: {
mutate: mockAPIcall,
},
@ -125,7 +122,7 @@ describe('UserCard_FormUsername', () => {
})
it('toasts an success message', () => {
expect(toastSuccessMock).toBeCalledWith('settings.name.change-success')
expect(toastSuccessSpy).toBeCalledWith('settings.name.change-success')
})
it('has no edit button anymore', () => {
@ -155,7 +152,7 @@ describe('UserCard_FormUsername', () => {
})
it('toasts an error message', () => {
expect(toastErrorMock).toBeCalledWith('Ouch!')
expect(toastErrorSpy).toBeCalledWith('Ouch!')
})
it('renders an empty username', () => {

View File

@ -97,10 +97,10 @@ export default {
this.$store.commit('username', this.form.username)
this.username = this.form.username
this.showUsername = true
this.$toasted.success(this.$t('settings.name.change-success'))
this.toastSuccess(this.$t('settings.name.change-success'))
})
.catch((error) => {
this.$toasted.global.error(error.message)
this.toastError(error.message)
this.showUsername = true
this.username = this.$store.state.username
this.form.username = this.$store.state.username