update tests and implementation ofr getAPNsFullUrlToUse

This commit is contained in:
2025-02-10 13:30:29 -08:00
parent da224c36ed
commit baa94eeef5
2 changed files with 28 additions and 13 deletions

View File

@@ -185,21 +185,22 @@ describe("NotificationService", () => {
process.env.NODE_ENV = 'production';
const deviceId = 'testDeviceId';
const result = NotificationService.getAPNsFullUrlToUse(deviceId);
expect(result).toBe(`https://api.push.apple.com/3/device/${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 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}`);
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}`);
});
});