Skip to content

Instantly share code, notes, and snippets.

@c089
Last active June 20, 2016 16:20
Show Gist options
  • Save c089/5808a500f41eb83122f25cb6c2d90990 to your computer and use it in GitHub Desktop.
Save c089/5808a500f41eb83122f25cb6c2d90990 to your computer and use it in GitHub Desktop.
// together:
const asyncEnhancer = // depends on your middleware and how you inject dependencies
const store = createStore(reducer, undefined, asyncEnhancer);
store.dispatch(myAsyncAction()).then(() => {
expect(mySelector(store.getState())).toEqual('foo');
});
// or separate:
describe('async action', () => {
it('dispatches action1 and action2', () => {
// depends on your async middleware and how you inject dependencies for that
});
});
describe('reducer', () => {
it('does foo when receiving action1 and action2', () => {
const actions = [action1(), action2()];
const state = actions.reduce(reducer, undefined);
expect(mySelector(state))).toEqual('foo');
});
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment