diff --git a/admin/src/components/CreationFormular.spec.js b/admin/src/components/CreationFormular.spec.js index cfc23fa26..f2ce36908 100644 --- a/admin/src/components/CreationFormular.spec.js +++ b/admin/src/components/CreationFormular.spec.js @@ -2,6 +2,7 @@ import { mount } from '@vue/test-utils' import CreationFormular from './CreationFormular.vue' import { createPendingCreation } from '../graphql/createPendingCreation' import { createPendingCreations } from '../graphql/createPendingCreations' +import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup' const localVue = global.localVue @@ -11,8 +12,6 @@ const apolloMutateMock = jest.fn().mockResolvedValue({ }, }) const stateCommitMock = jest.fn() -const toastedErrorMock = jest.fn() -const toastedSuccessMock = jest.fn() const mocks = { $t: jest.fn((t, options) => (options ? [t, options] : t)), @@ -32,10 +31,6 @@ const mocks = { }, }, }, - $toasted: { - error: toastedErrorMock, - success: toastedSuccessMock, - }, } const propsData = { @@ -140,7 +135,7 @@ describe('CreationFormular', () => { }) it('toasts a success message', () => { - expect(toastedSuccessMock).toBeCalledWith([ + expect(toastSuccessSpy).toBeCalledWith([ 'creation_form.toasted', { email: 'benjamin@bluemchen.de', value: '90' }, ]) @@ -162,7 +157,7 @@ describe('CreationFormular', () => { }) it('toasts an error message', () => { - expect(toastedErrorMock).toBeCalledWith('Ouch!') + expect(toastErrorSpy).toBeCalledWith('Ouch!') }) }) @@ -292,7 +287,7 @@ describe('CreationFormular', () => { }) it('toast success message', () => { - expect(toastedSuccessMock).toBeCalled() + expect(toastSuccessSpy).toBeCalled() }) it('store commit openCreationPlus', () => { @@ -427,10 +422,10 @@ describe('CreationFormular', () => { }) it('toasts two errors', () => { - expect(toastedErrorMock).toBeCalledWith( + expect(toastErrorSpy).toBeCalledWith( 'Could not created PendingCreation for bob@baumeister.de', ) - expect(toastedErrorMock).toBeCalledWith( + expect(toastErrorSpy).toBeCalledWith( 'Could not created PendingCreation for bibi@bloxberg.de', ) }) @@ -454,7 +449,7 @@ describe('CreationFormular', () => { }) it('toasts an error message', () => { - expect(toastedErrorMock).toBeCalledWith('Oh no!') + expect(toastErrorSpy).toBeCalledWith('Oh no!') }) }) }) diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index 34df13e11..a705bbba8 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -173,13 +173,13 @@ export default { if (result.data.createPendingCreations.failedCreation.length > 0) { result.data.createPendingCreations.failedCreation.forEach((failed) => { // TODO: Please localize this error message - this.$toasted.error('Could not created PendingCreation for ' + failed) + this.toastError('Could not created PendingCreation for ' + failed) }) } this.$emit('remove-all-bookmark') }) .catch((error) => { - this.$toasted.error(error.message) + this.toastError(error.message) }) } else if (this.type === 'singleCreation') { submitObj = { @@ -196,19 +196,19 @@ export default { }) .then((result) => { this.$emit('update-user-data', this.item, result.data.createPendingCreation) - this.$toasted.success( + this.$store.commit('openCreationsPlus', 1) + this.toastSuccess( this.$t('creation_form.toasted', { value: this.value, email: this.item.email, }), ) - this.$store.commit('openCreationsPlus', 1) // what is this? Tests says that this.text is not reseted this.$refs.creationForm.reset() this.value = 0 }) .catch((error) => { - this.$toasted.error(error.message) + this.toastError(error.message) this.$refs.creationForm.reset() this.value = 0 })