From 1d7e5544876b111e96358247435ba6dfb674b861 Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Fri, 26 May 2017 17:25:51 +0800 Subject: [web] Add tests for js/components/Header/ConnectionIndicator.jsx --- .../components/Header/ConnectionIndicatorSpec.js | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 web/src/js/__tests__/components/Header/ConnectionIndicatorSpec.js (limited to 'web/src/js/__tests__/components') 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( + ), + tree = connectionIndicator.toJSON() + expect(tree).toMatchSnapshot() + }) + + it('should render FETCHING', () => { + let connectionIndicator = renderer.create( + ), + tree = connectionIndicator.toJSON() + expect(tree).toMatchSnapshot() + }) + + it('should render ESTABLISHED', () => { + let connectionIndicator = renderer.create( + ), + tree = connectionIndicator.toJSON() + expect(tree).toMatchSnapshot() + }) + + it('should render ERROR', () => { + let connectionIndicator = renderer.create( + ), + tree = connectionIndicator.toJSON() + expect(tree).toMatchSnapshot() + }) + + it('should render OFFLINE', () => { + let connectionIndicator = renderer.create( + ), + tree = connectionIndicator.toJSON() + expect(tree).toMatchSnapshot() + }) + + it('should connect to state', () => { + let store = mockStore({ connection: {state: ConnectionState.INIT} }), + provider = renderer.create( + + + ), + tree = provider.toJSON() + expect(tree).toMatchSnapshot() + }) +}) + -- cgit v1.2.3