Passed
Pull Request — master (#114)
by Huu-Phat
04:15
created

cms/src/core/state/drawer/__tests__/reducers.spec.js   A

Complexity

Total Complexity 6
Complexity/F 1

Size

Lines of Code 45
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 27
mnd 0
bc 0
fnc 6
dl 0
loc 45
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
1
import drawerReducer from '../reducers'
2
3
describe('drawer reducers', () => {
4
  it('should return state with open drawer', function() {
5
    const initState = {
6
      open: false
7
    }
8
    const action = {
9
      type: 'drawer/openDrawer'
10
    }
11
    expect(drawerReducer(initState, action)).toEqual({
12
      open: true
13
    })
14
  })
15
16
  it('should return state with close drawer', function() {
17
    const initState = {
18
      open: true
19
    }
20
    const action = {
21
      type: 'drawer/closeDrawer'
22
    }
23
    expect(drawerReducer(initState, action)).toEqual({
24
      open: false
25
    })
26
  })
27
28
  it('should return state with unknown action type', function() {
29
    const initState = {
30
      open: false
31
    }
32
    const action = {
33
      type: ''
34
    }
35
    expect(drawerReducer(initState, action)).toEqual({
36
      open: false
37
    })
38
  })
39
40
  it('should throw error when calling reducer with nothing', function() {
41
    expect(() => {
42
      drawerReducer()
43
    }).toThrow(TypeError)
44
  })
45
})
46