(for redux)
a standalone ES6 combine-reducers function. Unit tested. Babel pre-configured.
yarn run v1.3.2
$ jest --coverage
PASS test/combine-reducers.test.js
combineReducers
✓ should add a customer and a pony into eachs state (3ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.895s, estimated 1s
Ran all test suites.
---------------------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
---------------------|----------|----------|----------|----------|----------------|
All files | 100 | 0 | 100 | 100 | |
combine-reducers.js | 100 | 0 | 100 | 100 | 1 |
---------------------|----------|----------|----------|----------|----------------|
✨ Done in 1.88s.
import combineReducers from 'combine-reducers'
const reducerCustomers = (state = [], action) => action.type === 'SET_CUSTOMER' ? {
customer: action.customer
} : state
const reducerPonys = (state = [], action) => action.type === 'SET_PONY' ? {
pony: action.pony
} : state
const combinedReducers = combineReducers({
reducerCustomers,
reducerPonys
});