Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ferrannp
Created May 19, 2016 12:04
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/3f39555ea9d79c63cf1c23836a0570c1 to your computer and use it in GitHub Desktop.
Save ferrannp/3f39555ea9d79c63cf1c23836a0570c1 to your computer and use it in GitHub Desktop.
pit('calls request and success actions if the fetch response was successful', () => {
window.fetch = jest.fn().mockImplementation(() =>
Promise.resolve(mockResponse(200, null, '{"id":"1234"}')));
return store.dispatch(fetchData(1234))
.then(() => {
const expectedActions = store.getActions();
expect(expectedActions.length).toBe(2);
expect(expectedActions[0]).toEqual({type: types.FETCH_DATA_REQUEST});
expect(expectedActions[1]).toEqual({type: types.FETCH_DATA_SUCCESS, id: 1234);
})
});
@tomsarduy
Copy link

tomsarduy commented Jan 2, 2017

I think in the tutorial is missing something like const store = mockStore({}), or am I confused?

@oscarnevarezleal
Copy link

Missing a } in line 11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment