mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
move getAPNsFullUrlToUse method to the notification sender tests
This commit is contained in:
@@ -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", () => {
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user