Skip to content

Instantly share code, notes, and snippets.

@ferrannp
Created May 19, 2016 12:05
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/1ee189ded796f480861e88bdf1314966 to your computer and use it in GitHub Desktop.
Save ferrannp/1ee189ded796f480861e88bdf1314966 to your computer and use it in GitHub Desktop.
pit('calls request and failure actions if the fetch response was not successful', () => {
window.fetch = jest.fn().mockImplementation(() => Promise.resolve(mockResponse(
400, 'Test Error', '{"status":400, "statusText": Test Error!}')));
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_FAILURE,
error: {status: 400, statusText: 'Test Error'}});
})
});
@th3fallen
Copy link

store is never defined here...

@zarcode
Copy link

zarcode commented Dec 17, 2016

where does 'window' comes from?

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