Skip to content

Commit

Permalink
feat: delay notification removal
Browse files Browse the repository at this point in the history
  • Loading branch information
setchy committed May 8, 2024
1 parent 216b62e commit 52ff048
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/utils/remove-notification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -13,12 +15,33 @@ describe('utils/remove-notification.ts', () => {
expect(mockedSingleAccountNotifications[0].notifications.length).toBe(1);

const result = removeNotification(
mockSettings,
{ ...mockSettings, delayNotificationState: false },
notificationId,
mockedSingleAccountNotifications,
hostname,
);

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);
});
});

0 comments on commit 52ff048

Please sign in to comment.