- built-in mock Gitea backend (src/core/demo): repositories, issues, comments, reactions, labels/milestones, pulls, files, diff, reviews, inline comments, releases, notifications, activity, Actions runs/jobs/logs/artifacts/workflows, repo settings, orgs/teams/packages/credentials/admin, and benign writes - session wires demoFetch for the demo instance; welcome screen 'Try the demo' - demo E2E (16 tests over the real endpoint layer) + UI render E2E; minimal reanimated jest mock; README demo-mode section
42 lines
1.6 KiB
TypeScript
42 lines
1.6 KiB
TypeScript
/**
|
|
* Jest setup for Gitea Native.
|
|
*
|
|
* Native modules that cannot run in the Jest (Node) environment are mocked here.
|
|
* Test-specific mocks (e.g. expo-secure-store) live next to the tests that need them
|
|
* unless they are required globally.
|
|
*/
|
|
|
|
// AsyncStorage: official in-memory mock provided by the package.
|
|
jest.mock('@react-native-async-storage/async-storage', () =>
|
|
require('@react-native-async-storage/async-storage/jest/async-storage-mock'),
|
|
);
|
|
|
|
// Reanimated: minimal manual mock (the real package pulls native worklets).
|
|
jest.mock('react-native-reanimated', () => {
|
|
const { View } = require('react-native');
|
|
return {
|
|
__esModule: true,
|
|
default: { View, createAnimatedComponent: (component: unknown) => component },
|
|
useSharedValue: (value: unknown) => ({ value }),
|
|
useAnimatedStyle: () => ({}),
|
|
withTiming: (value: unknown) => value,
|
|
withRepeat: (value: unknown) => value,
|
|
withSequence: (...values: unknown[]) => values[values.length - 1],
|
|
withDelay: (_delay: number, value: unknown) => value,
|
|
cancelAnimation: () => undefined,
|
|
runOnJS: (fn: unknown) => fn,
|
|
runOnUI: (fn: unknown) => fn,
|
|
Easing: { linear: () => 0, ease: () => 0, inOut: () => 0, out: () => 0, in: () => 0 },
|
|
};
|
|
});
|
|
|
|
// Safe area: official mock so SafeAreaView/useSafeAreaInsets work in tests.
|
|
jest.mock('react-native-safe-area-context', () => require('react-native-safe-area-context/jest/mock'));
|
|
|
|
// Haptics: no native module in Jest.
|
|
jest.mock('expo-haptics', () => ({
|
|
selectionAsync: jest.fn(async () => undefined),
|
|
impactAsync: jest.fn(async () => undefined),
|
|
notificationAsync: jest.fn(async () => undefined),
|
|
}));
|