diff --git a/admin/src/components/ConfirmRegisterMailFormular.spec.js b/admin/src/components/ConfirmRegisterMailFormular.spec.js index a53fcae02..7fd71a37d 100644 --- a/admin/src/components/ConfirmRegisterMailFormular.spec.js +++ b/admin/src/components/ConfirmRegisterMailFormular.spec.js @@ -3,6 +3,8 @@ import ConfirmRegisterMailFormular from './ConfirmRegisterMailFormular.vue' const localVue = global.localVue +const apolloMutateMock = jest.fn().mockResolvedValue() + const mocks = { $moment: jest.fn(() => { return { @@ -14,10 +16,13 @@ const mocks = { }), } }), + $apollo: { + mutate: apolloMutateMock, + }, } const propsData = { - email: '', + email: 'bob@baumeister.de', dateLastSend: '', } @@ -36,5 +41,27 @@ describe('ConfirmRegisterMailFormular', () => { it('has a DIV element with the class.component-confirm-register-mail', () => { expect(wrapper.find('.component-confirm-register-mail').exists()).toBeTruthy() }) + + describe('send register mail with success', () => { + beforeEach(() => { + wrapper.find('button.test-button').trigger('click') + }) + + it('calls the API', () => { + expect(apolloMutateMock).toBeCalled() + }) + }) + + describe('send register mail with error', () => { + beforeEach(() => { + apolloMutateMock.mockRejectedValue({ message: 'OUCH!' }) + wrapper = Wrapper() + wrapper.find('button.test-button').trigger('click') + }) + + it('calls the API', () => { + expect(apolloMutateMock).toBeCalled() + }) + }) }) })