diff options
author | Matthew Shao <me@matshao.com> | 2017-06-05 10:19:09 +0800 |
---|---|---|
committer | Matthew Shao <me@matshao.com> | 2017-06-05 10:19:09 +0800 |
commit | 298ac8391e86999c00804b2ed891ab8b7d4a6e39 (patch) | |
tree | e49cecf6c7f1dcb46cba9934b6edece94cdd71ba | |
parent | 46eae0a0b65e4064cd06658baf69957d37b503fe (diff) | |
download | mitmproxy-298ac8391e86999c00804b2ed891ab8b7d4a6e39.tar.gz mitmproxy-298ac8391e86999c00804b2ed891ab8b7d4a6e39.tar.bz2 mitmproxy-298ac8391e86999c00804b2ed891ab8b7d4a6e39.zip |
[web] Add tests for js/components/ContentView/MetaViews.jsx
-rw-r--r-- | web/src/js/__tests__/components/ContentView/MetaViewsSpec.js | 37 | ||||
-rw-r--r-- | web/src/js/__tests__/components/ContentView/__snapshots__/MetaViewsSpec.js.snap | 66 |
2 files changed, 103 insertions, 0 deletions
diff --git a/web/src/js/__tests__/components/ContentView/MetaViewsSpec.js b/web/src/js/__tests__/components/ContentView/MetaViewsSpec.js new file mode 100644 index 00000000..8867ccbe --- /dev/null +++ b/web/src/js/__tests__/components/ContentView/MetaViewsSpec.js @@ -0,0 +1,37 @@ +import React from 'react' +import renderer from 'react-test-renderer' +import { ContentEmpty, ContentMissing, ContentTooLarge } from '../../../components/ContentView/MetaViews' +import { TFlow } from '../../ducks/tutils' + +let tflow = new TFlow() + +describe('ContentEmpty Components', () => { + it('should render correctly', () => { + let contentEmpty = renderer.create(<ContentEmpty flow={tflow} message={tflow.response}/>), + tree = contentEmpty.toJSON() + expect(tree).toMatchSnapshot() + }) +}) + +describe('ContentMissing Components', () => { + it('should render correctly', () => { + let contentMissing = renderer.create(<ContentMissing flow={tflow} message={tflow.response}/>), + tree = contentMissing.toJSON() + expect(tree).toMatchSnapshot() + }) +}) + +describe('ContentTooLarge Components', () => { + it('should render correctly', () => { + let clickFn = jest.fn(), + uploadContentFn = jest.fn(), + contentTooLarge = renderer.create(<ContentTooLarge + flow={tflow} + message={tflow.response} + onClick={clickFn} + uploadContent={uploadContentFn} + />), + tree = contentTooLarge.toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/web/src/js/__tests__/components/ContentView/__snapshots__/MetaViewsSpec.js.snap b/web/src/js/__tests__/components/ContentView/__snapshots__/MetaViewsSpec.js.snap new file mode 100644 index 00000000..18ec5bba --- /dev/null +++ b/web/src/js/__tests__/components/ContentView/__snapshots__/MetaViewsSpec.js.snap @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ContentEmpty Components should render correctly 1`] = ` +<div + className="alert alert-info" +> + No + response + content. +</div> +`; + +exports[`ContentMissing Components should render correctly 1`] = ` +<div + className="alert alert-info" +> + Response + content missing. +</div> +`; + +exports[`ContentTooLarge Components should render correctly 1`] = ` +<div> + <div + className="alert alert-warning" + > + <button + className="btn btn-xs btn-warning pull-right" + onClick={[Function]} + > + Display anyway + </button> + 7b + content size. + </div> + <div + className="view-options text-center" + > + <a + className="btn btn-default btn-xs" + href="#" + onClick={[Function]} + title="Upload a file to replace the content." + > + <i + className="fa fa-fw fa-upload" + /> + <input + className="hidden" + onChange={[Function]} + type="file" + /> + </a> + + <a + className="btn btn-default btn-xs" + href="/flows/d91165be-ca1f-4612-88a9-c0f8696f3e29/response/content" + title="Download the content of the flow." + > + <i + className="fa fa-download" + /> + </a> + </div> +</div> +`; |