diff --git a/web/src/js/__tests__/components/FlowTable/FlowColumnsSpec.js b/web/src/js/__tests__/components/FlowTable/FlowColumnsSpec.js new file mode 100644 index 000000000..7606a683f --- /dev/null +++ b/web/src/js/__tests__/components/FlowTable/FlowColumnsSpec.js @@ -0,0 +1,103 @@ +import React from 'react' +import renderer from 'react-test-renderer' +import * as Columns from '../../../components/FlowTable/FlowColumns' +import { TFlow } from '../../ducks/tutils' + +describe('FlowColumns Components', () => { + + let tFlow = new TFlow() + it('should render TLSColumn', () => { + let tlsColumn = renderer.create(), + tree = tlsColumn.toJSON() + expect(tree).toMatchSnapshot() + }) + + it('should render IconColumn', () => { + let iconColumn = renderer.create(), + tree = iconColumn.toJSON() + // plain + expect(tree).toMatchSnapshot() + // not modified + tFlow.response.status_code = 304 + iconColumn = renderer.create() + tree = iconColumn.toJSON() + expect(tree).toMatchSnapshot() + // redirect + tFlow.response.status_code = 302 + iconColumn = renderer.create() + tree = iconColumn.toJSON() + expect(tree).toMatchSnapshot() + // image + let imageFlow = new TFlow() + imageFlow.response.headers = [['Content-Type', 'image/jpeg']] + iconColumn = renderer.create() + tree = iconColumn.toJSON() + expect(tree).toMatchSnapshot() + // javascript + let jsFlow = new TFlow() + jsFlow.response.headers = [['Content-Type', 'application/x-javascript']] + iconColumn = renderer.create() + tree = iconColumn.toJSON() + expect(tree).toMatchSnapshot() + // css + let cssFlow = new TFlow() + cssFlow.response.headers = [['Content-Type', 'text/css']] + iconColumn = renderer.create() + tree = iconColumn.toJSON() + expect(tree).toMatchSnapshot() + // default + let fooFlow = new TFlow() + fooFlow.response.headers = [['Content-Type', 'foo']] + iconColumn = renderer.create() + tree = iconColumn.toJSON() + expect(tree).toMatchSnapshot() + // no response + tFlow.response = null + iconColumn = renderer.create() + tree = iconColumn.toJSON() + expect(tree).toMatchSnapshot() + }) + + it('should render pathColumn', () => { + // error + let pathColumn = renderer.create(), + tree = pathColumn.toJSON() + expect(tree).toMatchSnapshot() + + tFlow.error.msg = 'Connection killed' + tFlow.intercepted = true + pathColumn = renderer.create() + tree = pathColumn.toJSON() + expect(tree).toMatchSnapshot() + }) + + it('should render MethodColumn', () => { + let methodColumn =renderer.create(), + tree = methodColumn.toJSON() + expect(tree).toMatchSnapshot() + }) + + it('should render StatusColumn', () => { + let statusColumn = renderer.create(), + tree = statusColumn.toJSON() + expect(tree).toMatchSnapshot() + }) + + it('should render SizeColumn', () => { + tFlow = new TFlow() + let sizeColumn = renderer.create(), + tree = sizeColumn.toJSON() + expect(tree).toMatchSnapshot() + }) + + it('should render TimeColumn', () => { + let timeColumn = renderer.create(), + tree = timeColumn.toJSON() + expect(tree).toMatchSnapshot() + + tFlow.response = null + timeColumn = renderer.create(), + 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 new file mode 100644 index 000000000..ec260e1e9 --- /dev/null +++ b/web/src/js/__tests__/components/FlowTable/__snapshots__/FlowColumnsSpec.js.snap @@ -0,0 +1,156 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`FlowColumns Components should render IconColumn 1`] = ` + +
+ +`; + +exports[`FlowColumns Components should render IconColumn 2`] = ` + +
+ +`; + +exports[`FlowColumns Components should render IconColumn 3`] = ` + +
+ +`; + +exports[`FlowColumns Components should render IconColumn 4`] = ` + +
+ +`; + +exports[`FlowColumns Components should render IconColumn 5`] = ` + +
+ +`; + +exports[`FlowColumns Components should render IconColumn 6`] = ` + +
+ +`; + +exports[`FlowColumns Components should render IconColumn 7`] = ` + +
+ +`; + +exports[`FlowColumns Components should render IconColumn 8`] = ` + +
+ +`; + +exports[`FlowColumns Components should render MethodColumn 1`] = ` + + GET + +`; + +exports[`FlowColumns Components should render SizeColumn 1`] = ` + + 100b + +`; + +exports[`FlowColumns Components should render StatusColumn 1`] = ` + +`; + +exports[`FlowColumns Components should render TLSColumn 1`] = ` + +`; + +exports[`FlowColumns Components should render TimeColumn 1`] = ` + + 2min + +`; + +exports[`FlowColumns Components should render TimeColumn 2`] = ` + + ... + +`; + +exports[`FlowColumns Components should render pathColumn 1`] = ` + + + + http://undefined:undefinedundefined + +`; + +exports[`FlowColumns Components should render pathColumn 2`] = ` + + + + + http://undefined:undefinedundefined + +`;