From 3444e34912a40b0e2c63c215d10d7bbdc086d432 Mon Sep 17 00:00:00 2001 From: Daniel Prikazsky Date: Tue, 27 May 2025 18:12:19 -0700 Subject: [PATCH] Expect Delete and Update to be called with right inputs --- backend/routers/users.router.test.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/backend/routers/users.router.test.js b/backend/routers/users.router.test.js index 1a09948aa..b8f65e201 100644 --- a/backend/routers/users.router.test.js +++ b/backend/routers/users.router.test.js @@ -153,7 +153,11 @@ describe('Unit Tests for userRouter', () => { .get(`/api/users/${mockId}`); //Test - expect(UserController.user_by_id).toHaveBeenCalled(); + expect(UserController.user_by_id).toHaveBeenCalledWith( + expect.objectContaining({params: {UserId: mockId}}), + expect.anything(), // Mock the response object + expect.anything() // Mock the next function + ); expect(response.status).toBe(200); expect(response.body).toEqual(mockUser); @@ -176,7 +180,11 @@ describe('Unit Tests for userRouter', () => { .send(mockUpdatedEmail); //Test - expect(UserController.update).toHaveBeenCalled(); + expect(UserController.update).toHaveBeenCalledWith( + expect.objectContaining({params: {UserId: mockId}}), + expect.anything(), // Mock the response object + expect.anything() // Mock the next function + ); expect(response.status).toBe(200); expect(response.body).toEqual(mockUser); @@ -198,7 +206,11 @@ describe('Unit Tests for userRouter', () => { .send(mockUpdatedEmail); //Test - expect(UserController.delete).toHaveBeenCalled(); + expect(UserController.delete).toHaveBeenCalledWith( + expect.objectContaining({params: {UserId: mockId}}), + expect.anything(), // Mock the response object + expect.anything() // Mock the next function + ); expect(response.status).toBe(200); expect(response.body).toEqual(mockUser);