diff options
author | Matthew Shao <me@matshao.com> | 2017-05-19 09:49:10 +0800 |
---|---|---|
committer | Matthew Shao <me@matshao.com> | 2017-05-19 09:50:12 +0800 |
commit | 5df0ddf358367dcd37c934798464ad91f3c7bdf8 (patch) | |
tree | ac634d40e24f489d87b6b5a4b59e53bd1809ff97 /web | |
parent | 50c07034249a07f25172230b689c4c6da1b63c2d (diff) | |
download | mitmproxy-5df0ddf358367dcd37c934798464ad91f3c7bdf8.tar.gz mitmproxy-5df0ddf358367dcd37c934798464ad91f3c7bdf8.tar.bz2 mitmproxy-5df0ddf358367dcd37c934798464ad91f3c7bdf8.zip |
[web] Updates test to use the new _tflow.js.
Diffstat (limited to 'web')
3 files changed, 30 insertions, 63 deletions
diff --git a/web/src/js/__tests__/components/FlowTable/FlowColumnsSpec.js b/web/src/js/__tests__/components/FlowTable/FlowColumnsSpec.js index 576838f4..7f30b809 100644 --- a/web/src/js/__tests__/components/FlowTable/FlowColumnsSpec.js +++ b/web/src/js/__tests__/components/FlowTable/FlowColumnsSpec.js @@ -1,101 +1,101 @@ import React from 'react' import renderer from 'react-test-renderer' import * as Columns from '../../../components/FlowTable/FlowColumns' -import { TFlow } from '../../ducks/tutils' +import _tflow from '../../ducks/_tflow' describe('FlowColumns Components', () => { - let tFlow = new TFlow() + let tflow = _tflow() it('should render TLSColumn', () => { - let tlsColumn = renderer.create(<Columns.TLSColumn flow={tFlow}/>), + let tlsColumn = renderer.create(<Columns.TLSColumn flow={tflow}/>), tree = tlsColumn.toJSON() expect(tree).toMatchSnapshot() }) it('should render IconColumn', () => { - let iconColumn = renderer.create(<Columns.IconColumn flow={tFlow}/>), + let iconColumn = renderer.create(<Columns.IconColumn flow={tflow}/>), tree = iconColumn.toJSON() // plain expect(tree).toMatchSnapshot() // not modified - tFlow.response.status_code = 304 - iconColumn = renderer.create(<Columns.IconColumn flow={tFlow}/>) + tflow.response.status_code = 304 + iconColumn = renderer.create(<Columns.IconColumn flow={tflow}/>) tree = iconColumn.toJSON() expect(tree).toMatchSnapshot() // redirect - tFlow.response.status_code = 302 - iconColumn = renderer.create(<Columns.IconColumn flow={tFlow}/>) + tflow.response.status_code = 302 + iconColumn = renderer.create(<Columns.IconColumn flow={tflow}/>) tree = iconColumn.toJSON() expect(tree).toMatchSnapshot() // image - let imageFlow = new TFlow() + let imageFlow = _tflow() imageFlow.response.headers = [['Content-Type', 'image/jpeg']] iconColumn = renderer.create(<Columns.IconColumn flow={imageFlow}/>) tree = iconColumn.toJSON() expect(tree).toMatchSnapshot() // javascript - let jsFlow = new TFlow() + let jsFlow = _tflow() jsFlow.response.headers = [['Content-Type', 'application/x-javascript']] iconColumn = renderer.create(<Columns.IconColumn flow={jsFlow}/>) tree = iconColumn.toJSON() expect(tree).toMatchSnapshot() // css - let cssFlow = new TFlow() + let cssFlow = _tflow() cssFlow.response.headers = [['Content-Type', 'text/css']] iconColumn = renderer.create(<Columns.IconColumn flow={cssFlow}/>) tree = iconColumn.toJSON() expect(tree).toMatchSnapshot() // default - let fooFlow = new TFlow() + let fooFlow = _tflow() fooFlow.response.headers = [['Content-Type', 'foo']] iconColumn = renderer.create(<Columns.IconColumn flow={fooFlow}/>) tree = iconColumn.toJSON() expect(tree).toMatchSnapshot() // no response - tFlow.response = null - iconColumn = renderer.create(<Columns.IconColumn flow={tFlow}/>) + tflow.response = null + iconColumn = renderer.create(<Columns.IconColumn flow={tflow}/>) tree = iconColumn.toJSON() expect(tree).toMatchSnapshot() }) it('should render pathColumn', () => { - let pathColumn = renderer.create(<Columns.PathColumn flow={tFlow}/>), + let pathColumn = renderer.create(<Columns.PathColumn flow={tflow}/>), tree = pathColumn.toJSON() expect(tree).toMatchSnapshot() - tFlow.error.msg = 'Connection killed' - tFlow.intercepted = true - pathColumn = renderer.create(<Columns.PathColumn flow={tFlow}/>) + tflow.error.msg = 'Connection killed' + tflow.intercepted = true + pathColumn = renderer.create(<Columns.PathColumn flow={tflow}/>) tree = pathColumn.toJSON() expect(tree).toMatchSnapshot() }) it('should render MethodColumn', () => { - let methodColumn =renderer.create(<Columns.MethodColumn flow={tFlow}/>), + let methodColumn =renderer.create(<Columns.MethodColumn flow={tflow}/>), tree = methodColumn.toJSON() expect(tree).toMatchSnapshot() }) it('should render StatusColumn', () => { - let statusColumn = renderer.create(<Columns.StatusColumn flow={tFlow}/>), + let statusColumn = renderer.create(<Columns.StatusColumn flow={tflow}/>), tree = statusColumn.toJSON() expect(tree).toMatchSnapshot() }) it('should render SizeColumn', () => { - tFlow = new TFlow() - let sizeColumn = renderer.create(<Columns.SizeColumn flow={tFlow}/>), + tflow = _tflow() + let sizeColumn = renderer.create(<Columns.SizeColumn flow={tflow}/>), tree = sizeColumn.toJSON() expect(tree).toMatchSnapshot() }) it('should render TimeColumn', () => { - let timeColumn = renderer.create(<Columns.TimeColumn flow={tFlow}/>), + let timeColumn = renderer.create(<Columns.TimeColumn flow={tflow}/>), tree = timeColumn.toJSON() expect(tree).toMatchSnapshot() - tFlow.response = null - timeColumn = renderer.create(<Columns.TimeColumn flow={tFlow}/>), + tflow.response = null + timeColumn = renderer.create(<Columns.TimeColumn flow={tflow}/>), tree = timeColumn.toJSON() expect(tree).toMatchSnapshot() }) diff --git a/web/src/js/__tests__/components/FlowTable/__snapshots__/FlowColumnsSpec.js.snap b/web/src/js/__tests__/components/FlowTable/__snapshots__/FlowColumnsSpec.js.snap index ec260e1e..c74f686e 100644 --- a/web/src/js/__tests__/components/FlowTable/__snapshots__/FlowColumnsSpec.js.snap +++ b/web/src/js/__tests__/components/FlowTable/__snapshots__/FlowColumnsSpec.js.snap @@ -5,7 +5,7 @@ exports[`FlowColumns Components should render IconColumn 1`] = ` className="col-icon" > <div - className="resource-icon resource-icon-document" + className="resource-icon resource-icon-plain" /> </td> `; @@ -92,7 +92,7 @@ exports[`FlowColumns Components should render SizeColumn 1`] = ` <td className="col-size" > - 100b + 14b </td> `; @@ -112,7 +112,7 @@ exports[`FlowColumns Components should render TimeColumn 1`] = ` <td className="col-time" > - 2min + 415322h </td> `; @@ -129,12 +129,9 @@ exports[`FlowColumns Components should render pathColumn 1`] = ` className="col-path" > <i - className="fa fa-fw fa-repeat pull-right" - /> - <i className="fa fa-fw fa-exclamation pull-right" /> - http://undefined:undefinedundefined + http://address:22/path </td> `; @@ -143,14 +140,11 @@ exports[`FlowColumns Components should render pathColumn 2`] = ` className="col-path" > <i - className="fa fa-fw fa-repeat pull-right" - /> - <i className="fa fa-fw fa-pause pull-right" /> <i className="fa fa-fw fa-times pull-right" /> - http://undefined:undefinedundefined + http://address:22/path </td> `; diff --git a/web/src/js/__tests__/ducks/tutils.js b/web/src/js/__tests__/ducks/tutils.js index f140222d..6ae7f080 100644 --- a/web/src/js/__tests__/ducks/tutils.js +++ b/web/src/js/__tests__/ducks/tutils.js @@ -7,30 +7,3 @@ export function createStore(parts) { applyMiddleware(...[thunk]) ) } - -export function TFlow(intercepted=false, marked=false, modified=false) { - return { - intercepted , - marked, - modified, - id: "foo", - request: { - scheme: 'http', - is_replay: true, - method: 'GET', - contentLength: 100 - }, - response: { - status_code: 200, - headers: [["Content-Type", 'text/html']], - timestamp_end: 200 - }, - error: { - msg: '' - }, - server_conn: { - timestamp_start: 100 - }, - type: 'http' - } -} |