@@ -521,6 +521,55 @@ describe('integration spec', () => {
521
521
done ( ) ;
522
522
} ) ;
523
523
} ) ;
524
+
525
+ it ( 'should continue to react to navigation after state initiates router change' , ( done : Function ) => {
526
+ const reducer = ( state : any = { state : { url : '/' } } , action : any ) => {
527
+ if ( action . type === ROUTER_NAVIGATION ) {
528
+ return { state : { url : action . payload . routerState . url . toString ( ) } } ;
529
+ } else {
530
+ return state ;
531
+ }
532
+ } ;
533
+
534
+ createTestModule ( {
535
+ reducers : { reducer } ,
536
+ config : { stateKey : 'reducer' } ,
537
+ } ) ;
538
+
539
+ const router : Router = TestBed . get ( Router ) ;
540
+ const store = TestBed . get ( Store ) ;
541
+ const log = logOfRouterAndStore ( router , store ) ;
542
+
543
+ store . dispatch ( { type : ROUTER_NAVIGATION , payload : { routerState : { url : '/next' } } } ) ;
544
+ waitForNavigation ( router )
545
+ . then ( ( ) => {
546
+ router . navigate ( [ '/' ] ) ;
547
+ return waitForNavigation ( router ) ;
548
+ } )
549
+ . then ( ( ) => {
550
+ expect ( log ) . toEqual ( [
551
+ { type : 'store' , state : { state : { url : '/' } } } ,
552
+ { type : 'router' , event : 'NavigationStart' , url : '/next' } ,
553
+ { type : 'store' , state : { state : { url : '/next' } } } ,
554
+ { type : 'router' , event : 'RoutesRecognized' , url : '/next' } ,
555
+ { type : 'router' , event : 'GuardsCheckStart' , url : '/next' } ,
556
+ { type : 'router' , event : 'GuardsCheckEnd' , url : '/next' } ,
557
+ { type : 'router' , event : 'ResolveStart' , url : '/next' } ,
558
+ { type : 'router' , event : 'ResolveEnd' , url : '/next' } ,
559
+ { type : 'router' , event : 'NavigationEnd' , url : '/next' } ,
560
+ { type : 'router' , event : 'NavigationStart' , url : '/' } ,
561
+ { type : 'router' , event : 'RoutesRecognized' , url : '/' } ,
562
+ { type : 'store' , state : { state : { url : '/' } } } ,
563
+ { type : 'router' , event : 'GuardsCheckStart' , url : '/' } ,
564
+ { type : 'router' , event : 'GuardsCheckEnd' , url : '/' } ,
565
+ { type : 'router' , event : 'ResolveStart' , url : '/' } ,
566
+ { type : 'router' , event : 'ResolveEnd' , url : '/' } ,
567
+ { type : 'router' , event : 'NavigationEnd' , url : '/' }
568
+ ] ) ;
569
+ done ( ) ;
570
+ } ) ;
571
+
572
+ } ) ;
524
573
} ) ;
525
574
526
575
function createTestModule (
0 commit comments