aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/__tests__/ducks/views/main.js
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-07-19 03:13:39 -0700
committerMaximilian Hils <git@maximilianhils.com>2016-07-19 03:13:39 -0700
commitf356a84430f6606b2d7157eefd8e4a100fdd5dfb (patch)
tree038ccf7a15ce49d654e0b03ce73ba226d32c40f9 /web/src/js/__tests__/ducks/views/main.js
parent4ea6e61ea8ba57895451a9f76ec2c5e3c02829f3 (diff)
downloadmitmproxy-f356a84430f6606b2d7157eefd8e4a100fdd5dfb.tar.gz
mitmproxy-f356a84430f6606b2d7157eefd8e4a100fdd5dfb.tar.bz2
mitmproxy-f356a84430f6606b2d7157eefd8e4a100fdd5dfb.zip
simplify web ui ducks
Diffstat (limited to 'web/src/js/__tests__/ducks/views/main.js')
-rw-r--r--web/src/js/__tests__/ducks/views/main.js83
1 files changed, 0 insertions, 83 deletions
diff --git a/web/src/js/__tests__/ducks/views/main.js b/web/src/js/__tests__/ducks/views/main.js
deleted file mode 100644
index 0255f6ce..00000000
--- a/web/src/js/__tests__/ducks/views/main.js
+++ /dev/null
@@ -1,83 +0,0 @@
-jest.unmock('../../../ducks/views/main');
-jest.unmock('../../../ducks/utils/view');
-jest.unmock('redux-thunk')
-jest.unmock('redux')
-
-import reduce, { selectRelative } from '../../../ducks/views/main';
-import thunk from 'redux-thunk'
-import { applyMiddleware, createStore, combineReducers } from 'redux'
-
-describe('main reduce', () => {
-
- describe('select previous', () => {
-
- it('should not changed when first flow is selected', () => {
- const flows = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }]
- const store = createTestStore(makeState(flows, 1))
- store.dispatch(selectRelative(-1))
- expect(store.getState().flows.views.main.selected).toEqual([1])
- })
-
- it('should select last flow if no flow is selected', () => {
- const flows = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }]
- const store = createTestStore(makeState(flows))
- store.dispatch(selectRelative(-1))
- expect(store.getState().flows.views.main.selected).toEqual([4])
- })
-
- })
-
- describe('select next', () => {
-
- it('should not change when last flow is selected', () => {
- const flows = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }]
- const store = createTestStore(makeState(flows, 4))
- store.dispatch(selectRelative(1))
- expect(store.getState().flows.views.main.selected).toEqual([4])
- })
-
- it('should select first flow if no flow is selected', () => {
- const flows = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }]
- const store = createTestStore(makeState(flows, 1))
- store.dispatch(selectRelative(1))
- expect(store.getState().flows.views.main.selected).toEqual([2])
- })
-
- })
-})
-
-function createTestStore(defaultState) {
- return createStore(
- (state = defaultState, action) => ({
- flows: {
- ...state.flows,
- views: {
- main: reduce(state.flows.views.main, action)
- }
- }
- }),
- defaultState,
- applyMiddleware(thunk)
- )
-}
-
-// TODO: We should not duplicate our reducer logic here.
-function makeState(flows, selected) {
- const list = {
- data: flows,
- byId: _.fromPairs(flows.map(flow => [flow.id, flow])),
- indexOf: _.fromPairs(flows.map((flow, index) => [flow.id, index])),
- }
-
- return {
- flows: {
- list,
- views: {
- main: {
- selected: [selected],
- view: list,
- }
- }
- }
- }
-}