move getAPNsFullUrlToUse method to the notification sender tests

This commit is contained in:
2025-03-24 10:05:10 -07:00
parent 6251f0e247
commit 5670efb042

View File

@@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it, jest } from "@jest/globals";
import http2 from "http2"; import http2 from "http2";
import { EventEmitter } from "node:events"; import { EventEmitter } from "node:events";
import { AppleNotificationSender } from "../../../src/notifications/senders/AppleNotificationSender"; import { AppleNotificationSender } from "../../../src/notifications/senders/AppleNotificationSender";
import { ETANotificationScheduler } from "../../../src/notifications/schedulers/ETANotificationScheduler";
jest.mock("http2"); jest.mock("http2");
@@ -63,4 +64,31 @@ describe("AppleNotificationSender", () => {
}); });
}); });
describe('getAPNsFullUrlToUse', () => {
it('should return the production URL when APNS_IS_PRODUCTION is set to "1"', () => {
process.env.APNS_IS_PRODUCTION = "1";
const deviceId = 'testDeviceId';
const result = AppleNotificationSender.getAPNsFullUrlToUse(deviceId);
const { fullUrl, host, path } = result;
expect(fullUrl).toBe(`https://api.push.apple.com/3/device/${deviceId}`);
expect(host).toBe("https://api.push.apple.com");
expect(path).toBe(`/3/device/${deviceId}`);
});
it('should return the sandbox URL when APNS_IS_PRODUCTION is set to something other than 1', () => {
process.env.APNS_IS_PRODUCTION = "0";
const deviceId = 'testDeviceId';
const result = AppleNotificationSender.getAPNsFullUrlToUse(deviceId);
const { fullUrl, host, path } = result;
expect(fullUrl).toBe(`https://api.development.push.apple.com/3/device/${deviceId}`);
expect(host).toBe("https://api.development.push.apple.com");
expect(path).toBe(`/3/device/${deviceId}`);
});
});
describe("sendNotificationImmediately", () => {
});
}); });