fix test stubs

This commit is contained in:
Oleksii Bulenok
2026-07-30 18:33:34 +02:00
parent 5d95a91437
commit 103c23517e
+14 -5
View File
@@ -21,9 +21,10 @@ jest.mock('react-native-safe-area-context', () => {
const inset = {top: 0, right: 0, bottom: 0, left: 0} const inset = {top: 0, right: 0, bottom: 0, left: 0}
return { return {
SafeAreaProvider: jest.fn().mockImplementation(({children}) => children), SafeAreaProvider: jest.fn().mockImplementation(({children}) => children),
SafeAreaConsumer: jest SafeAreaConsumer: jest.fn().mockImplementation(
.fn() /** @param {{children: (i: typeof inset) => unknown}} props */
.mockImplementation(({children}) => children(inset)), ({children}) => children(inset),
),
useSafeAreaInsets: jest.fn().mockImplementation(() => inset), useSafeAreaInsets: jest.fn().mockImplementation(() => inset),
} }
}) })
@@ -85,7 +86,9 @@ jest.mock('expo-application', () => ({
})) }))
jest.mock('expo-modules-core', () => ({ jest.mock('expo-modules-core', () => ({
requireNativeModule: jest.fn().mockImplementation(moduleName => { requireNativeModule: jest.fn().mockImplementation(
/** @param {string} moduleName */
moduleName => {
if (moduleName === 'ExpoPlatformInfo') { if (moduleName === 'ExpoPlatformInfo') {
return { return {
getIsReducedMotionEnabled: () => false, getIsReducedMotionEnabled: () => false,
@@ -96,7 +99,13 @@ jest.mock('expo-modules-core', () => ({
dismissAll: () => {}, dismissAll: () => {},
} }
} }
}),
const expoModules = /** @type {Record<string, unknown> | undefined} */ (
globalThis.expo?.modules
)
return expoModules?.[moduleName]
},
),
requireNativeViewManager: jest.fn().mockImplementation(_ => { requireNativeViewManager: jest.fn().mockImplementation(_ => {
return () => null return () => null
}), }),