From 3ff041dd4e75c0dbab126c70cb57824b649e719e Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Sun, 2 Feb 2025 14:46:21 -0800 Subject: [PATCH] add tests for reloadAPNsTokenIfTimePassed --- test/services/NotificationServiceTests.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/services/NotificationServiceTests.test.ts b/test/services/NotificationServiceTests.test.ts index 0d25b1b..29982b3 100644 --- a/test/services/NotificationServiceTests.test.ts +++ b/test/services/NotificationServiceTests.test.ts @@ -1,4 +1,4 @@ -import { beforeEach, describe, it } from "@jest/globals"; +import { beforeEach, describe, expect, it } from "@jest/globals"; import { NotificationService } from "../../src/services/NotificationService"; import { UnoptimizedInMemoryRepository } from "../../src/repositories/UnoptimizedInMemoryRepository"; @@ -13,10 +13,17 @@ describe("NotificationService", () => { 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); }); })