patch export error

This commit is contained in:
Sorrel Bri 2019-12-04 21:37:20 -08:00
parent ab02f945c6
commit 24b032e6f7
2 changed files with 22 additions and 6 deletions

View file

@ -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: []}
]
}
);
});
}); });

View file

@ -1,6 +1,9 @@
const initState = () => { export const initState = () => {
return { return {
epochs: [],
lexicon: [],
phones: {},
features: {}
} }
} }
@ -32,7 +35,7 @@ const addFeatureToPhone = (phones, phone, featureKey, featureValue) => {
return phones; return phones;
} }
const stateReducer = (state, action) => { export const stateReducer = (state, action) => {
switch (action.type) { switch (action.type) {
case 'INIT': { case 'INIT': {
return initState(); return initState();
@ -108,5 +111,3 @@ const stateReducer = (state, action) => {
return state; return state;
} }
} }
module.exports = {initState, stateReducer}