add new epoch reducer action
This commit is contained in:
parent
faec991cd0
commit
a29d7177dd
2 changed files with 28 additions and 2 deletions
23
src/reducers/stateReducer.epochs.test.js
Normal file
23
src/reducers/stateReducer.epochs.test.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
import {stateReducer} from './stateReducer';
|
||||
|
||||
describe('Epochs', () => {
|
||||
const state = {};
|
||||
beforeEach(()=> {
|
||||
state.epochs = [
|
||||
{
|
||||
name: 'epoch 1',
|
||||
changes: []
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
it('epochs returned unaltered', () => {
|
||||
const action = {type: ''};
|
||||
expect(stateReducer(state, action)).toBe(state);
|
||||
});
|
||||
|
||||
it('epochs addition returns new epochs list', () => {
|
||||
const action = {type: 'ADD_EPOCH', value: { name: 'epoch 2', changes: []}};
|
||||
expect(stateReducer(state, action)).toEqual({...state, epochs: [...state.epochs, action.value]})
|
||||
})
|
||||
});
|
|
@ -52,6 +52,11 @@ const stateReducer = (state, action) => {
|
|||
return {...state, lexicon: newLexicon}
|
||||
}
|
||||
|
||||
case 'ADD_EPOCH': {
|
||||
let newEpoch = action.value;
|
||||
return {...state, epochs: [...state.epochs, newEpoch]}
|
||||
}
|
||||
|
||||
case 'ADD_FEATURE': {
|
||||
let positivePhones = action.value.positivePhones || [];
|
||||
let negativePhones = action.value.negativePhones || [];
|
||||
|
@ -69,7 +74,6 @@ const stateReducer = (state, action) => {
|
|||
);
|
||||
|
||||
positivePhones = positivePhones.map( positivePhone => findPhone(newPhoneObject, positivePhone) )
|
||||
// console.log(positivePhones)
|
||||
}
|
||||
|
||||
if (negativePhones) {
|
||||
|
@ -80,7 +84,6 @@ const stateReducer = (state, action) => {
|
|||
);
|
||||
|
||||
negativePhones = negativePhones.map( negativePhone => findPhone(newPhoneObject, negativePhone) )
|
||||
// console.log(negativePhones)
|
||||
}
|
||||
|
||||
let newFeature = {[action.value.feature]: {positive: positivePhones, negative: negativePhones}};
|
||||
|
|
Loading…
Reference in a new issue