diff options
author | Clemens <cle1000.cb@gmail.com> | 2016-08-09 19:49:36 +0200 |
---|---|---|
committer | Clemens <cle1000.cb@gmail.com> | 2016-08-09 19:49:36 +0200 |
commit | b27e456ce2150d638b4eef73703da8a30722d392 (patch) | |
tree | 2ba82b15f1bdf22f12b7d97e726dcbd19374e9cf /web/src/js/__tests__/ducks/flowViewSpec.js | |
parent | 78bd99f97c36ba24bbab389350eb8e80ba16738f (diff) | |
parent | dcfa7027aed5a8d4aa80aff67fc299298659fb1b (diff) | |
download | mitmproxy-b27e456ce2150d638b4eef73703da8a30722d392.tar.gz mitmproxy-b27e456ce2150d638b4eef73703da8a30722d392.tar.bz2 mitmproxy-b27e456ce2150d638b4eef73703da8a30722d392.zip |
merge with master
Diffstat (limited to 'web/src/js/__tests__/ducks/flowViewSpec.js')
-rw-r--r-- | web/src/js/__tests__/ducks/flowViewSpec.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/web/src/js/__tests__/ducks/flowViewSpec.js b/web/src/js/__tests__/ducks/flowViewSpec.js new file mode 100644 index 00000000..d5d9a6d9 --- /dev/null +++ b/web/src/js/__tests__/ducks/flowViewSpec.js @@ -0,0 +1,67 @@ +jest.unmock('../../ducks/flows') +jest.unmock('../../ducks/flowView') +jest.unmock('../../ducks/utils/view') +jest.unmock('../../ducks/utils/list') +jest.unmock('./tutils') + +import { createStore } from './tutils' + +import flows, * as flowActions from '../../ducks/flows' +import flowView, * as flowViewActions from '../../ducks/flowView' + + +function testStore() { + let store = createStore({ + flows, + flowView + }) + for (let i of [1, 2, 3, 4]) { + store.dispatch( + flowActions.addFlow({ id: i }) + ) + } + return store +} + +describe('select relative', () => { + + function testSelect(start, relative, result) { + const store = testStore() + store.dispatch(flowActions.select(start)) + expect(store.getState().flows.selected).toEqual(start ? [start] : []) + store.dispatch(flowViewActions.selectRelative(relative)) + expect(store.getState().flows.selected).toEqual([result]) + } + + describe('previous', () => { + + it('should select the previous flow', () => { + testSelect(3, -1, 2) + }) + + it('should not changed when first flow is selected', () => { + testSelect(1, -1, 1) + }) + + it('should select first flow if no flow is selected', () => { + testSelect(undefined, -1, 1) + }) + + }) + + describe('next', () => { + + it('should select the next flow', () => { + testSelect(2, 1, 3) + }) + + it('should not changed when last flow is selected', () => { + testSelect(4, 1, 4) + }) + + it('should select last flow if no flow is selected', () => { + testSelect(undefined, 1, 4) + }) + + }) +}) |