aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/__tests__/components
diff options
context:
space:
mode:
authorMatthew Shao <me@matshao.com>2017-05-26 17:25:51 +0800
committerMatthew Shao <me@matshao.com>2017-05-26 17:25:51 +0800
commit1d7e5544876b111e96358247435ba6dfb674b861 (patch)
treef4bf247d10c2d7806682a6b4d608a709e12647b0 /web/src/js/__tests__/components
parent05d78a8353370fe60e06bc75c1fe658b735ea2ed (diff)
downloadmitmproxy-1d7e5544876b111e96358247435ba6dfb674b861.tar.gz
mitmproxy-1d7e5544876b111e96358247435ba6dfb674b861.tar.bz2
mitmproxy-1d7e5544876b111e96358247435ba6dfb674b861.zip
[web] Add tests for js/components/Header/ConnectionIndicator.jsx
Diffstat (limited to 'web/src/js/__tests__/components')
-rw-r--r--web/src/js/__tests__/components/Header/ConnectionIndicatorSpec.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/web/src/js/__tests__/components/Header/ConnectionIndicatorSpec.js b/web/src/js/__tests__/components/Header/ConnectionIndicatorSpec.js
new file mode 100644
index 00000000..88527d91
--- /dev/null
+++ b/web/src/js/__tests__/components/Header/ConnectionIndicatorSpec.js
@@ -0,0 +1,57 @@
+import React from 'react'
+import renderer from 'react-test-renderer'
+import ConnectedIndicator, { ConnectionIndicator } from '../../../components/Header/ConnectionIndicator'
+import { ConnectionState } from '../../../ducks/connection'
+import { Provider } from 'react-redux'
+import configureStore from 'redux-mock-store'
+
+const mockStore = configureStore()
+
+describe('ConnectionIndicator Component', () => {
+
+ it('should render INIT', () => {
+ let connectionIndicator = renderer.create(
+ <ConnectionIndicator state={ConnectionState.INIT}/>),
+ tree = connectionIndicator.toJSON()
+ expect(tree).toMatchSnapshot()
+ })
+
+ it('should render FETCHING', () => {
+ let connectionIndicator = renderer.create(
+ <ConnectionIndicator state={ConnectionState.FETCHING}/>),
+ tree = connectionIndicator.toJSON()
+ expect(tree).toMatchSnapshot()
+ })
+
+ it('should render ESTABLISHED', () => {
+ let connectionIndicator = renderer.create(
+ <ConnectionIndicator state={ConnectionState.ESTABLISHED}/>),
+ tree = connectionIndicator.toJSON()
+ expect(tree).toMatchSnapshot()
+ })
+
+ it('should render ERROR', () => {
+ let connectionIndicator = renderer.create(
+ <ConnectionIndicator state={ConnectionState.ERROR} message="foo"/>),
+ tree = connectionIndicator.toJSON()
+ expect(tree).toMatchSnapshot()
+ })
+
+ it('should render OFFLINE', () => {
+ let connectionIndicator = renderer.create(
+ <ConnectionIndicator state={ConnectionState.OFFLINE} />),
+ tree = connectionIndicator.toJSON()
+ expect(tree).toMatchSnapshot()
+ })
+
+ it('should connect to state', () => {
+ let store = mockStore({ connection: {state: ConnectionState.INIT} }),
+ provider = renderer.create(
+ <Provider store={store}>
+ <ConnectedIndicator/>
+ </Provider>),
+ tree = provider.toJSON()
+ expect(tree).toMatchSnapshot()
+ })
+})
+