aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/__tests__/components/ContentView
diff options
context:
space:
mode:
authorMatthew Shao <me@matshao.com>2017-06-05 10:22:19 +0800
committerMatthew Shao <me@matshao.com>2017-06-05 10:22:19 +0800
commitbff23275c32fa109e1bee09a819dad87789fdf24 (patch)
treee22f325df8ccb0ea3938b6f1bca6c4d1b6de9253 /web/src/js/__tests__/components/ContentView
parent298ac8391e86999c00804b2ed891ab8b7d4a6e39 (diff)
downloadmitmproxy-bff23275c32fa109e1bee09a819dad87789fdf24.tar.gz
mitmproxy-bff23275c32fa109e1bee09a819dad87789fdf24.tar.bz2
mitmproxy-bff23275c32fa109e1bee09a819dad87789fdf24.zip
[web] Add tests for js/components/ContentView/ShowFullContentButton.jsx
Diffstat (limited to 'web/src/js/__tests__/components/ContentView')
-rw-r--r--web/src/js/__tests__/components/ContentView/ShowFullContentButtonSpec.js39
-rw-r--r--web/src/js/__tests__/components/ContentView/__snapshots__/ShowFullContentButtonSpec.js.snap25
2 files changed, 64 insertions, 0 deletions
diff --git a/web/src/js/__tests__/components/ContentView/ShowFullContentButtonSpec.js b/web/src/js/__tests__/components/ContentView/ShowFullContentButtonSpec.js
new file mode 100644
index 00000000..14871f13
--- /dev/null
+++ b/web/src/js/__tests__/components/ContentView/ShowFullContentButtonSpec.js
@@ -0,0 +1,39 @@
+import React from 'react'
+import renderer from 'react-test-renderer'
+import { Provider } from 'react-redux'
+import ConnectedComponent, { ShowFullContentButton } from '../../../components/ContentView/ShowFullContentButton'
+import { TStore } from '../../ducks/tutils'
+
+
+describe('ShowFullContentButton Component', () => {
+ let setShowFullContentFn = jest.fn(),
+ showFullContentButton = renderer.create(
+ <ShowFullContentButton
+ setShowFullContent={setShowFullContentFn}
+ showFullContent={false}
+ visibleLines={10}
+ contentLines={20}
+ />
+ ),
+ tree = showFullContentButton.toJSON()
+
+ it('should render correctly', () => {
+ expect(tree).toMatchSnapshot()
+ })
+
+ it('should handle click', () => {
+ tree.children[0].props.onClick()
+ expect(setShowFullContentFn).toBeCalled()
+ })
+
+ it('should connect to state', () => {
+ let store = TStore(),
+ provider = renderer.create(
+ <Provider store={store}>
+ <ConnectedComponent/>
+ </Provider>
+ ),
+ tree = provider.toJSON()
+ expect(tree).toMatchSnapshot()
+ })
+})
diff --git a/web/src/js/__tests__/components/ContentView/__snapshots__/ShowFullContentButtonSpec.js.snap b/web/src/js/__tests__/components/ContentView/__snapshots__/ShowFullContentButtonSpec.js.snap
new file mode 100644
index 00000000..e0532154
--- /dev/null
+++ b/web/src/js/__tests__/components/ContentView/__snapshots__/ShowFullContentButtonSpec.js.snap
@@ -0,0 +1,25 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`ShowFullContentButton Component should connect to state 1`] = `null`;
+
+exports[`ShowFullContentButton Component should render correctly 1`] = `
+<div>
+ <div
+ className="view-all-content-btn btn-xs btn btn-default"
+ disabled={undefined}
+ onClick={[Function]}
+ title={undefined}
+ >
+ Show full content
+ </div>
+ <span
+ className="pull-right"
+ >
+
+ 10
+ /
+ 20
+ are visible  
+ </span>
+</div>
+`;