Mock Linking - openURL & canOpenURL#12839
Closed
manosim wants to merge 7 commits intofacebook:masterfrom
manosim:mock-linking
Closed
Mock Linking - openURL & canOpenURL#12839manosim wants to merge 7 commits intofacebook:masterfrom manosim:mock-linking
manosim wants to merge 7 commits intofacebook:masterfrom
manosim:mock-linking
Conversation
mkonicek
reviewed
Mar 14, 2017
jest/setup.js
Outdated
| Linking: { | ||
| openURL: jest.fn(), | ||
| canOpenURL: jest.fn( | ||
| (url) => new Promise((resolve) => resolve(url)) |
Contributor
There was a problem hiding this comment.
This should return a boolean:
https://github.com/facebook/react-native/blob/master/Libraries/Linking/Linking.js#L164
Contributor
|
Good idea, thanks for doing it! Just one nit. |
Contributor
Author
|
@mkonicek I forgot about this PR - Is there anything else I need to change? |
Contributor
|
@javache has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Maxwell2022
pushed a commit
to Maxwell2022/react-native
that referenced
this pull request
Apr 19, 2017
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 facebook#12839
Differential Revision: D4908903
Pulled By: javache
fbshipit-source-id: 0b62e9c2a7f920dc8bf0a49c1973f65c473eb653
thotegowda
pushed a commit
to thotegowda/react-native
that referenced
this pull request
May 7, 2017
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 facebook#12839
Differential Revision: D4908903
Pulled By: javache
fbshipit-source-id: 0b62e9c2a7f920dc8bf0a49c1973f65c473eb653
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR brings 2 basic mocks for
Linking'sopenURL&canOpenURLmethods. Below you can find 2 examples on how to it works.