aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/__tests__/ducks/ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/js/__tests__/ducks/ui.js')
-rw-r--r--web/src/js/__tests__/ducks/ui.js66
1 files changed, 33 insertions, 33 deletions
diff --git a/web/src/js/__tests__/ducks/ui.js b/web/src/js/__tests__/ducks/ui.js
index 2388a9ad..d3242815 100644
--- a/web/src/js/__tests__/ducks/ui.js
+++ b/web/src/js/__tests__/ducks/ui.js
@@ -1,36 +1,36 @@
-jest.unmock("../../ducks/ui");
-// @todo fix it ( this is why I don't like to add tests until our architecture is stable :P )
-jest.unmock("../../ducks/views/main");
+jest.unmock('../../ducks/ui')
+jest.unmock('../../ducks/flows')
-import reducer, { setActiveMenu } from '../../ducks/ui';
-import { SELECT } from '../../ducks/views/main';
+import reducer, { setActiveMenu } from '../../ducks/ui'
+import * as flowActions from '../../ducks/flows'
-describe("ui reducer", () => {
- it("should return the initial state", () => {
- expect(reducer(undefined, {})).toEqual({ activeMenu: 'Start'})
- }),
- it("should return the state for view", () => {
- expect(reducer(undefined, setActiveMenu('View'))).toEqual({ activeMenu: 'View'})
- }),
- it("should change the state to Start when deselecting a flow and we a currently at the flow tab", () => {
- expect(reducer({activeMenu: 'Flow'},
- { type: SELECT,
- currentSelection: '1',
- flowId : undefined
- })).toEqual({ activeMenu: 'Start'})
- }),
- it("should change the state to Flow when we selected a flow and no flow was selected before", () => {
- expect(reducer({activeMenu: 'Start'},
- { type: SELECT,
- currentSelection: undefined,
- flowId : '1'
- })).toEqual({ activeMenu: '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'},
- { type: SELECT,
- currentSelection: '1',
- flowId : '2'
- })).toEqual({ activeMenu: 'Options'})
+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')
+ })
+})