bv toast in deleted user formular

This commit is contained in:
Moriz Wahl 2022-03-03 12:29:01 +01:00
parent 11808f1e22
commit bb4a237f18
2 changed files with 9 additions and 15 deletions

View File

@ -2,6 +2,7 @@ import { mount } from '@vue/test-utils'
import DeletedUserFormular from './DeletedUserFormular.vue'
import { deleteUser } from '../graphql/deleteUser'
import { unDeleteUser } from '../graphql/unDeleteUser'
import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup'
const localVue = global.localVue
@ -13,9 +14,6 @@ const apolloMutateMock = jest.fn().mockResolvedValue({
},
})
const toastedErrorMock = jest.fn()
const toastedSuccessMock = jest.fn()
const mocks = {
$t: jest.fn((t) => t),
$apollo: {
@ -29,10 +27,6 @@ const mocks = {
},
},
},
$toasted: {
error: toastedErrorMock,
success: toastedSuccessMock,
},
}
const propsData = {
@ -119,7 +113,7 @@ describe('DeletedUserFormular', () => {
})
it('toasts a success message', () => {
expect(toastedSuccessMock).toBeCalledWith('user_deleted')
expect(toastSuccessSpy).toBeCalledWith('user_deleted')
})
it('emits update deleted At', () => {
@ -147,7 +141,7 @@ describe('DeletedUserFormular', () => {
})
it('toasts an error message', () => {
expect(toastedErrorMock).toBeCalledWith('Oh no!')
expect(toastErrorSpy).toBeCalledWith('Oh no!')
})
})
@ -216,7 +210,7 @@ describe('DeletedUserFormular', () => {
})
it('toasts a success message', () => {
expect(toastedSuccessMock).toBeCalledWith('user_recovered')
expect(toastSuccessSpy).toBeCalledWith('user_recovered')
})
it('emits update deleted At', () => {
@ -244,7 +238,7 @@ describe('DeletedUserFormular', () => {
})
it('toasts an error message', () => {
expect(toastedErrorMock).toBeCalledWith('Oh no!')
expect(toastErrorSpy).toBeCalledWith('Oh no!')
})
})

View File

@ -45,7 +45,7 @@ export default {
},
})
.then((result) => {
this.$toasted.success(this.$t('user_deleted'))
this.toastSuccess(this.$t('user_deleted'))
this.$emit('updateDeletedAt', {
userId: this.item.userId,
deletedAt: result.data.deleteUser,
@ -53,7 +53,7 @@ export default {
this.checked = false
})
.catch((error) => {
this.$toasted.error(error.message)
this.toastError(error.message)
})
},
unDeleteUser() {
@ -65,7 +65,7 @@ export default {
},
})
.then((result) => {
this.$toasted.success(this.$t('user_recovered'))
this.toastSuccess(this.$t('user_recovered'))
this.$emit('updateDeletedAt', {
userId: this.item.userId,
deletedAt: result.data.unDeleteUser,
@ -73,7 +73,7 @@ export default {
this.checked = false
})
.catch((error) => {
this.$toasted.error(error.message)
this.toastError(error.message)
})
},
},