Moved later/gitgram-ai/gitgram/ to apps/ritgram/ (fresh history; full history stays in caelum0x/gitgram). AITimeMachine stays separate in later/gitgram-ai per the Rithub master plan. Logs, pid files and env files are ignored; GPL-3.0 mobile/proximity noted in THIRD_PARTY_NOTICES. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
141 lines
3.7 KiB
JavaScript
141 lines
3.7 KiB
JavaScript
import '@testing-library/jest-native/extend-expect';
|
|
|
|
// Mock AsyncStorage
|
|
jest.mock('@react-native-async-storage/async-storage', () =>
|
|
require('@react-native-async-storage/async-storage/jest/async-storage-mock')
|
|
);
|
|
|
|
// Mock expo-router
|
|
jest.mock('expo-router', () => ({
|
|
useRouter: () => ({
|
|
push: jest.fn(),
|
|
replace: jest.fn(),
|
|
back: jest.fn(),
|
|
}),
|
|
useLocalSearchParams: () => ({}),
|
|
useSegments: () => [],
|
|
usePathname: () => '/',
|
|
Link: 'Link',
|
|
Stack: {
|
|
Screen: 'Screen',
|
|
},
|
|
}));
|
|
|
|
// Mock expo-image
|
|
jest.mock('expo-image', () => ({
|
|
Image: 'Image',
|
|
ImageSource: {},
|
|
}));
|
|
|
|
// Mock expo-constants
|
|
jest.mock('expo-constants', () => ({
|
|
__esModule: true,
|
|
default: {
|
|
expoConfig: {
|
|
extra: {},
|
|
},
|
|
easConfig: {},
|
|
},
|
|
}));
|
|
|
|
// Mock expo-sharing (used to let the user save/share a downloaded file)
|
|
jest.mock('expo-sharing', () => ({
|
|
isAvailableAsync: jest.fn(() => Promise.resolve(true)),
|
|
shareAsync: jest.fn(() => Promise.resolve()),
|
|
}));
|
|
|
|
// Mock expo-file-system legacy API (used for downloading the GDPR export to
|
|
// local app storage before handing it to expo-sharing)
|
|
jest.mock('expo-file-system/legacy', () => ({
|
|
cacheDirectory: 'file:///mock-cache/',
|
|
downloadAsync: jest.fn(() =>
|
|
Promise.resolve({ uri: 'file:///mock-cache/mock-export.json', status: 200 })
|
|
),
|
|
getInfoAsync: jest.fn(() => Promise.resolve({ exists: false, isDirectory: false })),
|
|
readDirectoryAsync: jest.fn(() => Promise.resolve([])),
|
|
deleteAsync: jest.fn(() => Promise.resolve()),
|
|
}));
|
|
|
|
// Mock expo-notifications
|
|
jest.mock('expo-notifications', () => ({
|
|
setNotificationHandler: jest.fn(),
|
|
getPermissionsAsync: jest.fn(() => Promise.resolve({ status: 'granted' })),
|
|
requestPermissionsAsync: jest.fn(() => Promise.resolve({ status: 'granted' })),
|
|
getExpoPushTokenAsync: jest.fn(() => Promise.resolve({ data: 'ExponentPushToken[test]' })),
|
|
setNotificationChannelAsync: jest.fn(() => Promise.resolve()),
|
|
addNotificationReceivedListener: jest.fn(() => ({ remove: jest.fn() })),
|
|
addNotificationResponseReceivedListener: jest.fn(() => ({ remove: jest.fn() })),
|
|
cancelAllScheduledNotificationsAsync: jest.fn(() => Promise.resolve()),
|
|
setBadgeCountAsync: jest.fn(() => Promise.resolve()),
|
|
AndroidImportance: {
|
|
MAX: 'max',
|
|
},
|
|
}));
|
|
|
|
// Mock expo-device
|
|
jest.mock('expo-device', () => ({
|
|
isDevice: false,
|
|
deviceName: 'Test Device',
|
|
brand: 'Test',
|
|
modelName: 'Device',
|
|
}));
|
|
|
|
// Mock expo-clipboard
|
|
jest.mock('expo-clipboard', () => ({
|
|
setStringAsync: jest.fn(() => Promise.resolve()),
|
|
}));
|
|
|
|
// Mock expo-video
|
|
jest.mock('expo-video', () => ({
|
|
VideoView: 'VideoView',
|
|
useVideoPlayer: jest.fn(() => ({
|
|
play: jest.fn(),
|
|
pause: jest.fn(),
|
|
loop: false,
|
|
muted: false,
|
|
})),
|
|
}));
|
|
|
|
// Mock expo-image-picker
|
|
jest.mock('expo-image-picker', () => ({
|
|
requestMediaLibraryPermissionsAsync: jest.fn(() =>
|
|
Promise.resolve({ status: 'granted' })
|
|
),
|
|
launchImageLibraryAsync: jest.fn(() =>
|
|
Promise.resolve({
|
|
canceled: false,
|
|
assets: [{ uri: 'file://test-image.jpg' }],
|
|
})
|
|
),
|
|
}));
|
|
|
|
// Mock @react-native-community/netinfo
|
|
jest.mock('@react-native-community/netinfo', () => ({
|
|
fetch: jest.fn(() => Promise.resolve({ isConnected: true })),
|
|
addEventListener: jest.fn(() => jest.fn()),
|
|
}));
|
|
|
|
// Mock expo-haptics
|
|
jest.mock('expo-haptics', () => ({
|
|
ImpactFeedbackStyle: {
|
|
Light: 'light',
|
|
Medium: 'medium',
|
|
Heavy: 'heavy',
|
|
},
|
|
NotificationFeedbackType: {
|
|
Success: 'success',
|
|
Warning: 'warning',
|
|
Error: 'error',
|
|
},
|
|
impactAsync: jest.fn(() => Promise.resolve()),
|
|
notificationAsync: jest.fn(() => Promise.resolve()),
|
|
selectionAsync: jest.fn(() => Promise.resolve()),
|
|
}));
|
|
|
|
// Silence console warnings in tests
|
|
global.console = {
|
|
...console,
|
|
warn: jest.fn(),
|
|
error: jest.fn(),
|
|
};
|