diff --git a/test/components/connect.spec.js b/test/components/connect.spec.js index 1145ce13f..30741853f 100644 --- a/test/components/connect.spec.js +++ b/test/components/connect.spec.js @@ -1212,5 +1212,38 @@ describe('React', () => { // store.dispatch({ type: 'APPEND', body: 'd'}); // expect(childMapStateInvokes).toBe(5); }); + + it('should not render the wrapped component when mapState does not produce change', () => { + const store = createStore(stringBuilder); + let renderCalls = 0; + let mapStateCalls = 0; + + @connect(() => { + mapStateCalls++; + return {}; // no change! + }) + class Container extends Component { + render() { + renderCalls++; + return ; + } + } + + TestUtils.renderIntoDocument( + + + + ); + + expect(renderCalls).toBe(1); + expect(mapStateCalls).toBe(2); + + store.dispatch({ type: 'APPEND', body: 'a'}); + + // After store a change mapState has been called + expect(mapStateCalls).toBe(3); + // But render is not because it did not make any actual changes + expect(renderCalls).toBe(1); + }); }); });