Skip to content

Commit

Permalink
[web] adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mhils committed Oct 26, 2017
1 parent c2401e3 commit 9d51433
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 180 deletions.
2 changes: 1 addition & 1 deletion web/src/js/__tests__/components/FlowTableSpec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import renderer from 'react-test-renderer'
import FlowTable from '../../components/FlowTable'
import {PureFlowTable as FlowTable} from '../../components/FlowTable'
import TestUtils from 'react-dom/test-utils'
import { TFlow, TStore } from '../ducks/tutils'
import { Provider } from 'react-redux'
Expand Down
6 changes: 0 additions & 6 deletions web/src/js/__tests__/components/Header/FileMenuSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,4 @@ describe('FileMenu Component', () => {
a.props.onClick(mockEvent)
expect(saveFn).toBeCalled()
})

it('should open optionModal', () => {
let a = ul.children[3].children[1]
a.props.onClick(mockEvent)
expect(openModalFn).toBeCalled()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ exports[`FileMenu Component should render correctly 1`] = `
</li>
<li>
<a
href="#"
onClick={[Function]}
>
<i
className="fa fa-fw fa-cog"
/>
 Options
</a>
<hr
className="divider"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ exports[`FlowMenu Component should connect to state 1`] = `
<div
className="btn btn-default"
disabled={true}
onClick={false}
onClick={undefined}
title="revert changes to flow [V]"
>
<i
Expand Down Expand Up @@ -92,7 +92,7 @@ exports[`FlowMenu Component should connect to state 1`] = `
<div
className="btn btn-default"
disabled={true}
onClick={false}
onClick={undefined}
title="[a]ccept intercepted flow"
>
<i
Expand All @@ -103,7 +103,7 @@ exports[`FlowMenu Component should connect to state 1`] = `
<div
className="btn btn-default"
disabled={true}
onClick={false}
onClick={undefined}
title="kill intercepted flow [x]"
>
<i
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,24 @@ exports[`OptionMenu Component should render correctly 1`] = `
className="menu-content"
>
<div
className="menu-entry"
>
<label>
<input
checked={false}
onChange={[Function]}
type="checkbox"
/>
HTTP/2.0
</label>
</div>
<div
className="menu-entry"
>
<label>
<input
checked={false}
onChange={[Function]}
type="checkbox"
/>
WebSockets
</label>
</div>
<div
className="menu-entry"
className="btn btn-default"
disabled={undefined}
onClick={[Function]}
title="Open Options"
>
<label>
<input
checked={false}
onChange={[Function]}
type="checkbox"
/>
Raw TCP
</label>
<i
className="fa fa-fw fa-cogs text-primary"
/>
Edit Options
<sup>
alpha
</sup>
</div>
</div>
<div
className="menu-legend"
>
Protocol Support
Options Editor
</div>
</div>
<div
Expand All @@ -66,7 +44,7 @@ exports[`OptionMenu Component should render correctly 1`] = `
onChange={[Function]}
type="checkbox"
/>
Disable Caching
Strip cache headers
<a
href="http://docs.mitmproxy.org/en/stable/features/anticache.html"
target="_blank"
Expand All @@ -86,18 +64,26 @@ exports[`OptionMenu Component should render correctly 1`] = `
onChange={[Function]}
type="checkbox"
/>
Disable Compression
<i
className="fa fa-question-circle"
title="Do not forward Accept-Encoding headers to the server to force an uncompressed response."
Use host header for display
</label>
</div>
<div
className="menu-entry"
>
<label>
<input
checked={false}
onChange={[Function]}
type="checkbox"
/>
Verify server certificates
</label>
</div>
</div>
<div
className="menu-legend"
>
HTTP Options
Quick Options
</div>
</div>
<div
Expand All @@ -106,22 +92,6 @@ exports[`OptionMenu Component should render correctly 1`] = `
<div
className="menu-content"
>
<div
className="menu-entry"
>
<label>
<input
checked={false}
onChange={[Function]}
type="checkbox"
/>
Use Host Header
<i
className="fa fa-question-circle"
title="Use the Host header to construct URLs for display."
/>
</label>
</div>
<div
className="menu-entry"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Button Component should be able to be disabled 1`] = `
<div
className="classname btn btn-default"
disabled="true"
onClick={false}
onClick={undefined}
title={undefined}
>
<a>
Expand Down
4 changes: 3 additions & 1 deletion web/src/js/__tests__/ducks/flowsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ describe('flows actions', () => {
file = new window.Blob(['foo'], { type: 'plain/text' })
body.append('file', file)
store.dispatch(flowActions.uploadContent(tflow, 'foo', 'foo'))
expect(fetchApi).toBeCalledWith('/flows/1/foo/content', { method: 'POST', body})
// window.Blob's lastModified is always the current time,
// which causes flaky tests on comparison.
expect(fetchApi).toBeCalledWith('/flows/1/foo/content', { method: 'POST', body: expect.anything()})
})

it('should handle clear action', () => {
Expand Down
5 changes: 0 additions & 5 deletions web/src/js/__tests__/utilsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ describe('pure', () => {
expect(utils.pure(tFunc).displayName).toEqual('tFunc')
})

it('should suggest when should component update', () => {
expect(f.shouldComponentUpdate('foo')).toBeTruthy()
expect(f.shouldComponentUpdate('bar')).toBeFalsy()
})

it('should render properties', () => {
expect(f.render()).toEqual(tFunc('bar'))
})
Expand Down
4 changes: 2 additions & 2 deletions web/src/js/components/FlowTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class FlowTable extends React.Component {
}
}

FlowTable = AutoScroll(FlowTable)
export const PureFlowTable = AutoScroll(FlowTable)

export default connect(
state => ({
Expand All @@ -132,4 +132,4 @@ export default connect(
{
selectFlow: flowsActions.select,
}
)(FlowTable)
)(PureFlowTable)
Loading

0 comments on commit 9d51433

Please sign in to comment.