{"size": 974, "ext": "js", "max_stars_repo_path": "src/reducers/testReducer.js", "max_stars_repo_name": "artixx/supplier-a", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/reducers/testReducer.js", "max_issues_repo_name": "artixx/supplier-a", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/reducers/testReducer.js", "max_forks_repo_name": "artixx/supplier-a", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.6315789474, "max_line_length": 65, "alphanum_fraction": 0.6714579055}
import * as CON from 'src/redux/constants'
import { Map, fromJS } from 'immutable'

const defaultState = new Map({
  value: 0,
  valueAsync: 0,
  testRequest: '',
  testRequestState: CON.INITIAL
})

export default (state = defaultState, action) => {
  const { type, payload, response, error } = action

  switch (type) {
  case CON.TEST_CHANGE_VALUE:
    return state
      .set('value', state.get('value') + payload.delta)

  case CON.TEST_REQUEST + CON.START:
    return state
      .set('testRequestState', CON.PENDING)
  case CON.TEST_REQUEST + CON.SUCCESS:
    return state
      .set('testRequestState', CON.COMPLETED)
      .set('testRequest', fromJS(response))
  case CON.TEST_REQUEST + CON.FAIL:
    return state
      .set('testRequestState', CON.FAILED)
      .set('testRequest', fromJS(error))

  case CON.TEST_CHANGE_VALUE_ASYNC + CON.SUCCESS:
    return state
      .set('valueAsync', state.get('valueAsync') + payload.delta)
  default:
    return state
  }
}
