diff options
author | Jason <jason.daurus@gmail.com> | 2016-07-26 02:09:54 +0800 |
---|---|---|
committer | Jason <jason.daurus@gmail.com> | 2016-07-26 02:09:54 +0800 |
commit | 7b51f12813ab145304c15f0d39222a2811e6ca4d (patch) | |
tree | 6f0dbbe7f6e75fb9accad70278cc6d7b283681f6 /web/src/js/__tests__/ducks/ui | |
parent | 3a3305b9acbb3ac3ac82f9b29c099699b5210fa5 (diff) | |
download | mitmproxy-7b51f12813ab145304c15f0d39222a2811e6ca4d.tar.gz mitmproxy-7b51f12813ab145304c15f0d39222a2811e6ca4d.tar.bz2 mitmproxy-7b51f12813ab145304c15f0d39222a2811e6ca4d.zip |
[web] bug fix and add test
Diffstat (limited to 'web/src/js/__tests__/ducks/ui')
-rw-r--r-- | web/src/js/__tests__/ducks/ui/header.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/web/src/js/__tests__/ducks/ui/header.js b/web/src/js/__tests__/ducks/ui/header.js new file mode 100644 index 00000000..8968e636 --- /dev/null +++ b/web/src/js/__tests__/ducks/ui/header.js @@ -0,0 +1,36 @@ +jest.unmock('../../../ducks/ui/header') +jest.unmock('../../../ducks/flows') + +import reducer, { setActiveMenu } from '../../../ducks/ui/header' +import * as flowActions from '../../../ducks/flows' + +describe('header 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') + }) +}) |