From 37475217bf05fa44eba1551d318e6a5f6d088d7a Mon Sep 17 00:00:00 2001 From: Clemens Date: Thu, 16 Jun 2016 13:25:58 +0200 Subject: added tests for ui --- web/src/js/__tests__/ducks/ui.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 web/src/js/__tests__/ducks/ui.js (limited to 'web/src/js/__tests__/ducks/ui.js') diff --git a/web/src/js/__tests__/ducks/ui.js b/web/src/js/__tests__/ducks/ui.js new file mode 100644 index 00000000..ee1a008d --- /dev/null +++ b/web/src/js/__tests__/ducks/ui.js @@ -0,0 +1,34 @@ +jest.unmock("../../ducks/ui"); + +import reducer, {setActiveMenu, SELECT_FLOW} from '../../ducks/ui'; + + +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", () => { + expect(reducer({activeMenu: 'Flow'}, + { type: SELECT_FLOW, + currentSelection: '1', + flowId : undefined + })).toEqual({ activeMenu: 'Start'}) + }), + it("should change the state to Flow", () => { + expect(reducer({activeMenu: 'Start'}, + { type: SELECT_FLOW, + currentSelection: undefined, + flowId : '1' + })).toEqual({ activeMenu: 'Flow'}) + }), + it("should not change the state", () => { + expect(reducer({activeMenu: 'Options'}, + { type: SELECT_FLOW, + currentSelection: '1', + flowId : '2' + })).toEqual({ activeMenu: 'Options'}) + }) +}); -- cgit v1.2.3 From 65955ee45f4b5e66fd433924811f6753e996bea6 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 20 Jun 2016 21:01:24 -0700 Subject: add better description --- web/src/js/__tests__/ducks/ui.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'web/src/js/__tests__/ducks/ui.js') diff --git a/web/src/js/__tests__/ducks/ui.js b/web/src/js/__tests__/ducks/ui.js index ee1a008d..81ae852c 100644 --- a/web/src/js/__tests__/ducks/ui.js +++ b/web/src/js/__tests__/ducks/ui.js @@ -1,7 +1,8 @@ jest.unmock("../../ducks/ui"); +jest.unmock("../../ducks/flows"); -import reducer, {setActiveMenu, SELECT_FLOW} from '../../ducks/ui'; - +import reducer, {setActiveMenu} from '../../ducks/ui'; +import {SELECT_FLOW} from '../../ducks/flows'; describe("ui reducer", () => { it("should return the initial state", () => { @@ -10,21 +11,21 @@ describe("ui reducer", () => { it("should return the state for view", () => { expect(reducer(undefined, setActiveMenu('View'))).toEqual({ activeMenu: 'View'}) }), - it("should change the state to Start", () => { + 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_FLOW, currentSelection: '1', flowId : undefined })).toEqual({ activeMenu: 'Start'}) }), - it("should change the state to Flow", () => { + it("should change the state to Flow when we selected a flow and no flow was selected before", () => { expect(reducer({activeMenu: 'Start'}, { type: SELECT_FLOW, currentSelection: undefined, flowId : '1' })).toEqual({ activeMenu: 'Flow'}) }), - it("should not change the state", () => { + 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_FLOW, currentSelection: '1', -- cgit v1.2.3