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 {
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}
}