From 5225989b124463dd5e41df5f56570115b3c06afd Mon Sep 17 00:00:00 2001 From: JSoufer Date: Wed, 25 Sep 2024 18:40:41 +0100 Subject: [PATCH] polishes unit test --- app/util/notifications/hooks/index.test.ts | 37 +--------------------- 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/app/util/notifications/hooks/index.test.ts b/app/util/notifications/hooks/index.test.ts index 4f0512755d0..6428a197db5 100644 --- a/app/util/notifications/hooks/index.test.ts +++ b/app/util/notifications/hooks/index.test.ts @@ -62,7 +62,7 @@ describe('useNotificationHandler', () => { ); }); - it('does nothing if the EventType is DISMISSED', async () => { + it('does not navigate if the EventType is DISMISSED', async () => { (isNotificationsFeatureEnabled as jest.Mock).mockReturnValue(true); renderHook(() => useNotificationHandler(mockNavigation)); @@ -96,39 +96,4 @@ describe('useNotificationHandler', () => { expect(mockNavigation.navigate).not.toHaveBeenCalled(); }); - - it('processes notification on Android', async () => { - (isNotificationsFeatureEnabled as jest.Mock).mockReturnValue(true); - - renderHook(() => useNotificationHandler(mockNavigation)); - - const event = { - type: EventType.DELIVERED, - detail: { - notification, - }, - }; - - const callback = (NotificationsService.onBackgroundEvent as jest.Mock).mock - .calls[0][0]; - await callback(event); - - expect(NotificationsService.handleNotificationEvent).toHaveBeenCalledWith({ - type: event.type, - detail: event.detail, - callback: expect.any(Function), - }); - - const handleNotificationCallback = ( - NotificationsService.handleNotificationEvent as jest.Mock - ).mock.calls[0][0].callback; - await handleNotificationCallback(event.detail.notification); - - expect(mockNavigation.navigate).toHaveBeenCalledWith( - Routes.NOTIFICATIONS.DETAILS, - { - notificationId: notification.id, - }, - ); - }); });