diff --git a/web/src/js/__tests__/components/ContentViewSpec.js b/web/src/js/__tests__/components/ContentViewSpec.js new file mode 100644 index 000000000..c106b28b6 --- /dev/null +++ b/web/src/js/__tests__/components/ContentViewSpec.js @@ -0,0 +1,61 @@ +import React from 'react' +import renderer from 'react-test-renderer' +import ContentView from '../../components/ContentView' +import { TStore, TFlow } from '../ducks/tutils' +import { Provider } from 'react-redux' +import mockXMLHttpRequest from 'mock-xmlhttprequest' + +global.XMLHttpRequest = mockXMLHttpRequest + +describe('ContentView Component', () => { + let store = TStore() + + it('should render correctly', () => { + let tflow = TFlow(), + provider = renderer.create( + + + ), + tree = provider.toJSON() + expect(tree).toMatchSnapshot() + }) + + it('should render correctly with empty content', () => { + let tflow = TFlow() + tflow.response.contentLength = 0 + let provider = renderer.create( + + + ), + tree = provider.toJSON() + expect(tree).toMatchSnapshot() + }) + + it('should render correctly with missing content', () => { + let tflow = TFlow() + tflow.response.contentLength = null + let provider = renderer.create( + + + ), + tree = provider.toJSON() + expect(tree).toMatchSnapshot() + }) + + it('should render correctly with content too large', () => { + let tflow = TFlow() + tflow.response.contentLength = 1024 * 1024 * 100 + let provider = renderer.create( + + + ), + tree = provider.toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/web/src/js/__tests__/components/__snapshots__/ContentViewSpec.js.snap b/web/src/js/__tests__/components/__snapshots__/ContentViewSpec.js.snap new file mode 100644 index 000000000..60b816e2e --- /dev/null +++ b/web/src/js/__tests__/components/__snapshots__/ContentViewSpec.js.snap @@ -0,0 +1,80 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ContentView Component should render correctly 1`] = ` +
+
+ +
+
+`; + +exports[`ContentView Component should render correctly with content too large 1`] = ` +
+
+ + 100mb + content size. +
+
+ + + + +   + + + +
+
+`; + +exports[`ContentView Component should render correctly with empty content 1`] = ` +
+ No + response + content. +
+`; + +exports[`ContentView Component should render correctly with missing content 1`] = ` +
+ Response + content missing. +
+`;