aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/__tests__/ducks
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-05-09 19:10:48 +0200
committerMaximilian Hils <git@maximilianhils.com>2017-05-09 19:10:48 +0200
commit457bc36d7f83ef2fa5f461517df482d12f613797 (patch)
tree8816bcbbe6b6640e2c903e4f3294b6d296df8a61 /web/src/js/__tests__/ducks
parentfd24e15bfb90519f18ee29474fd174e5db2ec2ed (diff)
downloadmitmproxy-457bc36d7f83ef2fa5f461517df482d12f613797.tar.gz
mitmproxy-457bc36d7f83ef2fa5f461517df482d12f613797.tar.bz2
mitmproxy-457bc36d7f83ef2fa5f461517df482d12f613797.zip
web: clear mock store actions after each test
Diffstat (limited to 'web/src/js/__tests__/ducks')
-rw-r--r--web/src/js/__tests__/ducks/ui/keyboardSpec.js34
1 files changed, 21 insertions, 13 deletions
diff --git a/web/src/js/__tests__/ducks/ui/keyboardSpec.js b/web/src/js/__tests__/ducks/ui/keyboardSpec.js
index 12619774..500733cb 100644
--- a/web/src/js/__tests__/ducks/ui/keyboardSpec.js
+++ b/web/src/js/__tests__/ducks/ui/keyboardSpec.js
@@ -23,65 +23,74 @@ describe('onKeyDown', () => {
return onKeyDown({ keyCode, shiftKey, ctrlKey, preventDefault: jest.fn() })
}
+ afterEach(() => {
+ store.clearActions()
+ fetchApi.mockClear()
+ });
+
it('should handle cursor up', () => {
store.getState().flows = reduceFlows(flows, flowsActions.select(2))
store.dispatch(createKeyEvent(Key.K))
expect(store.getActions()).toEqual([{ flowIds: [1], type: flowsActions.SELECT }])
+ store.clearActions()
store.dispatch(createKeyEvent(Key.UP))
- expect(store.getActions().pop()).toEqual({ flowIds: [1], type: flowsActions.SELECT })
+ expect(store.getActions()).toEqual([{ flowIds: [1], type: flowsActions.SELECT }])
})
it('should handle cursor down', () => {
store.dispatch(createKeyEvent(Key.J))
- expect(store.getActions().pop()).toEqual({ flowIds: [3], type: flowsActions.SELECT })
+ expect(store.getActions()).toEqual([{ flowIds: [3], type: flowsActions.SELECT }])
+ store.clearActions()
store.dispatch(createKeyEvent(Key.DOWN))
- expect(store.getActions().pop()).toEqual({ flowIds: [3], type: flowsActions.SELECT })
+ expect(store.getActions()).toEqual([{ flowIds: [3], type: flowsActions.SELECT }])
})
it('should handle page down', () => {
store.dispatch(createKeyEvent(Key.SPACE))
- expect(store.getActions().pop()).toEqual({ flowIds: [12], type: flowsActions.SELECT })
+ expect(store.getActions()).toEqual([{ flowIds: [12], type: flowsActions.SELECT }])
store.getState().flows = reduceFlows(flows, flowsActions.select(1))
+ store.clearActions()
store.dispatch(createKeyEvent(Key.PAGE_DOWN))
- expect(store.getActions().pop()).toEqual({ flowIds: [11], type: flowsActions.SELECT })
+ expect(store.getActions()).toEqual([{ flowIds: [11], type: flowsActions.SELECT }])
})
it('should handle page up', () => {
store.getState().flows = reduceFlows(flows, flowsActions.select(11))
store.dispatch(createKeyEvent(Key.PAGE_UP))
- expect(store.getActions().pop()).toEqual({ flowIds: [1], type: flowsActions.SELECT })
+ expect(store.getActions()).toEqual([{ flowIds: [1], type: flowsActions.SELECT }])
})
it('should handle select first', () => {
store.dispatch(createKeyEvent(Key.HOME))
- expect(store.getActions().pop()).toEqual({ flowIds: [1], type: flowsActions.SELECT })
+ expect(store.getActions()).toEqual([{ flowIds: [1], type: flowsActions.SELECT }])
})
it('should handle select last', () => {
store.getState().flows = reduceFlows(flows, flowsActions.select(1))
store.dispatch(createKeyEvent(Key.END))
- expect(store.getActions().pop()).toEqual({ flowIds: [12], type: flowsActions.SELECT })
+ expect(store.getActions()).toEqual([{ flowIds: [12], type: flowsActions.SELECT }])
})
it('should handle deselect', () => {
store.dispatch(createKeyEvent(Key.ESC))
- expect(store.getActions().pop()).toEqual({ flowIds: [], type: flowsActions.SELECT })
+ expect(store.getActions()).toEqual([{ flowIds: [], type: flowsActions.SELECT }])
})
it('should handle switch to left tab', () => {
store.dispatch(createKeyEvent(Key.LEFT))
- expect(store.getActions().pop()).toEqual({ tab: 'details', type: UIActions.SET_TAB })
+ expect(store.getActions()).toEqual([{ tab: 'details', type: UIActions.SET_TAB }])
})
it('should handle switch to right tab', () => {
store.dispatch(createKeyEvent(Key.TAB))
- expect(store.getActions().pop()).toEqual({ tab: 'response', type: UIActions.SET_TAB })
+ expect(store.getActions()).toEqual([{ tab: 'response', type: UIActions.SET_TAB }])
+ store.clearActions()
store.dispatch(createKeyEvent(Key.RIGHT))
- expect(store.getActions().pop()).toEqual({ tab: 'response', type: UIActions.SET_TAB })
+ expect(store.getActions()).toEqual([{ tab: 'response', type: UIActions.SET_TAB }])
})
it('should handle delete action', () => {
@@ -131,7 +140,6 @@ describe('onKeyDown', () => {
})
it('should stop on some action with no flow is selected', () => {
- fetchApi.mockClear()
store.getState().flows = reduceFlows(undefined, {})
store.dispatch(createKeyEvent(Key.LEFT))
store.dispatch(createKeyEvent(Key.TAB))