aboutsummaryrefslogtreecommitdiffstats
path: root/web/src
diff options
context:
space:
mode:
authorMatthew Shao <me@matshao.com>2017-05-11 08:19:10 +0800
committerMatthew Shao <me@matshao.com>2017-05-11 08:19:10 +0800
commitf3e5c35b49db114968b722652738c4cdaec705ee (patch)
tree8a3770ebf5cf64ce111d2371e12365c86547f486 /web/src
parentcafa094f75732bd803972aecb71e2d1032ee2390 (diff)
downloadmitmproxy-f3e5c35b49db114968b722652738c4cdaec705ee.tar.gz
mitmproxy-f3e5c35b49db114968b722652738c4cdaec705ee.tar.bz2
mitmproxy-f3e5c35b49db114968b722652738c4cdaec705ee.zip
[web] Add tests for js/components/common/Button.jsx
Diffstat (limited to 'web/src')
-rw-r--r--web/src/js/__tests__/components/common/ButtonSpec.js26
-rw-r--r--web/src/js/__tests__/components/common/__snapshots__/ButtonSpec.js.snap30
2 files changed, 56 insertions, 0 deletions
diff --git a/web/src/js/__tests__/components/common/ButtonSpec.js b/web/src/js/__tests__/components/common/ButtonSpec.js
new file mode 100644
index 00000000..ea05ee6e
--- /dev/null
+++ b/web/src/js/__tests__/components/common/ButtonSpec.js
@@ -0,0 +1,26 @@
+import React from 'react'
+import renderer from 'react-test-renderer'
+import Button from '../../../components/common/Button'
+
+describe('Button Component', () => {
+
+ it('should render correctly', () => {
+ let button = renderer.create(
+ <Button className="classname" onClick={() => "onclick"} title="title" icon="icon">
+ <a>foo</a>
+ </Button>
+ ),
+ tree = button.toJSON()
+ expect(tree).toMatchSnapshot()
+ })
+
+ it('should be able to be disabled', () => {
+ let button = renderer.create(
+ <Button className="classname" onClick={() => "onclick"} disabled="true" children="children">
+ <a>foo</a>
+ </Button>
+ ),
+ tree = button.toJSON()
+ expect(tree).toMatchSnapshot()
+ })
+})
diff --git a/web/src/js/__tests__/components/common/__snapshots__/ButtonSpec.js.snap b/web/src/js/__tests__/components/common/__snapshots__/ButtonSpec.js.snap
new file mode 100644
index 00000000..1d403b2d
--- /dev/null
+++ b/web/src/js/__tests__/components/common/__snapshots__/ButtonSpec.js.snap
@@ -0,0 +1,30 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Button Component should be able to be disabled 1`] = `
+<div
+ className="classname btn btn-default"
+ disabled="true"
+ onClick={false}
+ title={undefined}
+>
+ <a>
+ foo
+ </a>
+</div>
+`;
+
+exports[`Button Component should render correctly 1`] = `
+<div
+ className="classname btn btn-default"
+ disabled={undefined}
+ onClick={[Function]}
+ title="title"
+>
+ <i
+ className="fa fa-fw icon"
+ />
+ <a>
+ foo
+ </a>
+</div>
+`;