mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
use bv toast
This commit is contained in:
parent
82c7725afc
commit
493ad9c6f7
@ -3,6 +3,8 @@ import UserCardFormUsername from './UserCard_FormUsername'
|
|||||||
import flushPromises from 'flush-promises'
|
import flushPromises from 'flush-promises'
|
||||||
import { extend } from 'vee-validate'
|
import { extend } from 'vee-validate'
|
||||||
|
|
||||||
|
import { toasters } from '../../../mixins/toaster'
|
||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
|
|
||||||
const mockAPIcall = jest.fn()
|
const mockAPIcall = jest.fn()
|
||||||
@ -14,10 +16,11 @@ extend('gddUsernameUnique', {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
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_FormUsername', () => {
|
describe('UserCard_FormUsername', () => {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
@ -29,12 +32,6 @@ describe('UserCard_FormUsername', () => {
|
|||||||
},
|
},
|
||||||
commit: storeCommitMock,
|
commit: storeCommitMock,
|
||||||
},
|
},
|
||||||
$toasted: {
|
|
||||||
success: toastSuccessMock,
|
|
||||||
global: {
|
|
||||||
error: toastErrorMock,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
$apollo: {
|
$apollo: {
|
||||||
mutate: mockAPIcall,
|
mutate: mockAPIcall,
|
||||||
},
|
},
|
||||||
@ -125,7 +122,7 @@ describe('UserCard_FormUsername', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('toasts an success message', () => {
|
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', () => {
|
it('has no edit button anymore', () => {
|
||||||
@ -155,7 +152,7 @@ describe('UserCard_FormUsername', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('toasts an error message', () => {
|
it('toasts an error message', () => {
|
||||||
expect(toastErrorMock).toBeCalledWith('Ouch!')
|
expect(toastErrorSpy).toBeCalledWith('Ouch!')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders an empty username', () => {
|
it('renders an empty username', () => {
|
||||||
|
|||||||
@ -97,10 +97,10 @@ export default {
|
|||||||
this.$store.commit('username', this.form.username)
|
this.$store.commit('username', this.form.username)
|
||||||
this.username = this.form.username
|
this.username = this.form.username
|
||||||
this.showUsername = true
|
this.showUsername = 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)
|
||||||
this.showUsername = true
|
this.showUsername = true
|
||||||
this.username = this.$store.state.username
|
this.username = this.$store.state.username
|
||||||
this.form.username = this.$store.state.username
|
this.form.username = this.$store.state.username
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user