Skip to content

Commit 8b2049e

Browse files
author
Dallon Feldner
committed
Added failing test
1 parent 72aa83f commit 8b2049e

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test/components/connect.spec.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,5 +1064,54 @@ describe('React', () => {
10641064
expect(decorated.getWrappedInstance().someInstanceMethod()).toBe(someData);
10651065
expect(decorated.refs.wrappedInstance.someInstanceMethod()).toBe(someData);
10661066
});
1067+
1068+
it.only('should wrap impure components without supressing updates', () => {
1069+
const store = createStore(() => ({}));
1070+
1071+
class ImpureComponent extends Component {
1072+
static contextTypes = {
1073+
statefulValue: React.PropTypes.number
1074+
};
1075+
1076+
render() {
1077+
return <Passthrough statefulValue={this.context.statefulValue} />;
1078+
}
1079+
}
1080+
1081+
const decorator = connect(state => state);
1082+
const Decorated = decorator(ImpureComponent);
1083+
1084+
class StatefulWrapper extends Component {
1085+
state = {
1086+
value: 0
1087+
};
1088+
1089+
static childContextTypes = {
1090+
statefulValue: React.PropTypes.number
1091+
};
1092+
1093+
getChildContext() {
1094+
return {
1095+
statefulValue: this.state.value
1096+
};
1097+
}
1098+
1099+
render() {
1100+
return <Decorated />;
1101+
};
1102+
}
1103+
1104+
const tree = TestUtils.renderIntoDocument(
1105+
<ProviderMock store={store}>
1106+
<StatefulWrapper />
1107+
</ProviderMock>
1108+
);
1109+
1110+
const target = TestUtils.findRenderedComponentWithType(tree, Passthrough);
1111+
const wrapper = TestUtils.findRenderedComponentWithType(tree, StatefulWrapper);
1112+
expect(target.props.statefulValue).toEqual(0);
1113+
wrapper.setState({ value: 1 });
1114+
expect(target.props.statefulValue).toEqual(1);
1115+
});
10671116
});
10681117
});

0 commit comments

Comments
 (0)