I've been trying to simulate onPress using enzyme shallow render. However I'm unable to access TouchableOpacity due to react-intl
I've seen the helper functions for injecting intl into react components, but those seem to only work with React and not react-native.
it("should handle button presses", () => {
const onPress = sinon.spy();
const button = shallow(
<IntlProvider locale='en'>
<ButtonApprove
tintColor={STYLES.COLOR.BRAND_SUCCESS}
buttonStyle={{}}
containerStyle={{}}
handlePress={onPress}
/>
</IntlProvider>
);
// console.log(button.instance());
button.find(TouchableOpacity).simulate('press');
expect(onPress.calledOnce).toEqual(true);
});
Would JSdom be the way to go about this?