Skip to content

Instantly share code, notes, and snippets.

@Nicktho
Created April 6, 2016 02:05
Show Gist options
  • Save Nicktho/da18b00deffdbe6b6a57bfb87041035d to your computer and use it in GitHub Desktop.
Save Nicktho/da18b00deffdbe6b6a57bfb87041035d to your computer and use it in GitHub Desktop.
describe('combineReducers', () => {
it('should combine multiple reducers to a single reducer', () => {
const notes = (state = [ 'hello world' ], action) => {
switch(action.type) {
case 'ADD_NOTE':
return [ ...state, action.payload ];
default:
return state;
}
};
const numbers = (state = [ 1 ], action) => {
switch(action.type) {
case 'ADD_NUMBER':
return [ ...state, action.payload ];
default:
return state;
}
};
const reducer = combineReducers({ notes, numbers });
const state = reducer({}, { type: 'ADD_NUMBER', payload: 2 });
expect(state).to.deep.equal({
notes: [ 'hello world' ],
numbers: [ 1, 2 ]
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment