@@ -401,7 +401,7 @@ describe("future.v7_partialHydration", () => {
401
401
} ) ;
402
402
} ) ;
403
403
404
- it ( "does not kick off initial data load if errors exist" , async ( ) => {
404
+ it ( "does not kick off initial data load if errors exist (parent error) " , async ( ) => {
405
405
let consoleWarnSpy = jest
406
406
. spyOn ( console , "warn" )
407
407
. mockImplementation ( ( ) => { } ) ;
@@ -457,5 +457,62 @@ describe("future.v7_partialHydration", () => {
457
457
router . dispose ( ) ;
458
458
consoleWarnSpy . mockReset ( ) ;
459
459
} ) ;
460
+
461
+ it ( "does not kick off initial data load if errors exist (bubbled child error)" , async ( ) => {
462
+ let consoleWarnSpy = jest
463
+ . spyOn ( console , "warn" )
464
+ . mockImplementation ( ( ) => { } ) ;
465
+ let parentDfd = createDeferred ( ) ;
466
+ let parentSpy = jest . fn ( ( ) => parentDfd . promise ) ;
467
+ let childDfd = createDeferred ( ) ;
468
+ let childSpy = jest . fn ( ( ) => childDfd . promise ) ;
469
+ let router = createRouter ( {
470
+ history : createMemoryHistory ( { initialEntries : [ "/child" ] } ) ,
471
+ routes : [
472
+ {
473
+ path : "/" ,
474
+ loader : parentSpy ,
475
+ children : [
476
+ {
477
+ path : "child" ,
478
+ loader : childSpy ,
479
+ } ,
480
+ ] ,
481
+ } ,
482
+ ] ,
483
+ future : {
484
+ v7_partialHydration : true ,
485
+ } ,
486
+ hydrationData : {
487
+ errors : {
488
+ "0" : "CHILD ERROR" ,
489
+ } ,
490
+ loaderData : {
491
+ "0" : "PARENT DATA" ,
492
+ } ,
493
+ } ,
494
+ } ) ;
495
+ router . initialize ( ) ;
496
+
497
+ expect ( consoleWarnSpy ) . not . toHaveBeenCalled ( ) ;
498
+ expect ( parentSpy ) . not . toHaveBeenCalled ( ) ;
499
+ expect ( childSpy ) . not . toHaveBeenCalled ( ) ;
500
+ expect ( router . state ) . toMatchObject ( {
501
+ historyAction : "POP" ,
502
+ location : expect . objectContaining ( { pathname : "/child" } ) ,
503
+ matches : [ { route : { path : "/" } } , { route : { path : "child" } } ] ,
504
+ initialized : true ,
505
+ navigation : IDLE_NAVIGATION ,
506
+ errors : {
507
+ "0" : "CHILD ERROR" ,
508
+ } ,
509
+ loaderData : {
510
+ "0" : "PARENT DATA" ,
511
+ } ,
512
+ } ) ;
513
+
514
+ router . dispose ( ) ;
515
+ consoleWarnSpy . mockReset ( ) ;
516
+ } ) ;
460
517
} ) ;
461
518
} ) ;
0 commit comments