From 9b5021715b5d24cd4ccbb465dd22d551d92d5e3e Mon Sep 17 00:00:00 2001 From: juan ignacio Date: Mon, 18 Sep 2023 10:47:14 -0300 Subject: [PATCH] refactor update and delete tests --- .../reply/__test__/replyApi.spec.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/api/marketplace/reply/__test__/replyApi.spec.ts b/src/api/marketplace/reply/__test__/replyApi.spec.ts index 7d8eccf..ef17533 100644 --- a/src/api/marketplace/reply/__test__/replyApi.spec.ts +++ b/src/api/marketplace/reply/__test__/replyApi.spec.ts @@ -89,15 +89,15 @@ describe('Marketplace Reply API', () => { const expectedResponse = expect.objectContaining(updates); - const postMock = jest - .spyOn(marketplaceClient, 'post') + const patchMock = jest + .spyOn(marketplaceClient, 'patch') .mockResolvedValueOnce({ data: { originalReply, ...updates } }); const response = await replyApi.update(originalReply.timestamp, updates); expect(response).toEqual(expectedResponse); - expect(postMock).toHaveBeenCalledWith( - `/api/bot/reply/${originalReply.timestamp}`, + expect(patchMock).toHaveBeenCalledWith( + `/api/reply/timestamp/${originalReply.timestamp}`, updates ); }); @@ -120,8 +120,8 @@ describe('Marketplace Reply API', () => { const expectedErrorMessage = 'Bad Request'; - const postMock = jest - .spyOn(marketplaceClient, 'post') + const patchMock = jest + .spyOn(marketplaceClient, 'patch') .mockRejectedValueOnce( new AxiosError( undefined, @@ -143,8 +143,8 @@ describe('Marketplace Reply API', () => { await expect( replyApi.update(originalReply.timestamp, updates) ).rejects.toThrowError(expectedErrorMessage); - expect(postMock).toHaveBeenCalledWith( - `/api/bot/reply/${originalReply.timestamp}`, + expect(patchMock).toHaveBeenCalledWith( + `/api/reply/timestamp/${originalReply.timestamp}`, updates ); }); @@ -160,7 +160,9 @@ describe('Marketplace Reply API', () => { await replyApi.remove(timestamp); - expect(deleteMock).toHaveBeenCalledWith(`/api/bot/reply/${timestamp}`); + expect(deleteMock).toHaveBeenCalledWith( + `/api/reply/timestamp/${timestamp}` + ); }); it('should throw an error when deleting a reply fails', async () => { @@ -191,7 +193,9 @@ describe('Marketplace Reply API', () => { await expect(replyApi.remove(timestamp)).rejects.toThrowError( expectedErrorMessage ); - expect(deleteMock).toHaveBeenCalledWith(`/api/bot/reply/${timestamp}`); + expect(deleteMock).toHaveBeenCalledWith( + `/api/reply/timestamp/${timestamp}` + ); }); }); });