add testing logic for scheduleNotification test

This commit is contained in:
2025-02-02 15:13:13 -08:00
parent 2c86d9189d
commit f8ff7f9cc9

View File

@@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it, jest } from "@jest/globals";
import { NotificationService } from "../../src/services/NotificationService"; import { NotificationService } from "../../src/services/NotificationService";
import { UnoptimizedInMemoryRepository } from "../../src/repositories/UnoptimizedInMemoryRepository"; import { UnoptimizedInMemoryRepository } from "../../src/repositories/UnoptimizedInMemoryRepository";
import fs from "fs"; import fs from "fs";
import { IEta } from "../../src/entities/entities";
jest.mock("fs"); jest.mock("fs");
@@ -49,7 +50,23 @@ describe("NotificationService", () => {
describe("scheduleNotification", () => { describe("scheduleNotification", () => {
it("sends a notification to given shuttle/stop ID when changed", async () => { 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 () => { it("clears the notification after delivering successfully", async () => {