From 16501a7488ae7ffe66baf240b93b7cf0cf839b33 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 3 Mar 2022 12:36:57 +0100 Subject: [PATCH] bv toast in creation confirm page --- admin/src/pages/CreationConfirm.spec.js | 17 ++++++----------- admin/src/pages/CreationConfirm.vue | 10 +++++----- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js index f0412678b..6df60378c 100644 --- a/admin/src/pages/CreationConfirm.spec.js +++ b/admin/src/pages/CreationConfirm.spec.js @@ -2,12 +2,11 @@ import { mount } from '@vue/test-utils' import CreationConfirm from './CreationConfirm.vue' import { deletePendingCreation } from '../graphql/deletePendingCreation' import { confirmPendingCreation } from '../graphql/confirmPendingCreation' +import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup' const localVue = global.localVue const storeCommitMock = jest.fn() -const toastedErrorMock = jest.fn() -const toastedSuccessMock = jest.fn() const apolloQueryMock = jest.fn().mockResolvedValue({ data: { getPendingCreations: [ @@ -47,10 +46,6 @@ const mocks = { query: apolloQueryMock, mutate: apolloMutateMock, }, - $toasted: { - error: toastedErrorMock, - success: toastedSuccessMock, - }, } describe('CreationConfirm', () => { @@ -101,7 +96,7 @@ describe('CreationConfirm', () => { }) it('toasts a success message', () => { - expect(toastedSuccessMock).toBeCalledWith('creation_form.toasted_delete') + expect(toastSuccessSpy).toBeCalledWith('creation_form.toasted_delete') }) }) @@ -112,7 +107,7 @@ describe('CreationConfirm', () => { }) it('toasts an error message', () => { - expect(toastedErrorMock).toBeCalledWith('Ouchhh!') + expect(toastErrorSpy).toBeCalledWith('Ouchhh!') }) }) @@ -158,7 +153,7 @@ describe('CreationConfirm', () => { }) it('toasts a success message', () => { - expect(toastedSuccessMock).toBeCalledWith('creation_form.toasted_created') + expect(toastSuccessSpy).toBeCalledWith('creation_form.toasted_created') }) it('has 1 item left in the table', () => { @@ -173,7 +168,7 @@ describe('CreationConfirm', () => { }) it('toasts an error message', () => { - expect(toastedErrorMock).toBeCalledWith('Ouchhh!') + expect(toastErrorSpy).toBeCalledWith('Ouchhh!') }) }) }) @@ -189,7 +184,7 @@ describe('CreationConfirm', () => { }) it('toast an error message', () => { - expect(toastedErrorMock).toBeCalledWith('Ouch!') + expect(toastErrorSpy).toBeCalledWith('Ouch!') }) }) }) diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue index 54580c366..26928fb67 100644 --- a/admin/src/pages/CreationConfirm.vue +++ b/admin/src/pages/CreationConfirm.vue @@ -43,10 +43,10 @@ export default { }) .then((result) => { this.updatePendingCreations(item.id) - this.$toasted.success(this.$t('creation_form.toasted_delete')) + this.toastSuccess(this.$t('creation_form.toasted_delete')) }) .catch((error) => { - this.$toasted.error(error.message) + this.toastError(error.message) }) }, confirmCreation() { @@ -60,11 +60,11 @@ export default { .then((result) => { this.overlay = false this.updatePendingCreations(this.item.id) - this.$toasted.success(this.$t('creation_form.toasted_created')) + this.toastSuccess(this.$t('creation_form.toasted_created')) }) .catch((error) => { this.overlay = false - this.$toasted.error(error.message) + this.toastError(error.message) }) }, getPendingCreations() { @@ -79,7 +79,7 @@ export default { this.$store.commit('setOpenCreations', result.data.getPendingCreations.length) }) .catch((error) => { - this.$toasted.error(error.message) + this.toastError(error.message) }) }, updatePendingCreations(id) {