diff --git a/test/services/NotificationServiceTests.test.ts b/test/services/NotificationServiceTests.test.ts index 3cd2978..b0aa767 100644 --- a/test/services/NotificationServiceTests.test.ts +++ b/test/services/NotificationServiceTests.test.ts @@ -71,11 +71,6 @@ describe("NotificationService", () => { stopId: "1", secondsRemaining: 120, }; - - // Simulate 200 + empty object for successful push notification - updateGlobalFetchMockJson({}); - - // Act const notificationData1 = { deviceId: "1", shuttleId: eta.shuttleId, @@ -85,6 +80,11 @@ describe("NotificationService", () => { ...notificationData1, deviceId: "2", } + + // Simulate 200 + empty object for successful push notification + updateGlobalFetchMockJson({}); + + // Act await notificationService.scheduleNotification(notificationData1); await notificationService.scheduleNotification(notificationData2); await repository.addOrUpdateEta(eta); @@ -99,6 +99,28 @@ describe("NotificationService", () => { }); 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); }); });