diff --git a/src/reducers/stateReducer.features.test.js b/src/reducers/stateReducer.features.test.js index 67b9682..6256095 100644 --- a/src/reducers/stateReducer.features.test.js +++ b/src/reducers/stateReducer.features.test.js @@ -5,7 +5,7 @@ describe('Features', () => { features: [ 'low', 'high','back', 'rounded', 'sonorant', 'nasal', 'obstruent', 'occlusive', 'plosive', - 'prenasalized', 'aspirated', 'coronal', 'anterior' + 'prenasalized', 'aspirated', 'coronal' ] }; @@ -14,4 +14,9 @@ describe('Features', () => { expect(stateReducer(state, action)).toBe(state); }); + it('feature addition returns new feature list', () => { + const action = {type: 'ADD_FEATURE', value: {feature: 'anterior'}}; + expect(stateReducer(state, action)).toEqual({...state, features:[...state.features, action.value.feature]}) + }) + }); \ No newline at end of file diff --git a/src/reducers/stateReducer.js b/src/reducers/stateReducer.js index ca3173c..cbe1cc1 100644 --- a/src/reducers/stateReducer.js +++ b/src/reducers/stateReducer.js @@ -24,6 +24,11 @@ const stateReducer = (state, action) => { return {...state, lexicon: newLexicon} } + case 'ADD_FEATURE': { + let newFeature = action.value.feature; + return {...state, features:[...state.features, newFeature]} + } + default: return state; }