{"size": 1258, "ext": "js", "max_stars_repo_path": "src/reducers/__tests__/map.js", "max_stars_repo_name": "s0ber/new_motion_assignment", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/reducers/__tests__/map.js", "max_issues_repo_name": "s0ber/new_motion_assignment", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/reducers/__tests__/map.js", "max_forks_repo_name": "s0ber/new_motion_assignment", "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": 29.9523809524, "max_line_length": 103, "alphanum_fraction": 0.6073131955}
import map from 'reducers/map'
import {ANONYMOUS} from 'constants'

describe('map reducer', () => {
  let state
  let action

  afterEach(() => {
    state = null
    action = null
  })

  it('updates state lat and lng properties on SET_DEFAULT_LAT_LNG', () => {
    state = {zoom: 12}
    action = {type: 'SET_DEFAULT_LAT_LNG', payload: {lat: 10, lng: 20}}
    expect(map(state, action)).to.eql({zoom: 12, lat: 10, lng: 20})
    expect(map(state, action)).not.to.eq(state)
  })

  it('updates map properties on UPDATE_MAP', () => {
    state = {zoom: 12, lat: 10, lng: 10}
    action = {type: 'UPDATE_MAP', payload: {zoom: 5, lng: 15}}

    expect(map(state, action)).to.eql({zoom: 5, lat: 10, lng: 15})
    expect(map(state, action)).not.to.eq(state)
  })

  it('updates chargers property on SET_CHARGERS', () => {
    state = {zoom: 12, lat: 10, lng: 10}
    action = {type: 'SET_CHARGERS', payload: ['charger1', 'charger2']}

    expect(map(state, action)).to.eql({zoom: 12, lat: 10, lng: 10, chargers: ['charger1', 'charger2']})
    expect(map(state, action)).not.to.eq(state)
  })

  it('returns default state on other actions', () => {
    state = {my: 'state'}
    action = {type: 'RANDOM_ACTION'}
    expect(map(state, action)).to.eq(state)
  })
})
