From adb597443855b3f367ba845261458157601f06a8 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 8 Aug 2022 15:04:58 +0200 Subject: [PATCH] add test for ContributionLinkForm.vue --- .../src/components/ContributionLinkForm.spec.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/admin/src/components/ContributionLinkForm.spec.js b/admin/src/components/ContributionLinkForm.spec.js index 9c7c33c52..7182fb2e9 100644 --- a/admin/src/components/ContributionLinkForm.spec.js +++ b/admin/src/components/ContributionLinkForm.spec.js @@ -1,5 +1,6 @@ import { mount } from '@vue/test-utils' import ContributionLinkForm from './ContributionLinkForm.vue' +import { toastErrorSpy } from '../../test/testSetup' const localVue = global.localVue @@ -8,9 +9,13 @@ global.alert = jest.fn() const propsData = { contributionLinkData: {}, } +const apolloMutateMock = jest.fn().mockResolvedValue() const mocks = { $t: jest.fn((t) => t), + $apollo: { + mutate: apolloMutateMock, + }, } // const mockAPIcall = jest.fn() @@ -99,4 +104,16 @@ describe('ContributionLinkForm', () => { // }) // }) }) + + describe('send createContributionLink with error', () => { + beforeEach(() => { + apolloMutateMock.mockRejectedValue({ message: 'OUCH!' }) + wrapper = Wrapper() + wrapper.vm.onSubmit() + }) + + it('toasts an error message', () => { + expect(toastErrorSpy).toBeCalledWith('contributionLink.noStartDate') + }) + }) })