mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
add tests for reloadAPNsTokenIfTimePassed
This commit is contained in:
@@ -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 { NotificationService } from "../../src/services/NotificationService";
|
||||||
import { UnoptimizedInMemoryRepository } from "../../src/repositories/UnoptimizedInMemoryRepository";
|
import { UnoptimizedInMemoryRepository } from "../../src/repositories/UnoptimizedInMemoryRepository";
|
||||||
|
|
||||||
@@ -13,10 +13,17 @@ describe("NotificationService", () => {
|
|||||||
|
|
||||||
describe("reloadAPNsTokenIfTimePassed", () => {
|
describe("reloadAPNsTokenIfTimePassed", () => {
|
||||||
it("reloads the token if token hasn't been generated yet", async () => {
|
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 () => {
|
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);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user