Skip to content

Instantly share code, notes, and snippets.

@janhesters
Created September 26, 2020 08:57
Show Gist options
  • Save janhesters/747802ba4409fcfa86ffa51cc026b5b4 to your computer and use it in GitHub Desktop.
Save janhesters/747802ba4409fcfa86ffa51cc026b5b4 to your computer and use it in GitHub Desktop.
Selector tests and setup with root reducer and actions array.
// 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