Skip to content

Commit 60cf359

Browse files
committed
test: enhance queue worker mock and improve test assertions
1 parent 43dced3 commit 60cf359

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/PrismaQueue.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ describe("PrismaQueue", () => {
190190
// Stop the queue that was started in beforeEach
191191
await queue.stop();
192192

193-
queue.worker = vi.fn(async (_job) => {
193+
queue.worker = vi.fn(async (_job: EmailJob) => {
194194
await waitFor(JOB_WAIT);
195195
return { code: "200" };
196196
});
@@ -210,7 +210,8 @@ describe("PrismaQueue", () => {
210210
await queue.stop();
211211

212212
// May or may not have started processing
213-
const countAfterInterruption = queue.worker.mock.calls.length;
213+
const mockedWorker = queue.worker as ReturnType<typeof vi.fn>;
214+
const countAfterInterruption = mockedWorker.mock.calls.length;
214215

215216
// Now properly start and let all jobs complete
216217
void queue.start();
@@ -222,7 +223,7 @@ describe("PrismaQueue", () => {
222223
}
223224

224225
// Eventually both jobs should be processed
225-
expect(queue.worker.mock.calls.length).toBe(2);
226+
expect(mockedWorker.mock.calls.length).toBe(2);
226227
}, 10000); // Increase timeout for this test
227228
afterAll(() => {
228229
void queue.stop();

src/utils/time.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ describe("time utilities", () => {
4747
expect(isValidTimeZone("Pacific/Port_Moresby")).toBe(true);
4848
});
4949
});
50-
});
50+
});

0 commit comments

Comments
 (0)