@@ -12,7 +12,7 @@ import {ChangeDetectionStrategy, Component, EventEmitter, Inject, Injectable, In
1212import { ComponentFixture , fakeAsync , inject , TestBed , tick } from '@angular/core/testing' ;
1313import { By } from '@angular/platform-browser/src/dom/debug/by' ;
1414import { expect } from '@angular/platform-browser/testing/src/matchers' ;
15- import { ActivatedRoute , ActivatedRouteSnapshot , ActivationEnd , ActivationStart , CanActivate , CanDeactivate , ChildActivationEnd , ChildActivationStart , DefaultUrlSerializer , DetachedRouteHandle , Event , GuardsCheckEnd , GuardsCheckStart , Navigation , NavigationCancel , NavigationEnd , NavigationError , NavigationStart , ParamMap , Params , PreloadAllModules , PreloadingStrategy , PRIMARY_OUTLET , Resolve , ResolveEnd , ResolveStart , RouteConfigLoadEnd , RouteConfigLoadStart , Router , RouteReuseStrategy , RouterEvent , RouterLink , RouterLinkWithHref , RouterModule , RouterPreloader , RouterStateSnapshot , RoutesRecognized , RunGuardsAndResolvers , UrlHandlingStrategy , UrlSegmentGroup , UrlSerializer , UrlTree } from '@angular/router' ;
15+ import { ActivatedRoute , ActivatedRouteSnapshot , ActivationEnd , ActivationStart , CanActivate , CanDeactivate , ChildActivationEnd , ChildActivationStart , DefaultUrlSerializer , DetachedRouteHandle , Event , GuardsCheckEnd , GuardsCheckStart , Navigation , NavigationCancel , NavigationCancellationCode , NavigationEnd , NavigationError , NavigationStart , ParamMap , Params , PreloadAllModules , PreloadingStrategy , PRIMARY_OUTLET , Resolve , ResolveEnd , ResolveStart , RouteConfigLoadEnd , RouteConfigLoadStart , Router , RouteReuseStrategy , RouterEvent , RouterLink , RouterLinkWithHref , RouterModule , RouterPreloader , RouterStateSnapshot , RoutesRecognized , RunGuardsAndResolvers , UrlHandlingStrategy , UrlSegmentGroup , UrlSerializer , UrlTree } from '@angular/router' ;
1616import { EMPTY , Observable , Observer , of , Subscription } from 'rxjs' ;
1717import { delay , filter , first , map , mapTo , tap } from 'rxjs/operators' ;
1818
@@ -1769,6 +1769,7 @@ describe('Integration', () => {
17691769 let locationUrlBeforeEmittingError = '' ;
17701770 router . events . forEach ( e => {
17711771 if ( e instanceof NavigationCancel ) {
1772+ expect ( e . code ) . toBe ( NavigationCancellationCode . GuardRejected ) ;
17721773 routerUrlBeforeEmittingError = router . url ;
17731774 locationUrlBeforeEmittingError = location . path ( ) ;
17741775 }
@@ -2126,6 +2127,9 @@ describe('Integration', () => {
21262127 [ NavigationCancel , '/simple' ] ,
21272128 ] ) ;
21282129
2130+ expect ( ( recordedEvents [ recordedEvents . length - 1 ] as NavigationCancel ) . code )
2131+ . toBe ( NavigationCancellationCode . NoDataFromResolver ) ;
2132+
21292133 expect ( e ) . toEqual ( null ) ;
21302134 } ) ) ) ;
21312135
@@ -4324,6 +4328,9 @@ describe('Integration', () => {
43244328 [ NavigationCancel , '/lazyFalse/loaded' ] ,
43254329 ] ) ;
43264330
4331+ expect ( ( recordedEvents [ 1 ] as NavigationCancel ) . code )
4332+ . toBe ( NavigationCancellationCode . GuardRejected ) ;
4333+
43274334 recordedEvents . splice ( 0 ) ;
43284335
43294336 // successful navigation
@@ -4386,6 +4393,9 @@ describe('Integration', () => {
43864393 [ GuardsCheckEnd , '/blank' ] , [ ResolveStart , '/blank' ] , [ ResolveEnd , '/blank' ] ,
43874394 [ ActivationEnd ] , [ ChildActivationEnd ] , [ NavigationEnd , '/blank' ]
43884395 ] ) ;
4396+
4397+ expect ( ( recordedEvents [ 1 ] as NavigationCancel ) . code )
4398+ . toBe ( NavigationCancellationCode . SupersededByNewNavigation ) ;
43894399 } ) ) ) ;
43904400
43914401 it ( 'should support returning UrlTree from within the guard' ,
@@ -4421,6 +4431,9 @@ describe('Integration', () => {
44214431 [ GuardsCheckEnd , '/blank' ] , [ ResolveStart , '/blank' ] , [ ResolveEnd , '/blank' ] ,
44224432 [ ActivationEnd ] , [ ChildActivationEnd ] , [ NavigationEnd , '/blank' ]
44234433 ] ) ;
4434+
4435+ expect ( ( recordedEvents [ 1 ] as NavigationCancel ) . code )
4436+ . toBe ( NavigationCancellationCode . Redirect ) ;
44244437 } ) ) ) ;
44254438
44264439 // Regression where navigateByUrl with false CanLoad no longer resolved `false` value on
0 commit comments