diff options
author | Clemens <cle1000.cb@gmail.com> | 2016-06-16 13:25:58 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-06-20 21:00:27 -0700 |
commit | 37475217bf05fa44eba1551d318e6a5f6d088d7a (patch) | |
tree | a23e1ee2e98461b7fbf2755337626b6e2220f243 /web/src | |
parent | 44abb4caea145a39b441d6af0d79fb07b672af1d (diff) | |
download | mitmproxy-37475217bf05fa44eba1551d318e6a5f6d088d7a.tar.gz mitmproxy-37475217bf05fa44eba1551d318e6a5f6d088d7a.tar.bz2 mitmproxy-37475217bf05fa44eba1551d318e6a5f6d088d7a.zip |
added tests for ui
Diffstat (limited to 'web/src')
-rw-r--r-- | web/src/js/__tests__/ducks/ui.js | 34 | ||||
-rw-r--r-- | web/src/js/__tests__/utils.js | 8 | ||||
-rw-r--r-- | web/src/js/ducks/ui.js | 4 |
3 files changed, 40 insertions, 6 deletions
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'}) + }) +}); diff --git a/web/src/js/__tests__/utils.js b/web/src/js/__tests__/utils.js index eda740a1..b216d7d4 100644 --- a/web/src/js/__tests__/utils.js +++ b/web/src/js/__tests__/utils.js @@ -1,9 +1,9 @@ -jest.unmock("../utils.js"); +jest.unmock("../utils"); -import {formatSize} from "../utils.js" +import {formatSize} from "../utils" -describe("utils", function () { - it("formatSize", function(){ +describe("utils", () => { + it("formatSize", () => { expect(formatSize(1024)).toEqual("1kb"); expect(formatSize(0)).toEqual("0"); expect(formatSize(10)).toEqual("10b"); diff --git a/web/src/js/ducks/ui.js b/web/src/js/ducks/ui.js index 28a13ea4..00468902 100644 --- a/web/src/js/ducks/ui.js +++ b/web/src/js/ducks/ui.js @@ -1,5 +1,5 @@ -import { SELECT_FLOW } from './flows' -const SET_ACTIVE_MENU = 'SET_ACTIVE_MENU' +export const SELECT_FLOW = "SELECT_FLOW" +export const SET_ACTIVE_MENU = 'SET_ACTIVE_MENU' const defaultState = { |