diff options
author | Maximilian Hils <git@maximilianhils.com> | 2017-03-11 14:48:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-11 14:48:25 +0100 |
commit | d069ba9da58beb65d8139c728cc20abcb01de3a4 (patch) | |
tree | c77a0439f683cf4b40f718b453b81b72b14ae215 /web/src/js | |
parent | 39154e628e8db58db01b5d8f2fd4080736d79bb6 (diff) | |
parent | abcfac3c194b42ccadd9cee8fbf82f3bb7151bed (diff) | |
download | mitmproxy-d069ba9da58beb65d8139c728cc20abcb01de3a4.tar.gz mitmproxy-d069ba9da58beb65d8139c728cc20abcb01de3a4.tar.bz2 mitmproxy-d069ba9da58beb65d8139c728cc20abcb01de3a4.zip |
Merge pull request #2133 from MatthewShao/jest-dev
[web] Fixes all existed tests
Diffstat (limited to 'web/src/js')
-rw-r--r-- | web/src/js/__tests__/ducks/flowsSpec.js | 3 | ||||
-rw-r--r-- | web/src/js/__tests__/ducks/ui/flowSpec.js | 9 | ||||
-rw-r--r-- | web/src/js/ducks/ui/flow.js | 7 |
3 files changed, 11 insertions, 8 deletions
diff --git a/web/src/js/__tests__/ducks/flowsSpec.js b/web/src/js/__tests__/ducks/flowsSpec.js index 2b261cb1..acfa3083 100644 --- a/web/src/js/__tests__/ducks/flowsSpec.js +++ b/web/src/js/__tests__/ducks/flowsSpec.js @@ -1,13 +1,14 @@ jest.unmock('../../ducks/flows'); import reduceFlows, * as flowActions from '../../ducks/flows' +import * as storeActions from '../../ducks/utils/store' describe('select flow', () => { let state = reduceFlows(undefined, {}) for (let i of [1, 2, 3, 4]) { - state = reduceFlows(state, flowActions.addFlow({ id: i })) + state = reduceFlows(state, storeActions.add({ id: i })) } it('should be possible to select a single flow', () => { diff --git a/web/src/js/__tests__/ducks/ui/flowSpec.js b/web/src/js/__tests__/ducks/ui/flowSpec.js index f838fbaa..91b56746 100644 --- a/web/src/js/__tests__/ducks/ui/flowSpec.js +++ b/web/src/js/__tests__/ducks/ui/flowSpec.js @@ -8,7 +8,8 @@ import reducer, { setContentViewDescription, setShowFullContent, setContent, - updateEdit + updateEdit, + stopEdit } from '../../../ducks/ui/flow' import { select, updateFlow } from '../../../ducks/flows' @@ -65,12 +66,12 @@ describe('flow reducer', () => { it('should not change the state when a flow is updated which is not selected', () => { let modifiedFlow = {id: 1} let updatedFlow = {id: 0} - expect(reducer({modifiedFlow}, updateFlow(updatedFlow)).modifiedFlow).toEqual(modifiedFlow) + expect(reducer({modifiedFlow}, stopEdit(updatedFlow, modifiedFlow)).modifiedFlow).toEqual(modifiedFlow) }) - it('should stop editing when the selected flow is updated', () => { + it('should stop editing when the selected flow is updated', () => { let modifiedFlow = {id: 1} let updatedFlow = {id: 1} - expect(reducer({modifiedFlow}, updateFlow(updatedFlow)).modifiedFlow).toBeFalsy() + expect(reducer({modifiedFlow}, stopEdit(updatedFlow, modifiedFlow)).modifiedFlow).toBeFalsy() }) }) diff --git a/web/src/js/ducks/ui/flow.js b/web/src/js/ducks/ui/flow.js index fa7474d2..8cb6e170 100644 --- a/web/src/js/ducks/ui/flow.js +++ b/web/src/js/ducks/ui/flow.js @@ -60,7 +60,7 @@ export default function reducer(state = defaultState, action) { // There is no explicit "stop edit" event. // We stop editing when we receive an update for // the currently edited flow from the server - if (action.data.id === state.modifiedFlow.id) { + if (action.flow.id === state.modifiedFlow.id) { return { ...state, modifiedFlow: false, @@ -145,9 +145,10 @@ export function setShowFullContent() { } export function setContent(content){ - return { type: SET_CONTENT, content} + return { type: SET_CONTENT, content } } export function stopEdit(flow, modifiedFlow) { - return flowsActions.update(flow, getDiff(flow, modifiedFlow)) + let diff = getDiff(flow, modifiedFlow) + return {type: flowsActions.UPDATE, flow, diff } } |