mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-02 22:41:18 +08:00
Summary:
This PR brings 2 basic mocks for `Linking`'s `openURL` & `canOpenURL` methods. Below you can find 2 examples on how to it works.
```javascript
it('presses the open website button', () => {
const wrapper = shallow(<Info />);
expect(wrapper).toBeDefined();
wrapper.find('TouchableOpacity').simulate('press');
expect(Linking.openURL).toHaveBeenCalledTimes(1);
expect(Linking.openURL).toHaveBeenCalledWith('https://www.hello.world/');
});
it('presses the call button', () => {
const wrapper = shallow(<MoreInfo />);
expect(wrapper).toBeDefined();
wrapper.find('TouchableOpacity').simulate('press');
expect(Linking.canOpenURL).toHaveBeenCalledTimes(1);
expect(Linking.canOpenURL).toHaveBeenCalledWith('tel:01273123123');
});
````
Closes https://github.com/facebook/react-native/pull/12839
Differential Revision: D4908903
Pulled By: javache
fbshipit-source-id: 0b62e9c2a7f920dc8bf0a49c1973f65c473eb653