From 9dcc17b68783e7a8cd190f361bd5e9d0cad549f8 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Wed, 30 Apr 2025 17:33:54 -0700 Subject: [PATCH] add test to check that connection is reused --- .../senders/AppleNotificationSenderTests.test.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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,