|
1 | 1 | /* eslint-disable ts/ban-ts-comment */ |
2 | 2 | /* eslint-disable no-restricted-globals */ |
3 | | -import '@testing-library/react-native/extend-expect'; |
| 3 | + |
| 4 | +// Mock react-native-worklets first |
| 5 | +jest.mock('react-native-worklets', () => ({ |
| 6 | + __esModule: true, |
| 7 | + default: {}, |
| 8 | +})); |
| 9 | + |
| 10 | +// Mock react-native-reanimated |
| 11 | +jest.mock('react-native-reanimated', () => { |
| 12 | + const View = require('react-native').View; |
| 13 | + |
| 14 | + return { |
| 15 | + __esModule: true, |
| 16 | + default: { |
| 17 | + View, |
| 18 | + ScrollView: View, |
| 19 | + createAnimatedComponent: (component: any) => component, |
| 20 | + }, |
| 21 | + useSharedValue: jest.fn(() => ({ value: 0 })), |
| 22 | + useAnimatedStyle: jest.fn(fn => fn()), |
| 23 | + withTiming: jest.fn(value => value), |
| 24 | + withSpring: jest.fn(value => value), |
| 25 | + withDecay: jest.fn(value => value), |
| 26 | + withDelay: jest.fn((_, value) => value), |
| 27 | + withRepeat: jest.fn(value => value), |
| 28 | + withSequence: jest.fn((...values) => values[0]), |
| 29 | + cancelAnimation: jest.fn(), |
| 30 | + Easing: { |
| 31 | + linear: jest.fn(), |
| 32 | + ease: jest.fn(), |
| 33 | + quad: jest.fn(), |
| 34 | + cubic: jest.fn(), |
| 35 | + bezier: jest.fn(), |
| 36 | + in: jest.fn(fn => fn), |
| 37 | + out: jest.fn(fn => fn), |
| 38 | + inOut: jest.fn(fn => fn), |
| 39 | + }, |
| 40 | + FadeIn: { duration: jest.fn(() => ({})) }, |
| 41 | + FadeOut: { duration: jest.fn(() => ({})) }, |
| 42 | + FadeInDown: { duration: jest.fn(() => ({})) }, |
| 43 | + FadeInUp: { duration: jest.fn(() => ({})) }, |
| 44 | + FadeInLeft: { duration: jest.fn(() => ({})) }, |
| 45 | + FadeInRight: { duration: jest.fn(() => ({})) }, |
| 46 | + SlideInDown: { duration: jest.fn(() => ({})) }, |
| 47 | + SlideInUp: { duration: jest.fn(() => ({})) }, |
| 48 | + SlideInLeft: { duration: jest.fn(() => ({})) }, |
| 49 | + SlideInRight: { duration: jest.fn(() => ({})) }, |
| 50 | + Layout: {}, |
| 51 | + Keyframe: jest.fn(), |
| 52 | + }; |
| 53 | +}); |
| 54 | + |
| 55 | +// Mock expo-localization |
| 56 | +jest.mock('expo-localization', () => ({ |
| 57 | + getLocales: jest.fn(() => [ |
| 58 | + { |
| 59 | + languageTag: 'en-US', |
| 60 | + languageCode: 'en', |
| 61 | + textDirection: 'ltr', |
| 62 | + digitGroupingSeparator: ',', |
| 63 | + decimalSeparator: '.', |
| 64 | + measurementSystem: 'metric', |
| 65 | + currencyCode: 'USD', |
| 66 | + currencySymbol: '$', |
| 67 | + regionCode: 'US', |
| 68 | + }, |
| 69 | + ]), |
| 70 | +})); |
| 71 | + |
| 72 | +// Mock react-native-mmkv |
| 73 | +jest.mock('react-native-mmkv', () => ({ |
| 74 | + MMKV: jest.fn(() => ({ |
| 75 | + set: jest.fn(), |
| 76 | + getString: jest.fn(), |
| 77 | + getNumber: jest.fn(), |
| 78 | + getBoolean: jest.fn(), |
| 79 | + delete: jest.fn(), |
| 80 | + clearAll: jest.fn(), |
| 81 | + getAllKeys: jest.fn(() => []), |
| 82 | + })), |
| 83 | + useMMKVString: jest.fn((_key: string) => [undefined, jest.fn()]), |
| 84 | + useMMKVNumber: jest.fn((_key: string) => [undefined, jest.fn()]), |
| 85 | + useMMKVBoolean: jest.fn((_key: string) => [undefined, jest.fn()]), |
| 86 | + useMMKVObject: jest.fn((_key: string) => [undefined, jest.fn()]), |
| 87 | + createMMKV: jest.fn(() => ({ |
| 88 | + set: jest.fn(), |
| 89 | + getString: jest.fn(), |
| 90 | + getNumber: jest.fn(), |
| 91 | + getBoolean: jest.fn(), |
| 92 | + delete: jest.fn(), |
| 93 | + clearAll: jest.fn(), |
| 94 | + getAllKeys: jest.fn(() => []), |
| 95 | + })), |
| 96 | +})); |
4 | 97 |
|
5 | 98 | // react-hook form setup for testing |
6 | 99 | // @ts-expect-error |
|
0 commit comments