From 52ff048fd6c9c4c6d1023a0de1a7180944b1e18d Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Tue, 7 May 2024 22:41:54 -0400 Subject: [PATCH] feat: delay notification removal --- src/utils/remove-notification.test.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/utils/remove-notification.test.ts b/src/utils/remove-notification.test.ts index 998440af4..8d0d375a9 100644 --- a/src/utils/remove-notification.test.ts +++ b/src/utils/remove-notification.test.ts @@ -3,6 +3,8 @@ import { mockedSingleAccountNotifications, mockedSingleNotification, } from '../__mocks__/mockedData'; +import Constants from './constants'; +// import Constants from './constants'; import { removeNotification } from './remove-notification'; describe('utils/remove-notification.ts', () => { @@ -13,7 +15,7 @@ describe('utils/remove-notification.ts', () => { expect(mockedSingleAccountNotifications[0].notifications.length).toBe(1); const result = removeNotification( - mockSettings, + { ...mockSettings, delayNotificationState: false }, notificationId, mockedSingleAccountNotifications, hostname, @@ -21,4 +23,25 @@ describe('utils/remove-notification.ts', () => { expect(result[0].notifications.length).toBe(0); }); + + it('should set notification as opaque if delayNotificationState enabled', () => { + const mockElement = document.createElement('div'); + mockElement.id = mockedSingleAccountNotifications[0].notifications[0].id; + jest.spyOn(document, 'getElementById').mockReturnValue(mockElement); + + expect(mockedSingleAccountNotifications[0].notifications.length).toBe(1); + + const result = removeNotification( + { ...mockSettings, delayNotificationState: true }, + notificationId, + mockedSingleAccountNotifications, + hostname, + ); + + expect(result[0].notifications.length).toBe(1); + expect(document.getElementById).toHaveBeenCalledWith( + mockedSingleAccountNotifications[0].notifications[0].id, + ); + expect(mockElement.className).toContain(Constants.READ_CLASS_NAME); + }); });