diff --git a/test/notifications/senders/AppleNotificationSenderTests.test.ts b/test/notifications/senders/AppleNotificationSenderTests.test.ts index 948be7d..0ccf20d 100644 --- a/test/notifications/senders/AppleNotificationSenderTests.test.ts +++ b/test/notifications/senders/AppleNotificationSenderTests.test.ts @@ -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,