Created
May 19, 2016 12:08
-
-
Save ferrannp/83cd4d4fcaaf8a44e3d85fa30783c2c3 to your computer and use it in GitHub Desktop.
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
it('does check if we already fetched that id and only calls fetch if necessary', () => { | |
const store = mockStore({id: 1234, isFetching: false }}); | |
window.fetch = jest.fn().mockImplementation(() => Promise.resolve()); | |
store.dispatch(fetchData(1234)); // Same id | |
expect(window.fetch).not.toBeCalled(); | |
store.dispatch(fetchData(1234 + 1)); // Different id | |
expect(window.fetch).toBeCalled(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment