Created
September 26, 2020 08:57
-
-
Save janhesters/747802ba4409fcfa86ffa51cc026b5b4 to your computer and use it in GitHub Desktop.
Selector tests and setup with root reducer and actions array.
This file contains hidden or 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
// root-reducer.js | |
const rootReducer = combineReducers({ /* ... */ }); | |
const rootState = rootReducer(undefined, {}); | |
export { rootReducer, rootState }; | |
// in counter-reducer.test.js | |
import { rootReducer, rootState } from 'redux/root-reducer.js'; | |
import { setOffset } from 'features/offset/offset-reducer.js'; | |
// ... | |
assert({ | |
given: 'default state and a get count selector', | |
should: 'return 0', | |
actual: getCount(rootState), | |
expected: 0, | |
}); | |
{ | |
const actions = [incrementBy(10), setOffset(10), incrementBy(12)]; | |
const state = actions.reduce(rootReducer, rootState); | |
assert({ | |
given: 'state with a count, an offset and a get count selector', |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment