mirror of
https://github.com/hanzo-apps/android-rn-obytes.git
synced 2026-11-09 15:50:32 +00:00
104 lines
2.9 KiB
TypeScript
104 lines
2.9 KiB
TypeScript
/* eslint-disable ts/ban-ts-comment */
|
|
/* eslint-disable no-restricted-globals */
|
|
|
|
// Mock react-native-worklets first
|
|
jest.mock('react-native-worklets', () => ({
|
|
__esModule: true,
|
|
default: {},
|
|
}));
|
|
|
|
// Mock react-native-reanimated
|
|
jest.mock('react-native-reanimated', () => {
|
|
const View = require('react-native').View;
|
|
|
|
return {
|
|
__esModule: true,
|
|
default: {
|
|
View,
|
|
ScrollView: View,
|
|
createAnimatedComponent: (component: any) => component,
|
|
},
|
|
useSharedValue: jest.fn(() => ({ value: 0 })),
|
|
useAnimatedStyle: jest.fn(fn => fn()),
|
|
withTiming: jest.fn(value => value),
|
|
withSpring: jest.fn(value => value),
|
|
withDecay: jest.fn(value => value),
|
|
withDelay: jest.fn((_, value) => value),
|
|
withRepeat: jest.fn(value => value),
|
|
withSequence: jest.fn((...values) => values[0]),
|
|
cancelAnimation: jest.fn(),
|
|
Easing: {
|
|
linear: jest.fn(),
|
|
ease: jest.fn(),
|
|
quad: jest.fn(),
|
|
cubic: jest.fn(),
|
|
bezier: jest.fn(),
|
|
in: jest.fn(fn => fn),
|
|
out: jest.fn(fn => fn),
|
|
inOut: jest.fn(fn => fn),
|
|
},
|
|
FadeIn: { duration: jest.fn(() => ({})) },
|
|
FadeOut: { duration: jest.fn(() => ({})) },
|
|
FadeInDown: { duration: jest.fn(() => ({})) },
|
|
FadeInUp: { duration: jest.fn(() => ({})) },
|
|
FadeInLeft: { duration: jest.fn(() => ({})) },
|
|
FadeInRight: { duration: jest.fn(() => ({})) },
|
|
SlideInDown: { duration: jest.fn(() => ({})) },
|
|
SlideInUp: { duration: jest.fn(() => ({})) },
|
|
SlideInLeft: { duration: jest.fn(() => ({})) },
|
|
SlideInRight: { duration: jest.fn(() => ({})) },
|
|
Layout: {},
|
|
Keyframe: jest.fn(),
|
|
};
|
|
});
|
|
|
|
// Mock expo-localization
|
|
jest.mock('expo-localization', () => ({
|
|
getLocales: jest.fn(() => [
|
|
{
|
|
languageTag: 'en-US',
|
|
languageCode: 'en',
|
|
textDirection: 'ltr',
|
|
digitGroupingSeparator: ',',
|
|
decimalSeparator: '.',
|
|
measurementSystem: 'metric',
|
|
currencyCode: 'USD',
|
|
currencySymbol: '$',
|
|
regionCode: 'US',
|
|
},
|
|
]),
|
|
}));
|
|
|
|
// Mock react-native-mmkv
|
|
jest.mock('react-native-mmkv', () => ({
|
|
MMKV: jest.fn(() => ({
|
|
set: jest.fn(),
|
|
getString: jest.fn(),
|
|
getNumber: jest.fn(),
|
|
getBoolean: jest.fn(),
|
|
delete: jest.fn(),
|
|
clearAll: jest.fn(),
|
|
getAllKeys: jest.fn(() => []),
|
|
})),
|
|
useMMKVString: jest.fn((_key: string) => [undefined, jest.fn()]),
|
|
useMMKVNumber: jest.fn((_key: string) => [undefined, jest.fn()]),
|
|
useMMKVBoolean: jest.fn((_key: string) => [undefined, jest.fn()]),
|
|
useMMKVObject: jest.fn((_key: string) => [undefined, jest.fn()]),
|
|
createMMKV: jest.fn(() => ({
|
|
set: jest.fn(),
|
|
getString: jest.fn(),
|
|
getNumber: jest.fn(),
|
|
getBoolean: jest.fn(),
|
|
delete: jest.fn(),
|
|
clearAll: jest.fn(),
|
|
getAllKeys: jest.fn(() => []),
|
|
})),
|
|
}));
|
|
|
|
// Global window object setup for React Native testing
|
|
// @ts-expect-error
|
|
global.window = {};
|
|
|
|
// @ts-expect-error
|
|
global.window = global;
|