@@ -310,6 +310,94 @@ describe('ReactClass-mixin', function() {
310
310
) ;
311
311
} ) ;
312
312
313
+ it ( 'should warn if the mixin is undefined' , function ( ) {
314
+ spyOn ( console , 'error' ) ;
315
+
316
+ React . createClass ( {
317
+ mixins : [ undefined ] ,
318
+
319
+ render : function ( ) {
320
+ return < span /> ;
321
+ } ,
322
+ } ) ;
323
+
324
+ expect ( console . error . argsForCall . length ) . toBe ( 1 ) ;
325
+ expect ( console . error . argsForCall [ 0 ] [ 0 ] ) . toBe (
326
+ 'Warning: ReactClass: You\'re attempting to include a mixin that is ' +
327
+ 'either null or not an object. Check the mixins included by the ' +
328
+ 'component, as well as any mixins they include themselves. ' +
329
+ 'Expected object but got undefined.'
330
+ ) ;
331
+ } ) ;
332
+
333
+ it ( 'should warn if the mixin is null' , function ( ) {
334
+ spyOn ( console , 'error' ) ;
335
+
336
+ React . createClass ( {
337
+ mixins : [ null ] ,
338
+
339
+ render : function ( ) {
340
+ return < span /> ;
341
+ } ,
342
+ } ) ;
343
+
344
+ expect ( console . error . argsForCall . length ) . toBe ( 1 ) ;
345
+ expect ( console . error . argsForCall [ 0 ] [ 0 ] ) . toBe (
346
+ 'Warning: ReactClass: You\'re attempting to include a mixin that is ' +
347
+ 'either null or not an object. Check the mixins included by the ' +
348
+ 'component, as well as any mixins they include themselves. ' +
349
+ 'Expected object but got null.'
350
+ ) ;
351
+ } ) ;
352
+
353
+ it ( 'should warn if an undefined mixin is included in another mixin' , function ( ) {
354
+ spyOn ( console , 'error' ) ;
355
+
356
+ var mixinA = {
357
+ mixins : [ undefined ]
358
+ } ;
359
+
360
+ React . createClass ( {
361
+ mixins : [ mixinA ] ,
362
+
363
+ render : function ( ) {
364
+ return < span /> ;
365
+ } ,
366
+ } ) ;
367
+
368
+ expect ( console . error . argsForCall . length ) . toBe ( 1 ) ;
369
+ expect ( console . error . argsForCall [ 0 ] [ 0 ] ) . toBe (
370
+ 'Warning: ReactClass: You\'re attempting to include a mixin that is ' +
371
+ 'either null or not an object. Check the mixins included by the ' +
372
+ 'component, as well as any mixins they include themselves. ' +
373
+ 'Expected object but got undefined.'
374
+ ) ;
375
+ } ) ;
376
+
377
+ it ( 'should warn if a null mixin is included in another mixin' , function ( ) {
378
+ spyOn ( console , 'error' ) ;
379
+
380
+ var mixinA = {
381
+ mixins : [ null ]
382
+ } ;
383
+
384
+ React . createClass ( {
385
+ mixins : [ mixinA ] ,
386
+
387
+ render : function ( ) {
388
+ return < span /> ;
389
+ } ,
390
+ } ) ;
391
+
392
+ expect ( console . error . argsForCall . length ) . toBe ( 1 ) ;
393
+ expect ( console . error . argsForCall [ 0 ] [ 0 ] ) . toBe (
394
+ 'Warning: ReactClass: You\'re attempting to include a mixin that is ' +
395
+ 'either null or not an object. Check the mixins included by the ' +
396
+ 'component, as well as any mixins they include themselves. ' +
397
+ 'Expected object but got null.'
398
+ ) ;
399
+ } ) ;
400
+
313
401
it ( 'should throw if the mixin is a React component' , function ( ) {
314
402
expect ( function ( ) {
315
403
React . createClass ( {
0 commit comments