Created
April 6, 2016 02:05
-
-
Save Nicktho/da18b00deffdbe6b6a57bfb87041035d to your computer and use it in GitHub Desktop.
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
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