add test cases for sendNotificationImmediately

This commit is contained in:
2025-03-24 10:09:37 -07:00
parent 5670efb042
commit e433662f19

View File

@@ -1,7 +1,10 @@
import { beforeEach, describe, expect, it, jest } from "@jest/globals"; import { beforeEach, describe, expect, it, jest } from "@jest/globals";
import http2 from "http2"; import http2 from "http2";
import { EventEmitter } from "node:events"; import { EventEmitter } from "node:events";
import { AppleNotificationSender } from "../../../src/notifications/senders/AppleNotificationSender"; import {
AppleNotificationSender,
NotificationAlertArguments
} from "../../../src/notifications/senders/AppleNotificationSender";
import { ETANotificationScheduler } from "../../../src/notifications/schedulers/ETANotificationScheduler"; import { ETANotificationScheduler } from "../../../src/notifications/schedulers/ETANotificationScheduler";
jest.mock("http2"); jest.mock("http2");
@@ -89,6 +92,26 @@ describe("AppleNotificationSender", () => {
}); });
describe("sendNotificationImmediately", () => { describe("sendNotificationImmediately", () => {
it('makes the connection to the http server if the notification should be sent', async () => {
}); });
it('throws an error if the bundle ID is not set correctly', async () => {
});
it('does not send notification if shouldActuallySendNotifications is false', async () => {
notificationSender = new AppleNotificationSender(false);
const notificationArguments: NotificationAlertArguments = {
title: 'Test notification',
body: 'This notification should not send',
}
const result = await notificationSender.sendNotificationImmediately('1', notificationArguments);
expect(http2.connect).not.toHaveBeenCalled();
expect(result).toBe(true);
});
});
}); });