mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
add test to check that connection is reused
This commit is contained in:
@@ -91,7 +91,7 @@ describe("AppleNotificationSender", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("sendNotificationImmediately", () => {
|
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 = {
|
const notificationArguments: NotificationAlertArguments = {
|
||||||
title: 'Test notification',
|
title: 'Test notification',
|
||||||
body: 'This notification will send',
|
body: 'This notification will send',
|
||||||
@@ -103,6 +103,20 @@ describe("AppleNotificationSender", () => {
|
|||||||
expect(result).toBe(true);
|
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 () => {
|
it('throws an error if the bundle ID is not set correctly', async () => {
|
||||||
process.env = {
|
process.env = {
|
||||||
...process.env,
|
...process.env,
|
||||||
|
|||||||
Reference in New Issue
Block a user