aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/__tests__/ducks/ui.js
blob: d3242815183ae7c29ec747932e135be034543e60 (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
jest.unmock('../../ducks/ui')
jest.unmock('../../ducks/flows')

import reducer, { setActiveMenu } from '../../ducks/ui'
import * as flowActions from '../../ducks/flows'

describe('ui reducer', () => {
    it('should return the initial state', () => {
        expect(reducer(undefined, {}).activeMenu).toEqual('Start')
    })

    it('should return the state for view', () => {
        expect(reducer(undefined, setActiveMenu('View')).activeMenu).toEqual('View')
    })

    it('should change the state to Start when deselecting a flow and we a currently at the flow tab', () => {
        expect(reducer(
            { activeMenu: 'Flow', isFlowSelected: true },
            flowActions.select(undefined)).activeMenu
        ).toEqual('Start')
    })

    it('should change the state to Flow when we selected a flow and no flow was selected before', () => {
        expect(reducer(
            { activeMenu: 'Start', isFlowSelected: false },
            flowActions.select(1)).activeMenu
        ).toEqual('Flow')
    })

    it('should not change the state to Flow when OPTIONS tab is selected and we selected a flow and a flow as selected before', () => {
        expect(reducer(
            { activeMenu: 'Options', isFlowSelected: true },
            flowActions.select(1)
        ).activeMenu).toEqual('Options')
    })
})