add test to check that connection is reused

This commit is contained in:
2025-04-30 17:33:54 -07:00
parent 6e03dc7fe3
commit 9dcc17b687

View File

@@ -91,7 +91,7 @@ describe("AppleNotificationSender", () => {
});
describe("sendNotificationImmediately", () => {
it('makes the connection to the http server if the notification should be sent', async () => {
it('makes the connection to the http server if sending a notification for the first time', async () => {
const notificationArguments: NotificationAlertArguments = {
title: 'Test notification',
body: 'This notification will send',
@@ -103,6 +103,20 @@ describe("AppleNotificationSender", () => {
expect(result).toBe(true);
});
it('reuses the existing connection if sending another notification', async () => {
const notificationArguments: NotificationAlertArguments = {
title: 'Test notification',
body: 'This notification will send',
}
const result1 = await notificationSender.sendNotificationImmediately('1', notificationArguments);
const result2 = await notificationSender.sendNotificationImmediately('1', notificationArguments);
expect(http2.connect).toHaveBeenCalledTimes(1);
expect(result1).toBe(true);
expect(result2).toBe(true);
});
it('throws an error if the bundle ID is not set correctly', async () => {
process.env = {
...process.env,