From fbc08838df4fc5725cfbdf990e811fa9965b641a Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Mon, 31 Mar 2025 20:34:45 -0700 Subject: [PATCH] test unsubscribeFromNotificationChanges method --- .../NotificationRepositorySharedTests.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/repositories/NotificationRepositorySharedTests.test.ts b/test/repositories/NotificationRepositorySharedTests.test.ts index 6c7587f..d8df44e 100644 --- a/test/repositories/NotificationRepositorySharedTests.test.ts +++ b/test/repositories/NotificationRepositorySharedTests.test.ts @@ -183,6 +183,21 @@ describe.each(repositoryImplementations)('$name', (holder) => { }); }); + describe("unsubscribeFromNotificationChanges", () => { + it("stops calling subscribers when unsubscribed", async () => { + const mockCallback = jest.fn(); + repo.subscribeToNotificationChanges(mockCallback); + + await repo.addOrUpdateNotification(notification); + + repo.unsubscribeFromNotificationChanges(mockCallback); + + await repo.deleteNotificationIfExists(notification); + + expect(mockCallback).toHaveBeenCalledTimes(1); + }); + }); + describe("isNotificationScheduled", () => { it("returns true if the notification is in the repo", async () => { await repo.addOrUpdateNotification(notification);