mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
implement test which checks if notification stays scheduled
This commit is contained in:
@@ -71,11 +71,6 @@ describe("NotificationService", () => {
|
|||||||
stopId: "1",
|
stopId: "1",
|
||||||
secondsRemaining: 120,
|
secondsRemaining: 120,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Simulate 200 + empty object for successful push notification
|
|
||||||
updateGlobalFetchMockJson({});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const notificationData1 = {
|
const notificationData1 = {
|
||||||
deviceId: "1",
|
deviceId: "1",
|
||||||
shuttleId: eta.shuttleId,
|
shuttleId: eta.shuttleId,
|
||||||
@@ -85,6 +80,11 @@ describe("NotificationService", () => {
|
|||||||
...notificationData1,
|
...notificationData1,
|
||||||
deviceId: "2",
|
deviceId: "2",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Simulate 200 + empty object for successful push notification
|
||||||
|
updateGlobalFetchMockJson({});
|
||||||
|
|
||||||
|
// Act
|
||||||
await notificationService.scheduleNotification(notificationData1);
|
await notificationService.scheduleNotification(notificationData1);
|
||||||
await notificationService.scheduleNotification(notificationData2);
|
await notificationService.scheduleNotification(notificationData2);
|
||||||
await repository.addOrUpdateEta(eta);
|
await repository.addOrUpdateEta(eta);
|
||||||
@@ -99,6 +99,28 @@ describe("NotificationService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("leaves notification in array if delivery unsuccessful", async () => {
|
it("leaves notification in array if delivery unsuccessful", async () => {
|
||||||
|
// Arrange
|
||||||
|
const eta: IEta = {
|
||||||
|
shuttleId: "1",
|
||||||
|
stopId: "1",
|
||||||
|
secondsRemaining: 120,
|
||||||
|
};
|
||||||
|
const notificationData = {
|
||||||
|
deviceId: "1",
|
||||||
|
shuttleId: eta.shuttleId,
|
||||||
|
stopId: eta.stopId,
|
||||||
|
}
|
||||||
|
|
||||||
|
updateGlobalFetchMockJson({}, 400);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await notificationService.scheduleNotification(notificationData);
|
||||||
|
await repository.addOrUpdateEta(eta);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
// The notification should stay scheduled to be retried once
|
||||||
|
// the ETA updates again
|
||||||
|
expect(notificationService.isNotificationScheduled(notificationData)).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user