diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.spec.js index 7b83f405b..11807614c 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.spec.js @@ -2,14 +2,17 @@ import { mount } from '@vue/test-utils' import UserCardFormUserData from './UserCard_FormUserData' import flushPromises from 'flush-promises' +import { toasters } from '../../../mixins/toaster' + const localVue = global.localVue const mockAPIcall = jest.fn() -const toastErrorMock = jest.fn() -const toastSuccessMock = jest.fn() const storeCommitMock = jest.fn() +const toastErrorSpy = jest.spyOn(toasters.methods, 'toastError') +const toastSuccessSpy = jest.spyOn(toasters.methods, 'toastSuccess') + describe('UserCard_FormUserData', () => { let wrapper @@ -22,12 +25,6 @@ describe('UserCard_FormUserData', () => { }, commit: storeCommitMock, }, - $toasted: { - success: toastSuccessMock, - global: { - error: toastErrorMock, - }, - }, $apollo: { mutate: mockAPIcall, }, @@ -126,7 +123,7 @@ describe('UserCard_FormUserData', () => { }) it('toasts a success message', () => { - expect(toastSuccessMock).toBeCalledWith('settings.name.change-success') + expect(toastSuccessSpy).toBeCalledWith('settings.name.change-success') }) it('has an edit button again', () => { @@ -159,7 +156,7 @@ describe('UserCard_FormUserData', () => { }) it('toasts an error message', () => { - expect(toastErrorMock).toBeCalledWith('Error') + expect(toastErrorSpy).toBeCalledWith('Error') }) }) }) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue index 7ae84eb10..33fcccaab 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue @@ -108,10 +108,10 @@ export default { this.$store.commit('firstName', this.form.firstName) this.$store.commit('lastName', this.form.lastName) this.showUserData = true - this.$toasted.success(this.$t('settings.name.change-success')) + this.toastSuccess(this.$t('settings.name.change-success')) }) .catch((error) => { - this.$toasted.global.error(error.message) + this.toastError(error.message) }) }, },