@@ -1276,6 +1276,29 @@ describe('ReactCompositeComponent', function() {
1276
1276
expect ( Component . pqr ( ) ) . toBe ( Component . type ) ;
1277
1277
} ) ;
1278
1278
1279
+ it ( 'should throw if a reserved property is in statics' , function ( ) {
1280
+ expect ( function ( ) {
1281
+ React . createClass ( {
1282
+ statics : {
1283
+ getDefaultProps : function ( ) {
1284
+ return {
1285
+ foo : 0
1286
+ } ;
1287
+ }
1288
+ } ,
1289
+
1290
+ render : function ( ) {
1291
+ return < span /> ;
1292
+ }
1293
+ } ) ;
1294
+ } ) . toThrow (
1295
+ 'Invariant Violation: ReactCompositeComponent: You are attempting to ' +
1296
+ 'define a reserved property, `getDefaultProps`, that shouldn\'t be on ' +
1297
+ 'the "statics" key. Define it as an instance property instead; it ' +
1298
+ 'will still be accessible on the constructor.'
1299
+ ) ;
1300
+ } ) ;
1301
+
1279
1302
it ( 'should support statics in mixins' , function ( ) {
1280
1303
var Mixin = {
1281
1304
statics : {
@@ -1321,9 +1344,33 @@ describe('ReactCompositeComponent', function() {
1321
1344
} ) ;
1322
1345
} ) . toThrow (
1323
1346
'Invariant Violation: ReactCompositeComponent: You are attempting to ' +
1324
- 'define `abc` on your component more than once, but that is only ' +
1325
- 'supported for functions, which are chained together. This conflict ' +
1326
- 'may be due to a mixin.'
1347
+ 'define `abc` on your component more than once. This conflict may be ' +
1348
+ 'due to a mixin.'
1349
+ ) ;
1350
+ } ) ;
1351
+
1352
+ it ( "should throw if mixins override functions in statics" , function ( ) {
1353
+ expect ( function ( ) {
1354
+ var Mixin = {
1355
+ statics : {
1356
+ abc : function ( ) { console . log ( 'foo' ) ; }
1357
+ }
1358
+ } ;
1359
+ React . createClass ( {
1360
+ mixins : [ Mixin ] ,
1361
+
1362
+ statics : {
1363
+ abc : function ( ) { console . log ( 'bar' ) ; }
1364
+ } ,
1365
+
1366
+ render : function ( ) {
1367
+ return < span /> ;
1368
+ }
1369
+ } ) ;
1370
+ } ) . toThrow (
1371
+ 'Invariant Violation: ReactCompositeComponent: You are attempting to ' +
1372
+ 'define `abc` on your component more than once. This conflict may be ' +
1373
+ 'due to a mixin.'
1327
1374
) ;
1328
1375
} ) ;
1329
1376
0 commit comments