From 0765b80144760de520fc945bc855f8e6f3164aa8 Mon Sep 17 00:00:00 2001 From: Hannes Heine Date: Tue, 10 Aug 2021 15:15:52 +0200 Subject: [PATCH] Changed the expected values that are given from the apollo call. --- .../UserProfile/UserCard_FormUserData.spec.js | 39 +++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.spec.js index 5c8886887..a8e03fcbf 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.spec.js @@ -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', { - firstName: 'Petra', - lastName: 'Lustiger', - description: 'Keine Nickelbrille', - }) + 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', { - firstName: 'Petra', - lastName: 'Lustiger', - description: 'Keine Nickelbrille', - }) + expect(mockAPIcall).toBeCalledWith( + expect.objectContaining({ + variables: { + sessionId: 1, + email: 'user@example.org', + firstName: 'Petra', + lastName: 'Lustiger', + description: 'Keine Nickelbrille', + }, + }), + ) }) it('toasts an error message', () => {