From 24b032e6f7db9056da661a2c6b62b31f50a44895 Mon Sep 17 00:00:00 2001 From: Sorrel Bri Date: Wed, 4 Dec 2019 21:37:20 -0800 Subject: [PATCH] patch export error --- src/reducers/stateReducer.epochs.test.js | 15 +++++++++++++++ src/reducers/stateReducer.js | 13 +++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/reducers/stateReducer.epochs.test.js b/src/reducers/stateReducer.epochs.test.js index cfc781a..ef3d463 100644 --- a/src/reducers/stateReducer.epochs.test.js +++ b/src/reducers/stateReducer.epochs.test.js @@ -34,4 +34,19 @@ describe('Epochs', () => { } ); }); + + it('epoch changes mutation returns new epochs list with mutation', () => { + const firstAction = {type: 'ADD_EPOCH', value: { name: 'epoch 2', changes: []}}; + const secondAction = {type: 'SET_EPOCH', value: { index: 0, changes: ['n>t/_#', '[+plosive]>[+nasal -plosive]/_n']}}; + const secondState = stateReducer(state, firstAction); + expect(stateReducer(secondState, secondAction)).toEqual( + {...state, + epochs: [ + {name: 'epoch 1', changes: ['n>t/_#', '[+plosive]>[+nasal -plosive]/_n']}, + {name: 'epoch 2', changes: []} + ] + } + ); + }); + }); \ No newline at end of file diff --git a/src/reducers/stateReducer.js b/src/reducers/stateReducer.js index 83811ec..ec03ac3 100644 --- a/src/reducers/stateReducer.js +++ b/src/reducers/stateReducer.js @@ -1,6 +1,9 @@ -const initState = () => { +export const initState = () => { return { - + epochs: [], + lexicon: [], + phones: {}, + features: {} } } @@ -32,7 +35,7 @@ const addFeatureToPhone = (phones, phone, featureKey, featureValue) => { return phones; } -const stateReducer = (state, action) => { +export const stateReducer = (state, action) => { switch (action.type) { case 'INIT': { return initState(); @@ -107,6 +110,4 @@ const stateReducer = (state, action) => { default: return state; } -} - -module.exports = {initState, stateReducer} \ No newline at end of file +} \ No newline at end of file