From 8605b2087ae8af9e789df073723532fdc20f5283 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Sun, 2 Feb 2025 14:52:07 -0800 Subject: [PATCH] add sample key and mock fs return value --- test/services/NotificationServiceTests.test.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/services/NotificationServiceTests.test.ts b/test/services/NotificationServiceTests.test.ts index c4ab3a7..d34945e 100644 --- a/test/services/NotificationServiceTests.test.ts +++ b/test/services/NotificationServiceTests.test.ts @@ -1,6 +1,16 @@ -import { beforeEach, describe, expect, it } from "@jest/globals"; +import { beforeEach, describe, expect, it, jest } from "@jest/globals"; import { NotificationService } from "../../src/services/NotificationService"; import { UnoptimizedInMemoryRepository } from "../../src/repositories/UnoptimizedInMemoryRepository"; +import fs from "fs"; + +jest.mock("fs"); + +const sampleKey = `-----BEGIN PRIVATE KEY----- +9EKORECHU09 eouEUHKCREOFA12409kOHKOEU9125ADABOU098AOEBAOEI15bhao +XAOECR15bAAOECxrU91bAOEIAOERix145AOERDIIAOUX15997124xARODEARi119 +7k5AOEX151509KBRACOUDIAURCL1IAEO91245bAOECHDUAOE90kAOEB15139KAOA +19ax15qu +-----END PRIVATE KEY-----` describe("NotificationService", () => { let repository: UnoptimizedInMemoryRepository @@ -16,7 +26,9 @@ describe("NotificationService", () => { APNS_KEY_ID: "1", APNS_TEAM_ID: "1", APNS_KEY_PATH: "./dummy-path.p8" - } + }; + + (fs.readFileSync as jest.Mock).mockReturnValue(sampleKey); }) describe("reloadAPNsTokenIfTimePassed", () => {