From 75a4e133eda212ff9afff7b841f66cadbfc4089a Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Thu, 27 Mar 2025 11:40:32 -0700 Subject: [PATCH] fix failing test for notification deletion --- src/repositories/InMemoryNotificationRepository.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/repositories/InMemoryNotificationRepository.ts b/src/repositories/InMemoryNotificationRepository.ts index bd1db3f..513f7b7 100644 --- a/src/repositories/InMemoryNotificationRepository.ts +++ b/src/repositories/InMemoryNotificationRepository.ts @@ -107,6 +107,12 @@ export class InMemoryNotificationRepository implements NotificationRepository { const secondsThreshold = this.deviceIdsToDeliverTo[tupleKey.toString()][deviceId]; delete this.deviceIdsToDeliverTo[tupleKey.toString()][deviceId]; + + if (Object.keys(this.deviceIdsToDeliverTo[tupleKey.toString()]).length === 0) { + // no more device IDs remaining for this key combination + delete this.deviceIdsToDeliverTo[tupleKey.toString()]; + } + this.listeners.forEach((listener) => { const event: NotificationEvent = { event: 'delete',