use bv toast

This commit is contained in:
Moriz Wahl 2022-02-16 08:08:23 +01:00
parent fec442ba51
commit cb0edbd46e
2 changed files with 9 additions and 12 deletions

View File

@ -2,14 +2,17 @@ import { mount } from '@vue/test-utils'
import UserCardFormUserData from './UserCard_FormUserData' import UserCardFormUserData from './UserCard_FormUserData'
import flushPromises from 'flush-promises' import flushPromises from 'flush-promises'
import { toasters } from '../../../mixins/toaster'
const localVue = global.localVue const localVue = global.localVue
const mockAPIcall = jest.fn() const mockAPIcall = jest.fn()
const toastErrorMock = jest.fn()
const toastSuccessMock = jest.fn()
const storeCommitMock = jest.fn() const storeCommitMock = jest.fn()
const toastErrorSpy = jest.spyOn(toasters.methods, 'toastError')
const toastSuccessSpy = jest.spyOn(toasters.methods, 'toastSuccess')
describe('UserCard_FormUserData', () => { describe('UserCard_FormUserData', () => {
let wrapper let wrapper
@ -22,12 +25,6 @@ describe('UserCard_FormUserData', () => {
}, },
commit: storeCommitMock, commit: storeCommitMock,
}, },
$toasted: {
success: toastSuccessMock,
global: {
error: toastErrorMock,
},
},
$apollo: { $apollo: {
mutate: mockAPIcall, mutate: mockAPIcall,
}, },
@ -126,7 +123,7 @@ describe('UserCard_FormUserData', () => {
}) })
it('toasts a success message', () => { it('toasts a success message', () => {
expect(toastSuccessMock).toBeCalledWith('settings.name.change-success') expect(toastSuccessSpy).toBeCalledWith('settings.name.change-success')
}) })
it('has an edit button again', () => { it('has an edit button again', () => {
@ -159,7 +156,7 @@ describe('UserCard_FormUserData', () => {
}) })
it('toasts an error message', () => { it('toasts an error message', () => {
expect(toastErrorMock).toBeCalledWith('Error') expect(toastErrorSpy).toBeCalledWith('Error')
}) })
}) })
}) })

View File

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