Changed the expected values that are given from the apollo call.

This commit is contained in:
Hannes Heine 2021-08-10 15:15:52 +02:00
parent 464d05efa0
commit 0765b80144

View File

@ -98,6 +98,9 @@ describe('UserCard_FormUsername', () => {
describe('successfull submit', () => {
beforeEach(async () => {
mockAPIcall.mockResolvedValue({
state: 'success',
})
jest.clearAllMocks()
await wrapper.findAll('input').at(0).setValue('Petra')
await wrapper.findAll('input').at(1).setValue('Lustiger')
@ -108,11 +111,17 @@ describe('UserCard_FormUsername', () => {
})
it('calls the loginAPI', () => {
expect(mockAPIcall).toBeCalledWith(1, 'user@example.org', {
expect(mockAPIcall).toBeCalledWith(
expect.objectContaining({
variables: {
sessionId: 1,
email: 'user@example.org',
firstName: 'Petra',
lastName: 'Lustiger',
description: 'Keine Nickelbrille',
})
},
}),
)
})
it('commits firstname to store', () => {
@ -138,8 +147,10 @@ describe('UserCard_FormUsername', () => {
describe('submit results in server error', () => {
beforeEach(async () => {
mockAPIcall.mockRejectedValue({
message: 'Error',
})
jest.clearAllMocks()
mockAPIcall.mockReturnValue({ success: false, result: { message: 'Error' } })
await wrapper.findAll('input').at(0).setValue('Petra')
await wrapper.findAll('input').at(1).setValue('Lustiger')
await wrapper.find('textarea').setValue('Keine Nickelbrille')
@ -149,11 +160,17 @@ describe('UserCard_FormUsername', () => {
})
it('calls the loginAPI', () => {
expect(mockAPIcall).toBeCalledWith(1, 'user@example.org', {
expect(mockAPIcall).toBeCalledWith(
expect.objectContaining({
variables: {
sessionId: 1,
email: 'user@example.org',
firstName: 'Petra',
lastName: 'Lustiger',
description: 'Keine Nickelbrille',
})
},
}),
)
})
it('toasts an error message', () => {