From f8ff7f9cc93db1521b73c7a4ef1c856d0764a4a5 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Sun, 2 Feb 2025 15:13:13 -0800 Subject: [PATCH] add testing logic for scheduleNotification test --- test/services/NotificationServiceTests.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/services/NotificationServiceTests.test.ts b/test/services/NotificationServiceTests.test.ts index 4ef1953..a89dfa4 100644 --- a/test/services/NotificationServiceTests.test.ts +++ b/test/services/NotificationServiceTests.test.ts @@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it, jest } from "@jest/globals"; import { NotificationService } from "../../src/services/NotificationService"; import { UnoptimizedInMemoryRepository } from "../../src/repositories/UnoptimizedInMemoryRepository"; import fs from "fs"; +import { IEta } from "../../src/entities/entities"; jest.mock("fs"); @@ -49,7 +50,23 @@ describe("NotificationService", () => { describe("scheduleNotification", () => { it("sends a notification to given shuttle/stop ID when changed", async () => { + // Arrange + const eta: IEta = { + shuttleId: "1", + stopId: "1", + secondsRemaining: 120, + }; + // Act + await notificationService.scheduleNotification({ + deviceId: "1", + shuttleId: eta.shuttleId, + stopId: eta.stopId, + }); + await repository.addOrUpdateEta(eta); + + // Assert + // ...that notification (fetch request) was sent }); it("clears the notification after delivering successfully", async () => {