All files / src/tests/integrationTests/covenant index.js

47.06% Statements 8/17
0% Branches 0/5
33.33% Functions 1/3
47.06% Lines 8/17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 421x   1x           1x       1x 2x           1x                   1x             1x          
const Immutable = require('seamless-immutable')
 
const initialState = Immutable.from({
  shared: {},
  sharedWithMe: {},
  lastAction: {}
})
 
const actionTypes = {
  ADD_STATE: 'ADD_STATE'
}
 
const actionCreators = {
  addState: newState => ({
    type: actionTypes.ADD_STATE,
    payload: { newState }
  })
}
 
const reducer = (state = initialState, action) => {
  let nextState = state
  if (action.type === actionTypes.ADD_STATE) {
    const { newState } = action.payload
    nextState = state.set('shared', newState)
    return setLastAction(nextState, action)
  }
  return setLastAction(nextState, action)
}
 
const setLastAction = (state, action) => {
  if (action.type === '*/STROBE') {
    return state
  }
  return state.set('lastAction', action)
}
 
module.exports = {
  initialState,
  actionCreators,
  reducer
}