Skip to content

Commit 85370ec

Browse files
authored
Merge pull request #1944 from dannyprikaz/1881-users-router-unit-tests
1881 users router unit tests
2 parents 8b2481a + 5ac05c4 commit 85370ec

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

backend/routers/users.router.test.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@ describe('Unit Tests for userRouter', () => {
153153
.get(`/api/users/${mockId}`);
154154

155155
//Test
156-
expect(UserController.user_by_id).toHaveBeenCalled();
156+
expect(UserController.user_by_id).toHaveBeenCalledWith(
157+
expect.objectContaining({params: {UserId: mockId}}),
158+
expect.anything(), // Mock the response object
159+
expect.anything() // Mock the next function
160+
);
157161
expect(response.status).toBe(200);
158162
expect(response.body).toEqual(mockUser);
159163

@@ -176,7 +180,11 @@ describe('Unit Tests for userRouter', () => {
176180
.send(mockUpdatedEmail);
177181

178182
//Test
179-
expect(UserController.update).toHaveBeenCalled();
183+
expect(UserController.update).toHaveBeenCalledWith(
184+
expect.objectContaining({params: {UserId: mockId}}),
185+
expect.anything(), // Mock the response object
186+
expect.anything() // Mock the next function
187+
);
180188
expect(response.status).toBe(200);
181189
expect(response.body).toEqual(mockUser);
182190

@@ -198,7 +206,11 @@ describe('Unit Tests for userRouter', () => {
198206
.send(mockUpdatedEmail);
199207

200208
//Test
201-
expect(UserController.delete).toHaveBeenCalled();
209+
expect(UserController.delete).toHaveBeenCalledWith(
210+
expect.objectContaining({params: {UserId: mockId}}),
211+
expect.anything(), // Mock the response object
212+
expect.anything() // Mock the next function
213+
);
202214
expect(response.status).toBe(200);
203215
expect(response.body).toEqual(mockUser);
204216

0 commit comments

Comments
 (0)