add test for ContributionLinkForm.vue

This commit is contained in:
ogerly 2022-08-08 15:04:58 +02:00
parent 30019d207d
commit adb5974438

View File

@ -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')
})
})
})