diff --git a/test/components/connect.spec.js b/test/components/connect.spec.js index 8af12bb2b..614ae4743 100644 --- a/test/components/connect.spec.js +++ b/test/components/connect.spec.js @@ -1148,5 +1148,51 @@ describe('React', () => { wrapper.setState({ value: 1 }); expect(target.props.statefulValue).toEqual(1); }); + + it('should not pass stale data to mapState', () => { + const store = createStore(stringBuilder); + store.dispatch({ type: 'APPEND', body: 'initial'}); + let childMapStateExecuted = false; + + @connect(state => ({ string: state }) ) + class Container extends Component { + + emitChange() { + store.dispatch({ type: 'APPEND', body: 'changed'}); + } + + render() { + return ( +
+ + +
+ ); + } + } + + @connect((state, parentProps) => { + childMapStateExecuted = true; + // The state from parent props should always be consistent with the current state + expect(state).toEqual(parentProps.parentString); + return {}; + }) + class ChildContainer extends Component { + render() { + return ; + } + } + + const tree = TestUtils.renderIntoDocument( + + + + ); + + const container = TestUtils.findRenderedComponentWithType(tree, Container); + const node = React.findDOMNode(container.getWrappedInstance().refs.button); + TestUtils.Simulate.click(node); + expect(childMapStateExecuted).toBe(true); + }); }); });