aboutsummaryrefslogtreecommitdiffstats
path: root/spec/javascript/journey_patterns/reducers/status_spec.js
blob: ab094088a6d3af2757a864c89d1077441d643ed9 (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
46
47
48
49
50
51
import statusReducer from '../../../../app/javascript/journey_patterns/reducers/status'

let state = {}

let pagination = {
  page : 2,
  totalCount : 25,
  stateChanged: false,
  perPage: 12
}
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_JOURNEY_PATTERNS', () => {
    expect(
      statusReducer(state, {
        type: 'RECEIVE_JOURNEY_PATTERNS'
      })
    ).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}))
  })

})