test ConfirmRegisterMailFormular API calls

This commit is contained in:
Moriz Wahl 2021-12-21 11:20:40 +01:00
parent d96e458356
commit 1890475d59

View File

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