Last active
March 21, 2016 16:41
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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