From 6473661607f966ee78e87065d3920759c248c4fa Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Mon, 3 Feb 2025 23:26:16 -0800 Subject: [PATCH] add tests for getAPNsFullUrlToUse --- .../services/NotificationServiceTests.test.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/services/NotificationServiceTests.test.ts b/test/services/NotificationServiceTests.test.ts index 980b0f7..f2a5dbc 100644 --- a/test/services/NotificationServiceTests.test.ts +++ b/test/services/NotificationServiceTests.test.ts @@ -178,6 +178,29 @@ describe("NotificationService", () => { }); }); + describe('getAPNsFullUrlToUse', () => { + it('should return the production URL when NODE_ENV is set to "production"', () => { + process.env.NODE_ENV = 'production'; + const deviceId = 'testDeviceId'; + const result = NotificationService.getAPNsFullUrlToUse(deviceId); + expect(result).toBe(`https://api.push.apple.com/3/device/${deviceId}`); + }); + + it('should return the sandbox URL when NODE_ENV is not set to "production"', () => { + process.env.NODE_ENV = 'development'; + const deviceId = 'testDeviceId'; + const result = NotificationService.getAPNsFullUrlToUse(deviceId); + expect(result).toBe(`https://api.sandbox.push.apple.com/3/device/${deviceId}`); + }); + + it('should append the correct device ID to the URL', () => { + process.env.NODE_ENV = 'production'; + const deviceId = 'device123'; + const result = NotificationService.getAPNsFullUrlToUse(deviceId); + expect(result).toBe(`https://api.push.apple.com/3/device/${deviceId}`); + }); + }); + describe("cancelNotification", () => { it("stops notification from sending to given shuttle/stop ID", async () => {