Skip to content

Instantly share code, notes, and snippets.

@josser
Last active March 21, 2016 16:41
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 josser/11e1d8b0babb0c9fc905 to your computer and use it in GitHub Desktop.
Save josser/11e1d8b0babb0c9fc905 to your computer and use it in GitHub Desktop.
Is it ok to use initialState as stub for reducer tests importing it from reducer itself?
// Is it ok to use initialState as stub for reducer tests importing it from reducer itself?
import { initialState, fooReducer } from './reducers/foo';
var reducedState = { ... initialState }
reducedState.name = 'bar';
expect(fooReducer(initialState)).to.eql(reducedState);
// Here is different approach
import { fooReducer } from './reducers/foo';
var initialState = { foo: 'bar' };
var reducedState = { ... initialState }
reducedState.name = 'bar';
expect(fooReducer(initialState)).to.eql(reducedState);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment