Skip to content

Instantly share code, notes, and snippets.

@ferrannp
Created May 19, 2016 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferrannp/83cd4d4fcaaf8a44e3d85fa30783c2c3 to your computer and use it in GitHub Desktop.
Save ferrannp/83cd4d4fcaaf8a44e3d85fa30783c2c3 to your computer and use it in GitHub Desktop.
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