Skip to content

Commit

Permalink
test(solidarity): adds tests to new validTickets logic on createSuppo…
Browse files Browse the repository at this point in the history
…rtRequests
  • Loading branch information
Viviane Dias committed Dec 8, 2023
1 parent 0b1feb6 commit be0ac27
Showing 1 changed file with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@ describe("createSupportRequests", () => {
"No valid tickets to save as support requests"
);
});
it("should throw an error if there are no 'open' tickets", async () => {
await expect(
createSupportRequests(
[{ requester_id: 1, id: 1, status: "closed" }] as Ticket[],
[{ user_id: 1 }] as User[]
)
).rejects.toThrow("No valid tickets to save as support requests");
});
it("should return error res when no user is found for the ticket", async () => {
expect(
await createSupportRequests(
[{ requester_id: 1, id: 1 }] as Ticket[],
[{ requester_id: 1, id: 1, status: "open" }] as Ticket[],
[{ user_id: 2 }, { user_id: 3 }] as User[]
)
).toStrictEqual(
Expand All @@ -24,7 +32,9 @@ describe("createSupportRequests", () => {
it("should return error res when ticket has unsupported support type", async () => {
expect(
await createSupportRequests(
[{ requester_id: 1, id: 1, subject: "foo bar" }] as Ticket[],
[
{ requester_id: 1, id: 1, subject: "foo bar", status: "open" },
] as Ticket[],
[{ user_id: 1 }] as User[]
)
).toStrictEqual(
Expand All @@ -40,7 +50,14 @@ describe("createSupportRequests", () => {
});
expect(
await createSupportRequests(
[{ id: 1, requester_id: 1, subject: "psicológico" } as Ticket],
[
{
id: 1,
requester_id: 1,
subject: "psicológico",
status: "open",
} as Ticket,
],
[
{
user_id: 1,
Expand All @@ -64,7 +81,14 @@ describe("createSupportRequests", () => {
});
expect(
await createSupportRequests(
[{ id: 1, requester_id: 1, subject: "psicológico" } as Ticket],
[
{
id: 1,
requester_id: 1,
subject: "psicológico",
status: "open",
} as Ticket,
],
[
{
user_id: 1,
Expand Down

0 comments on commit be0ac27

Please sign in to comment.