File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -1064,5 +1064,54 @@ describe('React', () => {
1064
1064
expect ( decorated . getWrappedInstance ( ) . someInstanceMethod ( ) ) . toBe ( someData ) ;
1065
1065
expect ( decorated . refs . wrappedInstance . someInstanceMethod ( ) ) . toBe ( someData ) ;
1066
1066
} ) ;
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
+ } ) ;
1067
1116
} ) ;
1068
1117
} ) ;
You can’t perform that action at this time.
0 commit comments