use bv toast

This commit is contained in:
Moriz Wahl 2022-02-16 08:14:02 +01:00
parent 051446f526
commit f67ac41389
2 changed files with 9 additions and 12 deletions

View File

@ -1,6 +1,8 @@
import { mount } from '@vue/test-utils'
import UserCardLanguage from './UserCard_Language'
import { toasters } from '../../../mixins/toaster'
const localVue = global.localVue
const mockAPIcall = jest.fn().mockResolvedValue({
@ -11,10 +13,11 @@ const mockAPIcall = jest.fn().mockResolvedValue({
},
})
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_Language', () => {
let wrapper
@ -26,12 +29,6 @@ describe('UserCard_Language', () => {
},
commit: storeCommitMock,
},
$toasted: {
success: toastSuccessMock,
global: {
error: toastErrorMock,
},
},
$apollo: {
mutate: mockAPIcall,
},
@ -143,7 +140,7 @@ describe('UserCard_Language', () => {
})
it('toasts a success message', () => {
expect(toastSuccessMock).toBeCalledWith('settings.language.success')
expect(toastSuccessSpy).toBeCalledWith('settings.language.success')
})
})
@ -159,7 +156,7 @@ describe('UserCard_Language', () => {
})
it('toasts an error message', () => {
expect(toastErrorMock).toBeCalledWith('Ouch!')
expect(toastErrorSpy).toBeCalledWith('Ouch!')
})
})
})

View File

@ -97,11 +97,11 @@ export default {
.then(() => {
this.$store.commit('language', this.language)
this.cancelEdit()
this.$toasted.success(this.$t('settings.language.success'))
this.toastSuccess(this.$t('settings.language.success'))
})
.catch((error) => {
this.language = this.$store.state.language
this.$toasted.global.error(error.message)
this.toastError(error.message)
})
},
buildTagFromLanguageString() {