mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
fix constructors
This commit is contained in:
@@ -5,6 +5,7 @@ import http2 from "http2";
|
||||
import { IEta, IShuttle, IStop } from "../../../src/entities/entities";
|
||||
import { addMockShuttleToRepository, addMockStopToRepository } from "../../testHelpers/repositorySetupHelpers";
|
||||
import { AppleNotificationSender } from "../../../src/notifications/senders/AppleNotificationSender";
|
||||
import { InMemoryNotificationRepository } from "../../../src/repositories/InMemoryNotificationRepository";
|
||||
|
||||
jest.mock("http2");
|
||||
jest.mock("../../../src/notifications/senders/AppleNotificationSender");
|
||||
@@ -51,7 +52,11 @@ describe("ETANotificationScheduler", () => {
|
||||
mockNotificationSenderMethods(true);
|
||||
|
||||
const appleNotificationSender = new MockAppleNotificationSender(false);
|
||||
notificationService = new ETANotificationScheduler(repository, appleNotificationSender);
|
||||
notificationService = new ETANotificationScheduler(
|
||||
repository,
|
||||
new InMemoryNotificationRepository(),
|
||||
appleNotificationSender
|
||||
);
|
||||
});
|
||||
|
||||
function generateNotificationDataAndEta(shuttle: IShuttle, stop: IStop) {
|
||||
@@ -141,6 +146,7 @@ describe("ETANotificationScheduler", () => {
|
||||
mockNotificationSenderMethods(false);
|
||||
notificationService = new ETANotificationScheduler(
|
||||
repository,
|
||||
new InMemoryNotificationRepository(),
|
||||
new MockAppleNotificationSender(),
|
||||
)
|
||||
|
||||
@@ -176,38 +182,4 @@ describe("ETANotificationScheduler", () => {
|
||||
expect(http2.connect as jest.Mock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getAllScheduledNotificationsForDevice", () => {
|
||||
it("returns scheduled notifications for the device ID", async () => {
|
||||
// Arrange
|
||||
const shuttle1 = await addMockShuttleToRepository(repository, "1");
|
||||
const stop = await addMockStopToRepository(repository, "1");
|
||||
const { notificationData1 } = generateNotificationDataAndEta(shuttle1, stop);
|
||||
await notificationService.scheduleNotification(notificationData1);
|
||||
|
||||
const shuttle2 = {
|
||||
...shuttle1,
|
||||
id: "2",
|
||||
}
|
||||
await repository.addOrUpdateShuttle(shuttle2);
|
||||
|
||||
const notificationData2 = {
|
||||
...notificationData1,
|
||||
shuttleId: shuttle2.id,
|
||||
}
|
||||
await notificationService.scheduleNotification(notificationData2);
|
||||
|
||||
// Act
|
||||
const notifications = await notificationService.getAllScheduledNotificationsForDevice(notificationData1.deviceId);
|
||||
|
||||
// Assert
|
||||
expect(notifications.length).toBe(2);
|
||||
});
|
||||
|
||||
it("returns an empty array if there are no notifications", async () => {
|
||||
// Act
|
||||
const notifications = await notificationService.getAllScheduledNotificationsForDevice("1");
|
||||
expect(notifications.length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user