All files / spec loading_bar_ducks.js

100% Statements 18/18
100% Branches 0/0
100% Functions 7/7
100% Lines 18/18
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 52 53 54 551x   1x               1x 1x 1x     1x 1x       1x       1x         1x 1x       1x         1x           1x 1x 1x     1x 1x      
import expect from 'expect'
 
import {
  loadingBarReducer,
  SHOW,
  HIDE,
  showLoading,
  hideLoading,
} from '../src/loading_bar_ducks'
 
describe('loadingBarReducer', () => {
  it('returns the initial state', () => {
    expect(loadingBarReducer(undefined, {})).toEqual(0)
  })
 
  it('handles SHOW', () => {
    expect(
      loadingBarReducer(undefined, { type: SHOW })
    ).toEqual(1)
 
    expect(
      loadingBarReducer(0, { type: SHOW })
    ).toEqual(1)
 
    expect(
      loadingBarReducer(1, { type: SHOW })
    ).toEqual(2)
  })
 
  it('handles HIDE', () => {
    expect(
      loadingBarReducer(1, { type: HIDE })
    ).toEqual(0)
 
    expect(
      loadingBarReducer(undefined, { type: HIDE })
    ).toEqual(0)
 
 
    expect(
      loadingBarReducer(0, { type: HIDE })
    ).toEqual(0)
  })
})
 
describe('actions', () => {
  it('creates an action to show loading bar', () => {
    expect(showLoading()).toEqual({ type: SHOW })
  })
 
  it('creates an action to hide loading bar', () => {
    expect(hideLoading()).toEqual({ type: HIDE })
  })
})