From 9dd817be527c85c154c74d2777613b55a05e2f45 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Fri, 14 Jun 2024 17:06:17 -0400 Subject: [PATCH] fix: regression in delay notification state after tailwind animations --- src/hooks/useNotifications.test.ts | 5 +++++ src/utils/remove-notification.test.ts | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/hooks/useNotifications.test.ts b/src/hooks/useNotifications.test.ts index c76ab45da..027bdca93 100644 --- a/src/hooks/useNotifications.test.ts +++ b/src/hooks/useNotifications.test.ts @@ -2,6 +2,7 @@ import { act, renderHook, waitFor } from '@testing-library/react'; import axios, { AxiosError } from 'axios'; import nock from 'nock'; +import { mockSingleAccountNotifications } from '../__mocks__/notifications-mocks'; import { mockAuth, mockGitHubCloudAccount, @@ -299,6 +300,10 @@ describe('hooks/useNotifications.ts', () => { describe('removeNotificationFromState', () => { it('should remove a notification from state', async () => { + const mockElement = document.createElement('div'); + mockElement.id = mockSingleAccountNotifications[0].notifications[0].id; + jest.spyOn(document, 'getElementById').mockReturnValue(mockElement); + const notifications = [ { id: 1, title: 'This is a notification.' }, { id: 2, title: 'This is another one.' }, diff --git a/src/utils/remove-notification.test.ts b/src/utils/remove-notification.test.ts index 489fdaaa7..b328d16d4 100644 --- a/src/utils/remove-notification.test.ts +++ b/src/utils/remove-notification.test.ts @@ -6,6 +6,10 @@ import { removeNotification } from './remove-notification'; describe('utils/remove-notification.ts', () => { it('should remove a notification if it exists', () => { + const mockElement = document.createElement('div'); + mockElement.id = mockSingleAccountNotifications[0].notifications[0].id; + jest.spyOn(document, 'getElementById').mockReturnValue(mockElement); + expect(mockSingleAccountNotifications[0].notifications.length).toBe(1); const result = removeNotification(