Skip to content

Commit

Permalink
Updated submitter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ziggy-cyb committed Oct 23, 2023
1 parent 5089308 commit 1374bb3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions submitter/src/submission/services/__tests__/queueService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const queueService = new QueueService(server);
test("Queue service does not process any submissions if none found", async () => {
(prisma.submission.findMany as jest.Mock).mockResolvedValueOnce([]);

await queueService.processSubmissions();
expect(webhookService.postRequest).not.toBeCalled();
const row = await queueService.getSubmissions();
expect(row).toBe(undefined);
});

test("Queue service updates a submission entry with an error if the webhook fails", async () => {
Expand All @@ -46,7 +46,8 @@ test("Queue service updates a submission entry with an error if the webhook fail
});
const updateWithError = jest.spyOn(queueService, "updateWithError");

await queueService.processSubmissions();
const row = await queueService.getSubmissions();
await queueService.submit(row);
expect(updateWithError).toBeCalled();
});
test("Queue service updates a submission entry with a successful response if the webhook was successful", async () => {
Expand All @@ -69,7 +70,8 @@ test("Queue service updates a submission entry with a successful response if the
});

const updateFunc = jest.spyOn(queueService, "updateWithSuccess");
await queueService.processSubmissions();
const row = await queueService.getSubmissions();
await queueService.submit(row);

expect(updateFunc).toBeCalled();
});

0 comments on commit 1374bb3

Please sign in to comment.