mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
add testing logic for scheduleNotification test
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user