@@ -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