Skip to content

Commit 29a4c51

Browse files
committed
updated tests for comments
1 parent 100834e commit 29a4c51

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

nodejs_api/__tests__/integration/tickets.route.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,9 @@ describe("Integration Tests - /tickets", () => {
666666
const mockRequestBody = {
667667
comment: "This is a test comment without an image.",
668668
ticket_id: "ticket123",
669-
user_id: "user456"
669+
user_id: "user456",
670+
user_role: "CITIZEN",
671+
date_created: "2022-01-01T12:00:00Z"
670672
};
671673

672674
const mockServiceResponse = {
@@ -684,11 +686,7 @@ describe("Integration Tests - /tickets", () => {
684686

685687
expect(response.body).toEqual(mockServiceResponse);
686688

687-
expect(ticketsService.addTicketCommentWithoutImage).toHaveBeenCalledWith(
688-
mockRequestBody.comment,
689-
mockRequestBody.ticket_id,
690-
mockRequestBody.user_id
691-
);
689+
expect(ticketsService.addTicketCommentWithoutImage).toHaveBeenCalledWith(mockRequestBody);
692690
});
693691

694692
test("should return 400 if required fields are missing", async () => {
@@ -703,14 +701,16 @@ describe("Integration Tests - /tickets", () => {
703701

704702
expect(response.statusCode).toBe(400);
705703

706-
expect(response.body.error).toBe("Missing parameter(s): comment");
704+
expect(response.body.error).toBe("Missing parameter(s): comment, date_created, user_role");
707705
});
708706

709707
test("should return 500 if there is an internal server error", async () => {
710708
const mockRequestBody = {
711709
comment: "This is a test comment without an image.",
712710
ticket_id: "ticket123",
713-
user_id: "user456"
711+
user_id: "user456",
712+
user_role: "CITIZEN",
713+
date_created: "2022-01-01T12:00:00Z"
714714
};
715715

716716
jest.spyOn(ticketsService, "addTicketCommentWithoutImage").mockRejectedValue(new Error("Internal Server Error"));

0 commit comments

Comments
 (0)