All files / @gce/relation/store reducers.js

88.89% Statements 8/9
100% Branches 5/5
66.67% Functions 2/3
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23    1x         1x 1x   1x           3x 1x     2x    
import { SET_INSUREDS, SET_LOADING } from './constants';
 
const initialState = {
  insureds: [],
  loading: true,
};
 
const setInsureds = (state, action) => ({ ...state, insureds: action.payload.insureds });
const setLoading = (state, action) => ({ ...state, loading: action.payload.loading });
 
const FUNCTION_BY_ACTION = {
  [SET_INSUREDS]: setInsureds,
  [SET_LOADING]: setLoading,
};
 
export default (state = initialState, action) => {
  if (action && action.type in FUNCTION_BY_ACTION) {
    return FUNCTION_BY_ACTION[action.type](state, action);
  }
 
  return state;
};