aboutsummaryrefslogtreecommitdiffstats
path: root/spec/javascript/vehicle_journeys/reducers/status_spec.js
blob: 8fc0f557efac2482bb3608d8a377b495f7dc8145 (plain)
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
42
43
44
45
import statusReducer from '../../../../app/javascript/vehicle_journeys/reducers/status'

let state = {}

const dispatch = function(){}

describe('status reducer', () => {
  beforeEach(() => {
    state = {
      fetchSuccess: true,
      isFetching: false
    }
  })

  it('should return the initial state', () => {
    expect(
      statusReducer(undefined, {})
    ).toEqual({})
  })

  it('should handle UNAVAILABLE_SERVER', () => {
    expect(
      statusReducer(state, {
        type: 'UNAVAILABLE_SERVER'
      })
    ).toEqual(Object.assign({}, state, {fetchSuccess: false}))
  })

  it('should handle RECEIVE_VEHICLE_JOURNEYS', () => {
    expect(
      statusReducer(state, {
        type: 'RECEIVE_VEHICLE_JOURNEYS'
      })
    ).toEqual(Object.assign({}, state, {fetchSuccess: true, isFetching: false}))
  })

  it('should handle FETCH_API', () => {
    expect(
      statusReducer(state, {
        type: 'FETCH_API'
      })
    ).toEqual(Object.assign({}, state, {isFetching: true}))
  })

})