Skip to content

Instantly share code, notes, and snippets.

@tiagogomes772
Created October 22, 2018 08:02
Show Gist options
  • Save tiagogomes772/94cec5fabbb4f21aabea7f47a9ac9f7c to your computer and use it in GitHub Desktop.
Save tiagogomes772/94cec5fabbb4f21aabea7f47a9ac9f7c to your computer and use it in GitHub Desktop.
describe('AsyncActions', () => {
beforeAll(() => {
mockStore = ReduxMockStore.default(middlewares);
initialState = {};
});
it('Does a getRandomAdvice succeful', () => {
fetch.mockResponse(JSON.stringify({slip: {
advice: 'Advice'
}}));
const expectedActions = [
{ type: 'REQUEST_ADVICE' },
{ payload: 'Advice', type: 'RESPONSE_ADVICE_SUCCESS' },
];
const store = mockStore(initialState);
return (
store.dispatch(actions.getRandomAdvice()).then(() => {
expect(store.getActions()).toEqual(expectedActions);
})
);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment