th3rdwave / react-native-safe-area-context

A flexible way to handle safe area insets in JS. Also works on Android and Web!
MIT License
2.09k stars 191 forks source link

How do we properly mock SafeAreaInsetsContext.Consumer? #361

Closed doublethefish closed 1 year ago

doublethefish commented 1 year ago

Issue #31 describes how to fully mock this package, but in the now deprecated SafeAreaConsumer way.

Also, jest/mock.js doesn't contain mocks for Consumer. Is there a specific reason for this or is it just an oversight?

What's the best way to proceed?

doublethefish commented 1 year ago

I didn't read the new docs which reference jest/mock.js 🤦‍♀️

This works fine.

// @ts-ignore: no type information
import mockSafeAreaContext from 'react-native-safe-area-context/jest/mock';

jest.mock('react-native-safe-area-context', () => mockSafeAreaContext);