From 2556fdc6be4d8f17c3cf669f10def0d7db37f56e Mon Sep 17 00:00:00 2001 From: JSoufer Date: Tue, 17 Sep 2024 13:00:17 +0100 Subject: [PATCH] refactor tests --- app/util/notifications/hooks/index.test.ts | 47 +++------------------- 1 file changed, 6 insertions(+), 41 deletions(-) diff --git a/app/util/notifications/hooks/index.test.ts b/app/util/notifications/hooks/index.test.ts index c826067a63a..45db3c2219b 100644 --- a/app/util/notifications/hooks/index.test.ts +++ b/app/util/notifications/hooks/index.test.ts @@ -31,10 +31,6 @@ const mockNavigation = { navigate: mockNavigate, } as unknown as NavigationProp; -const bootstrapAndroidInitialNotification = jest - .fn() - .mockResolvedValue(undefined); - const mockNotificationEvent = (event: NotifeeEvent) => ({ type: event.type, detail: { @@ -52,25 +48,9 @@ describe('useNotificationHandler', () => { jest.clearAllMocks(); }); - it('sets initial badge count and initializes Android notifications on mount', async () => { - renderHook(() => - useNotificationHandler( - bootstrapAndroidInitialNotification, - mockNavigation, - ), - ); - - expect(bootstrapAndroidInitialNotification).toHaveBeenCalled(); - - jest.runAllTimers(); - }); - it('should handle notifications correctly', async () => { const { waitFor } = renderHook(() => - useNotificationHandler( - bootstrapAndroidInitialNotification, - mockNavigation, - ), + useNotificationHandler(mockNavigation), ); await act(async () => { @@ -96,10 +76,7 @@ describe('useNotificationHandler', () => { it('should do nothing if the EventType is DISMISSED', async () => { const { waitFor } = renderHook(() => - useNotificationHandler( - bootstrapAndroidInitialNotification, - mockNavigation, - ), + useNotificationHandler(mockNavigation), ); await act(async () => { @@ -126,10 +103,7 @@ describe('useNotificationHandler', () => { it('should do nothing if data.action is not tx', async () => { const { waitFor } = renderHook(() => - useNotificationHandler( - bootstrapAndroidInitialNotification, - mockNavigation, - ), + useNotificationHandler(mockNavigation), ); await act(async () => { @@ -158,10 +132,7 @@ describe('useNotificationHandler', () => { it('handleOpenedNotification should do nothing if notification is null', async () => { const { waitFor } = renderHook(() => - useNotificationHandler( - bootstrapAndroidInitialNotification, - mockNavigation, - ), + useNotificationHandler(mockNavigation), ); await act(async () => { @@ -183,10 +154,7 @@ describe('useNotificationHandler', () => { it('should navigate to the transaction view when the notification action is "tx"', async () => { const { waitFor } = renderHook(() => - useNotificationHandler( - bootstrapAndroidInitialNotification, - mockNavigation, - ), + useNotificationHandler(mockNavigation), ); await act(async () => { @@ -216,10 +184,7 @@ describe('useNotificationHandler', () => { })); const { waitFor } = renderHook(() => - useNotificationHandler( - bootstrapAndroidInitialNotification, - mockNavigation, - ), + useNotificationHandler(mockNavigation), ); await act(async () => {