RealOrangeOne / react-native-mock

A fully mocked and test-friendly version of react native (maintainers wanted)
MIT License
570 stars 153 forks source link

Mock for i18nManager #134

Open edmundito opened 7 years ago

edmundito commented 7 years ago

Hello, I'd like to add a suggestion to create a mock for React.i18nManager.

My team ran into an issue where an OSS module was referring it and failed to build during the test runner setup process. Our workaround is to import react-native-mock in the runner setup script and assign a i18nManager mock. However, it would be nice if react-native-mock supported it out of the box.

RealOrangeOne commented 7 years ago

Short term that's exactly the ideal fix for this! Long term i plan to do a large refactor job on the project in the coming weeks, i'll add this to the list!

joelpickup commented 7 years ago

@edmundito would you be able to share how you implemented this?

edmundito commented 7 years ago

@joelpickup In whichever test framework you're using in the initialization JS file, or via an import in your test, you can add the following:

const React = require('react-native');

React.I18nManager = {
  isRTL: false,
  allowRTL: () => {},
  forceRTL: () => {}
};