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
f67ac41389
commit
84d2b9459d
@ -2,14 +2,17 @@ import { mount } from '@vue/test-utils'
|
|||||||
import UserCardNewsletter from './UserCard_Newsletter'
|
import UserCardNewsletter from './UserCard_Newsletter'
|
||||||
import { unsubscribeNewsletter, subscribeNewsletter } from '../../../graphql/mutations'
|
import { unsubscribeNewsletter, subscribeNewsletter } from '../../../graphql/mutations'
|
||||||
|
|
||||||
|
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_Newsletter', () => {
|
describe('UserCard_Newsletter', () => {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
@ -23,12 +26,6 @@ describe('UserCard_Newsletter', () => {
|
|||||||
},
|
},
|
||||||
commit: storeCommitMock,
|
commit: storeCommitMock,
|
||||||
},
|
},
|
||||||
$toasted: {
|
|
||||||
success: toastSuccessMock,
|
|
||||||
global: {
|
|
||||||
error: toastErrorMock,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
$apollo: {
|
$apollo: {
|
||||||
mutate: mockAPIcall,
|
mutate: mockAPIcall,
|
||||||
},
|
},
|
||||||
@ -77,7 +74,7 @@ describe('UserCard_Newsletter', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('toasts a success message', () => {
|
it('toasts a success message', () => {
|
||||||
expect(toastSuccessMock).toBeCalledWith('settings.newsletter.newsletterFalse')
|
expect(toastSuccessSpy).toBeCalledWith('settings.newsletter.newsletterFalse')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -107,7 +104,7 @@ describe('UserCard_Newsletter', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('toasts a success message', () => {
|
it('toasts a success message', () => {
|
||||||
expect(toastSuccessMock).toBeCalledWith('settings.newsletter.newsletterTrue')
|
expect(toastSuccessSpy).toBeCalledWith('settings.newsletter.newsletterTrue')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -124,7 +121,7 @@ describe('UserCard_Newsletter', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('toasts an error message', () => {
|
it('toasts an error message', () => {
|
||||||
expect(toastErrorMock).toBeCalledWith('Ouch')
|
expect(toastErrorSpy).toBeCalledWith('Ouch')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -48,7 +48,7 @@ export default {
|
|||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$store.commit('newsletterState', this.newsletterState)
|
this.$store.commit('newsletterState', this.newsletterState)
|
||||||
this.$toasted.success(
|
this.toastSuccess(
|
||||||
this.newsletterState
|
this.newsletterState
|
||||||
? this.$t('settings.newsletter.newsletterTrue')
|
? this.$t('settings.newsletter.newsletterTrue')
|
||||||
: this.$t('settings.newsletter.newsletterFalse'),
|
: this.$t('settings.newsletter.newsletterFalse'),
|
||||||
@ -56,7 +56,7 @@ export default {
|
|||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.newsletterState = this.$store.state.newsletterState
|
this.newsletterState = this.$store.state.newsletterState
|
||||||
this.$toasted.global.error(error.message)
|
this.toastError(error.message)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user