Skip to content

Commit

Permalink
polishes unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
JSoufer committed Sep 25, 2024
1 parent 850a6d7 commit 5225989
Showing 1 changed file with 1 addition and 36 deletions.
37 changes: 1 addition & 36 deletions app/util/notifications/hooks/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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,
},
);
});
});

0 comments on commit 5225989

Please sign in to comment.