@@ -253,7 +253,7 @@ describe('render', () => {
253
253
. to . have . been . calledOnce
254
254
. and . calledWithExactly (
255
255
match ( PROPS ) ,
256
- match . falsy ,
256
+ match ( { } ) ,
257
257
match ( { } ) // empty context
258
258
) ;
259
259
} ) ;
@@ -285,7 +285,7 @@ describe('render', () => {
285
285
foo : 1 ,
286
286
children : match ( { type : 'span' , props : { children : 'asdf' } } )
287
287
} ) ,
288
- match . falsy ,
288
+ match ( { } ) ,
289
289
match ( { } )
290
290
) ;
291
291
} ) ;
@@ -307,6 +307,19 @@ describe('render', () => {
307
307
expect ( render ( < Test foo = { undefined } bar = "b" /> ) , 'overridden' ) . to . equal ( '<div foo="default foo" bar="b"></div>' ) ;
308
308
} ) ;
309
309
310
+ it ( 'should initialize state as an empty object' , ( ) => {
311
+ const fn = spy ( ) ;
312
+ class Test extends Component {
313
+ render ( state ) {
314
+ fn ( this . state , state ) ;
315
+ return < div /> ;
316
+ }
317
+ }
318
+
319
+ render ( < Test /> ) ;
320
+ expect ( fn ) . to . be . calledOnce . and . be . calledWith ( match ( { } ) , match ( { } ) ) ;
321
+ } ) ;
322
+
310
323
it ( 'should invoke getDerivedStateFromProps' , ( ) => {
311
324
class Test extends Component {
312
325
static getDerivedStateFromProps ( ) { }
@@ -386,13 +399,13 @@ describe('render', () => {
386
399
render ( < Outer /> ) ;
387
400
388
401
expect ( Outer . prototype . getChildContext ) . to . have . been . calledOnce ;
389
- expect ( Inner . prototype . render ) . to . have . been . calledWith ( match ( { } ) , match . falsy , CONTEXT ) ;
402
+ expect ( Inner . prototype . render ) . to . have . been . calledWith ( match ( { } ) , match ( { } ) , CONTEXT ) ;
390
403
391
404
CONTEXT . foo = 'bar' ;
392
405
render ( < Outer { ...PROPS } /> ) ;
393
406
394
407
expect ( Outer . prototype . getChildContext ) . to . have . been . calledTwice ;
395
- expect ( Inner . prototype . render ) . to . have . been . calledWith ( match ( PROPS ) , match . falsy , CONTEXT ) ;
408
+ expect ( Inner . prototype . render ) . to . have . been . calledWith ( match ( PROPS ) , match ( { } ) , CONTEXT ) ;
396
409
} ) ;
397
410
398
411
it ( 'should pass context to direct children' , ( ) => {
@@ -419,13 +432,13 @@ describe('render', () => {
419
432
render ( < Outer /> ) ;
420
433
421
434
expect ( Outer . prototype . getChildContext ) . to . have . been . calledOnce ;
422
- expect ( Inner . prototype . render ) . to . have . been . calledWith ( match ( { } ) , match . falsy , CONTEXT ) ;
435
+ expect ( Inner . prototype . render ) . to . have . been . calledWith ( match ( { } ) , match ( { } ) , CONTEXT ) ;
423
436
424
437
CONTEXT . foo = 'bar' ;
425
438
render ( < Outer { ...PROPS } /> ) ;
426
439
427
440
expect ( Outer . prototype . getChildContext ) . to . have . been . calledTwice ;
428
- expect ( Inner . prototype . render ) . to . have . been . calledWith ( match ( PROPS ) , match . falsy , CONTEXT ) ;
441
+ expect ( Inner . prototype . render ) . to . have . been . calledWith ( match ( PROPS ) , match ( { } ) , CONTEXT ) ;
429
442
430
443
// make sure render() could make use of context.a
431
444
expect ( Inner . prototype . render ) . to . have . returned ( match ( { props : { children : 'a' } } ) ) ;
@@ -463,8 +476,8 @@ describe('render', () => {
463
476
464
477
render ( < Outer /> ) ;
465
478
466
- expect ( Inner . prototype . render ) . to . have . been . calledWith ( match ( { } ) , match . falsy , { outerContext } ) ;
467
- expect ( InnerMost . prototype . render ) . to . have . been . calledWith ( match ( { } ) , match . falsy , { outerContext, innerContext } ) ;
479
+ expect ( Inner . prototype . render ) . to . have . been . calledWith ( match ( { } ) , match ( { } ) , { outerContext } ) ;
480
+ expect ( InnerMost . prototype . render ) . to . have . been . calledWith ( match ( { } ) , match ( { } ) , { outerContext, innerContext } ) ;
468
481
} ) ;
469
482
} ) ;
470
483
0 commit comments