Last active
June 17, 2017 02:05
-
-
Save lotif/9c149f64725cb67fbeb596c4495a07b4 to your computer and use it in GitHub Desktop.
testing http calls
This file contains 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
// to mock a whole imported dependency, do this | |
jest.mock('my-http-client'); | |
import http from 'my-http-client'; | |
// ... | |
it('should change the text on click', () => { | |
http.get.mockImplementation({ body: 'the-return-of-my-get-request' }); | |
const sut = mount( | |
<Provider store={store}> | |
<MyComponent /> | |
</Provider> | |
); | |
sut.find('div').simulate('click'); | |
expect(sut.find('div').prop('children')).toEqual('the-return-of-my-get-request'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment