Files
Sauci/apps/mobile/src/__tests__/lib/notifications.test.ts
T
jjbrunton 2bc69c2790 feat(mobile): surface pending questions
Add a conditional Home cue for partner-answered questions and route both the card and catch-up reminders into the pending answer flow. Track prompt engagement and cover hidden, visible, CTA, and notification behavior.
2026-08-29 23:24:19 +01:00

48 lines
1.3 KiB
TypeScript

import { router } from 'expo-router';
import { handleNotificationResponse } from '@/lib/notifications';
import { useMatchStore } from '@/store/matchStore';
jest.mock('expo-router', () => ({
router: { push: jest.fn() },
}));
jest.mock('expo-notifications', () => ({
setNotificationHandler: jest.fn(),
addNotificationResponseReceivedListener: jest.fn(),
getLastNotificationResponseAsync: jest.fn(),
getPermissionsAsync: jest.fn(),
requestPermissionsAsync: jest.fn(),
getExpoPushTokenAsync: jest.fn(),
}));
jest.mock('@/lib/crashlytics', () => ({
captureError: jest.fn(),
}));
const notificationResponse = (type: string) => ({
notification: {
request: {
content: { data: { type } },
},
},
}) as never;
describe('handleNotificationResponse', () => {
beforeEach(() => {
useMatchStore.setState({ currentView: 'active' });
});
it('opens the answer queue for a catch-up reminder', () => {
handleNotificationResponse(notificationResponse('catchup_reminder'));
expect(useMatchStore.getState().currentView).toBe('pending');
expect(router.push).toHaveBeenCalledWith('/(app)/swipe?mode=pending');
});
it('ignores unknown notification types', () => {
handleNotificationResponse(notificationResponse('unknown'));
expect(router.push).not.toHaveBeenCalled();
});
});