__tests__/actions/index.test.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 1

Size

Lines of Code 54
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 38
mnd 0
bc 0
fnc 5
dl 0
loc 54
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
1
import configureStore from 'redux-mock-store'
2
import * as actions from 'Src/actions'
3
import * as types from 'Src/constants/ActionTypes'
4
5
const mockStore = configureStore()
6
const store = mockStore()
7
8
describe('test actions', () => {
9
  beforeEach(() => {
10
    store.clearActions()
11
  })
12
13
  it('changeLang dispatches the correct action and payload', () => {
14
    const lang = 'zh-cn'
15
    store.dispatch(actions.changeLang(lang))
16
    const expectedActions = [
17
      {
18
        lang,
19
        type: types.CHANGE_LANG,
20
      },
21
    ]
22
    const s = expect(store.getActions())
23
    s.toEqual(expectedActions)
24
    s.toMatchSnapshot()
25
  })
26
27
  it('renderData dispatches the correct action and payload', () => {
28
    const data = { a: 6 }
29
    store.dispatch(actions.renderData(data))
30
    const expectedActions = [
31
      {
32
        data,
33
        type: types.RENDER_DATA,
34
      },
35
    ]
36
    const s = expect(store.getActions())
37
    s.toEqual(expectedActions)
38
    s.toMatchSnapshot()
39
  })
40
41
  it('importJson dispatches the correct action and payload', () => {
42
    const data = { b: 'g' }
43
    store.dispatch(actions.importJson(data))
44
    const expectedActions = [
45
      {
46
        data,
47
        type: types.IMPORT_JSON,
48
      },
49
    ]
50
    const s = expect(store.getActions())
51
    s.toEqual(expectedActions)
52
    s.toMatchSnapshot()
53
  })
54
})
55