aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/__tests__
diff options
context:
space:
mode:
authorJason <jason.daurus@gmail.com>2016-06-22 00:49:21 +0800
committerJason <jason.daurus@gmail.com>2016-06-22 00:49:21 +0800
commit0cab9ef1fae927f9ef365526262bef32bd1b526b (patch)
treee3d64264e0239f21e71b1c2132443001fdadd363 /web/src/js/__tests__
parent9cb5b0af9db83d84af0bdb45d56a9755b400c212 (diff)
parent4576dbf8aac8996f7f87320aba3132b657b02278 (diff)
downloadmitmproxy-0cab9ef1fae927f9ef365526262bef32bd1b526b.tar.gz
mitmproxy-0cab9ef1fae927f9ef365526262bef32bd1b526b.tar.bz2
mitmproxy-0cab9ef1fae927f9ef365526262bef32bd1b526b.zip
Merge remote-tracking branch 'origin/master' into websocket
Conflicts: mitmproxy/web/static/app.js web/src/js/components/ProxyApp.jsx
Diffstat (limited to 'web/src/js/__tests__')
-rw-r--r--web/src/js/__tests__/ducks/ui.js35
-rw-r--r--web/src/js/__tests__/utils.js8
2 files changed, 39 insertions, 4 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..81ae852c
--- /dev/null
+++ b/web/src/js/__tests__/ducks/ui.js
@@ -0,0 +1,35 @@
+jest.unmock("../../ducks/ui");
+jest.unmock("../../ducks/flows");
+
+import reducer, {setActiveMenu} from '../../ducks/ui';
+import {SELECT_FLOW} 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_FLOW,
+ 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_FLOW,
+ 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_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");