mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-19 08:50:29 +00:00
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import { beforeEach, describe, expect, it } from "@jest/globals";
|
|
import { NotificationService } from "../../src/services/NotificationService";
|
|
import { UnoptimizedInMemoryRepository } from "../../src/repositories/UnoptimizedInMemoryRepository";
|
|
|
|
describe("NotificationService", () => {
|
|
let repository: UnoptimizedInMemoryRepository
|
|
let notificationService: NotificationService;
|
|
|
|
beforeEach(() => {
|
|
repository = new UnoptimizedInMemoryRepository();
|
|
notificationService = new NotificationService(repository);
|
|
})
|
|
|
|
describe("reloadAPNsTokenIfTimePassed", () => {
|
|
it("reloads the token if token hasn't been generated yet", async () => {
|
|
notificationService.reloadAPNsTokenIfTimePassed();
|
|
expect(notificationService.lastRefreshedTimeMs).toBeDefined();
|
|
});
|
|
|
|
it("doesn't reload the token if last refreshed time is recent", async () => {
|
|
notificationService.reloadAPNsTokenIfTimePassed();
|
|
const lastRefreshedTimeMs = notificationService.lastRefreshedTimeMs;
|
|
|
|
notificationService.reloadAPNsTokenIfTimePassed();
|
|
// Expect no change to have occurred
|
|
expect(lastRefreshedTimeMs).toEqual(notificationService.lastRefreshedTimeMs);
|
|
});
|
|
})
|
|
|
|
describe("scheduleNotification", () => {
|
|
it("sends a notification to given shuttle/stop ID when changed", async () => {
|
|
|
|
});
|
|
|
|
it("clears the notification after delivering successfully", async () => {
|
|
|
|
});
|
|
});
|
|
|
|
describe("cancelNotification", () => {
|
|
it("stops notification from sending to given shuttle/stop ID", async () => {
|
|
|
|
});
|
|
});
|
|
|
|
describe("cancelAllNotifications", () => {
|
|
it("clears all notifications scheduled to be sent", async () => {
|
|
|
|
});
|
|
})
|
|
});
|