Files

91 lines
3.2 KiB
JavaScript

/* global jest */
require('react-native-gesture-handler/jestSetup');
jest.mock('@react-native-async-storage/async-storage', () => ({
getItem: jest.fn(() => Promise.resolve(null)),
setItem: jest.fn(() => Promise.resolve()),
removeItem: jest.fn(() => Promise.resolve()),
mergeItem: jest.fn(() => Promise.resolve()),
clear: jest.fn(() => Promise.resolve()),
getAllKeys: jest.fn(() => Promise.resolve([])),
multiGet: jest.fn(() => Promise.resolve([])),
multiSet: jest.fn(() => Promise.resolve()),
multiRemove: jest.fn(() => Promise.resolve()),
multiMerge: jest.fn(() => Promise.resolve()),
}));
jest.mock('@react-native-community/netinfo', () => ({
__esModule: true,
default: {
addEventListener: jest.fn(() => jest.fn()),
fetch: jest.fn(() => Promise.resolve({ isConnected: true, isInternetReachable: true })),
},
}));
jest.mock('@notifee/react-native', () => ({
__esModule: true,
default: {
requestPermission: jest.fn(() => Promise.resolve({ authorizationStatus: 1 })),
createChannel: jest.fn(() => Promise.resolve('formed-changes')),
displayNotification: jest.fn(() => Promise.resolve('notification-id')),
},
AuthorizationStatus: { NOT_DETERMINED: -1, DENIED: 0, AUTHORIZED: 1, PROVISIONAL: 2 },
AndroidImportance: { DEFAULT: 3 },
}));
jest.mock('lucide-react-native', () => {
const { View } = require('react-native');
return new Proxy({ __esModule: true }, { get: () => View });
});
jest.mock('@kingstinct/react-native-healthkit', () => ({
CategoryValueAppleStandHour: { stood: 0, idle: 1 },
CategoryValueSleepAnalysis: {
inBed: 0,
asleep: 1,
asleepUnspecified: 1,
awake: 2,
asleepCore: 3,
asleepDeep: 4,
asleepREM: 5,
},
isHealthDataAvailableAsync: jest.fn(() => Promise.resolve(false)),
clearBackgroundTypes: jest.fn(() => Promise.resolve(true)),
configureBackgroundTypes: jest.fn(() => Promise.resolve(true)),
UpdateFrequency: { immediate: 1, hourly: 2, daily: 3, weekly: 4 },
requestAuthorization: jest.fn(() => Promise.resolve(false)),
queryQuantitySamples: jest.fn(() => Promise.resolve([])),
queryCategorySamples: jest.fn(() => Promise.resolve([])),
queryWorkoutSamples: jest.fn(() => Promise.resolve([])),
}));
jest.mock('react-native-health-connect', () => ({
SdkAvailabilityStatus: { SDK_UNAVAILABLE: 1, SDK_UNAVAILABLE_PROVIDER_UPDATE_REQUIRED: 2, SDK_AVAILABLE: 3 },
getSdkStatus: jest.fn(() => Promise.resolve(1)),
initialize: jest.fn(() => Promise.resolve(false)),
requestPermission: jest.fn(() => Promise.resolve([])),
readRecords: jest.fn(() => Promise.resolve({ records: [] })),
openHealthConnectSettings: jest.fn(),
}));
jest.mock('react-native-view-shot', () => ({
captureRef: jest.fn(() => Promise.resolve('file:///tmp/life-companion-share.png')),
}));
jest.mock('react-native-haptic-feedback', () => ({
HapticFeedbackTypes: {
selection: 'selection',
impactLight: 'impactLight',
},
trigger: jest.fn(),
}));
jest.mock('react-native-file-access', () => ({
Dirs: { CacheDir: '/tmp/life-companion-cache' },
FileSystem: {
exists: jest.fn(() => Promise.resolve(true)),
unlink: jest.fn(() => Promise.resolve()),
writeFile: jest.fn(() => Promise.resolve()),
},
}));