Skip to content

Instantly share code, notes, and snippets.

@josser

josser/foo.test.js

Last active Mar 21, 2016
Embed
What would you like to do?
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