From b2210f161c6de6791a0cd102bd1c3088ab4f8181 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 28 Sep 2015 03:54:13 +0300 Subject: [PATCH] Fix lint --- examples/counter/src/dock/DockMonitor.js | 2 + examples/counter/src/dock/MapProvider.js | 2 +- src/connectMonitor.js | 22 ----- test/connectMonitor.spec.js | 116 ----------------------- 4 files changed, 3 insertions(+), 139 deletions(-) delete mode 100644 src/connectMonitor.js delete mode 100644 test/connectMonitor.spec.js diff --git a/examples/counter/src/dock/DockMonitor.js b/examples/counter/src/dock/DockMonitor.js index 381636cc..c73bdbb3 100644 --- a/examples/counter/src/dock/DockMonitor.js +++ b/examples/counter/src/dock/DockMonitor.js @@ -89,6 +89,8 @@ export default class DockMonitor extends Component { case 'D': this.props.changePosition(); break; + default: + break; } } diff --git a/examples/counter/src/dock/MapProvider.js b/examples/counter/src/dock/MapProvider.js index 3b8bb8de..6ee2dd5f 100644 --- a/examples/counter/src/dock/MapProvider.js +++ b/examples/counter/src/dock/MapProvider.js @@ -2,7 +2,7 @@ // TODO: extract to a separate project. // -import React, { Children, Component, PropTypes } from 'react'; +import { Children, Component, PropTypes } from 'react'; const identity = _ => _; function mapStore(store, { mapAction = identity, mapState = identity }) { diff --git a/src/connectMonitor.js b/src/connectMonitor.js deleted file mode 100644 index 2ca16c00..00000000 --- a/src/connectMonitor.js +++ /dev/null @@ -1,22 +0,0 @@ -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { bindActionCreators } from 'redux'; -import { ActionCreators } from './devTools'; - -export default function connectMonitor(monitorActionCreators = {}) { - return Monitor => { - function mapStateToProps(state) { - return state; - } - function mapDispatchToProps(dispatch) { - return { - ...bindActionCreators(ActionCreators, dispatch), - monitorActions: bindActionCreators(monitorActionCreators, dispatch) - }; - } - const ConnectedMonitor = connect(mapStateToProps, mapDispatchToProps)(Monitor); - - - return DevTools; - }; -} diff --git a/test/connectMonitor.spec.js b/test/connectMonitor.spec.js deleted file mode 100644 index 40c36d0b..00000000 --- a/test/connectMonitor.spec.js +++ /dev/null @@ -1,116 +0,0 @@ -import expect from 'expect'; -import jsdom from 'mocha-jsdom'; -import React, { Component } from 'react'; -import TestUtils from 'react-addons-test-utils'; -import { connectMonitor, devTools } from '../src'; -import { createStore } from 'redux'; - -class MockMonitor extends Component { - render() { - return null; - } -} - -function increment() { - return { type: 'INCREMENT' }; -} - -function mockMonitorReducer(state = 0, action) { - switch (action.type) { - case 'INCREMENT': - return state + 1; - default: - return state; - } -} - -describe('connectMonitor', () => { - jsdom(); - - it('should pass devToolsStore to monitor', () => { - const store = devTools()(createStore)(() => {}); - const ConnectedMonitor = connectMonitor()(MockMonitor); - const tree = TestUtils.renderIntoDocument( - - ); - const mockMonitor = TestUtils.findRenderedComponentWithType(tree, MockMonitor); - expect(mockMonitor.props.store).toBe(store.devToolsStore); - }); - - it('should pass props to monitor', () => { - const store = devTools()(createStore)(() => {}); - const ConnectedMonitor = connectMonitor()(MockMonitor); - const tree = TestUtils.renderIntoDocument( - - ); - const mockMonitor = TestUtils.findRenderedComponentWithType(tree, MockMonitor); - expect(mockMonitor.props.one).toBe(1); - expect(mockMonitor.props.two).toBe(2); - }); - - it('should subscribe monitor to store updates', () => { - const ConnectedMonitor = connectMonitor()(MockMonitor); - const store = devTools()(createStore)( - (state, action) => { - switch (action.type) { - case 'INC': - return state + 1; - default: - return state; - } - }, - 0 - ); - const tree = TestUtils.renderIntoDocument( - - ); - - store.dispatch({type: 'INC'}); - - const mockMonitor = TestUtils.findRenderedComponentWithType(tree, MockMonitor); - const currentStateIndex = mockMonitor.props.currentStateIndex; - const computedStates = mockMonitor.props.computedStates; - - expect(computedStates[currentStateIndex].state).toBe(1); - }); - - it('should warn if devTools() not in middleware', () => { - const store = createStore(() => {}); - const ConnectedMonitor = connectMonitor()(MockMonitor); - - // Force to re-evaluate propType checks on every run - ConnectedMonitor.displayName = Math.random().toString(); - - const spy = expect.spyOn(console, 'error'); - TestUtils.renderIntoDocument(); - spy.restore(); - - expect(spy.calls).toContain( - /Could not find the DevTools store/, - (call, errMsg) => call.arguments[0].match(errMsg) - ); - }); - - it('should pass monitor state and actions to the monitor', () => { - const store = devTools(mockMonitorReducer)(createStore)(() => {}); - const ConnectedMonitor = connectMonitor()(MockMonitor); - const tree = TestUtils.renderIntoDocument( - - ); - const mockMonitor = TestUtils.findRenderedComponentWithType(tree, MockMonitor); - expect(mockMonitor.props.monitorState).toBe(0); - }); - - it('should pass bound monitor actions to monitor', () => { - const ConnectedMonitor = connectMonitor({ increment })(MockMonitor); - const store = devTools(mockMonitorReducer)(createStore)(() => {}); - const tree = TestUtils.renderIntoDocument( - - ); - - const mockMonitor = TestUtils.findRenderedComponentWithType(tree, MockMonitor); - expect(mockMonitor.props.monitorState).toBe(0); - mockMonitor.props.monitorActions.increment(); - expect(mockMonitor.props.monitorState).toBe(1); - }); -});