@@ -666,7 +666,9 @@ describe("Integration Tests - /tickets", () => {
666
666
const mockRequestBody = {
667
667
comment : "This is a test comment without an image." ,
668
668
ticket_id : "ticket123" ,
669
- user_id : "user456"
669
+ user_id : "user456" ,
670
+ user_role : "CITIZEN" ,
671
+ date_created : "2022-01-01T12:00:00Z"
670
672
} ;
671
673
672
674
const mockServiceResponse = {
@@ -684,11 +686,7 @@ describe("Integration Tests - /tickets", () => {
684
686
685
687
expect ( response . body ) . toEqual ( mockServiceResponse ) ;
686
688
687
- expect ( ticketsService . addTicketCommentWithoutImage ) . toHaveBeenCalledWith (
688
- mockRequestBody . comment ,
689
- mockRequestBody . ticket_id ,
690
- mockRequestBody . user_id
691
- ) ;
689
+ expect ( ticketsService . addTicketCommentWithoutImage ) . toHaveBeenCalledWith ( mockRequestBody ) ;
692
690
} ) ;
693
691
694
692
test ( "should return 400 if required fields are missing" , async ( ) => {
@@ -703,14 +701,16 @@ describe("Integration Tests - /tickets", () => {
703
701
704
702
expect ( response . statusCode ) . toBe ( 400 ) ;
705
703
706
- expect ( response . body . error ) . toBe ( "Missing parameter(s): comment" ) ;
704
+ expect ( response . body . error ) . toBe ( "Missing parameter(s): comment, date_created, user_role " ) ;
707
705
} ) ;
708
706
709
707
test ( "should return 500 if there is an internal server error" , async ( ) => {
710
708
const mockRequestBody = {
711
709
comment : "This is a test comment without an image." ,
712
710
ticket_id : "ticket123" ,
713
- user_id : "user456"
711
+ user_id : "user456" ,
712
+ user_role : "CITIZEN" ,
713
+ date_created : "2022-01-01T12:00:00Z"
714
714
} ;
715
715
716
716
jest . spyOn ( ticketsService , "addTicketCommentWithoutImage" ) . mockRejectedValue ( new Error ( "Internal Server Error" ) ) ;
0 commit comments