@@ -20,7 +20,8 @@ describe('ServerCheckGuard', () => {
2020 } ) ;
2121 rootDataServiceStub = jasmine . createSpyObj ( 'RootDataService' , {
2222 checkServerAvailability : jasmine . createSpy ( 'checkServerAvailability' ) ,
23- invalidateRootCache : jasmine . createSpy ( 'invalidateRootCache' )
23+ invalidateRootCache : jasmine . createSpy ( 'invalidateRootCache' ) ,
24+ findRoot : jasmine . createSpy ( 'findRoot' )
2425 } ) ;
2526 redirectUrlTree = new UrlTree ( ) ;
2627 router = {
@@ -63,18 +64,23 @@ describe('ServerCheckGuard', () => {
6364 } ) ;
6465
6566 describe ( `listenForRouteChanges` , ( ) => {
66- it ( `should invalidate the root cache when the method is first called, and then on every NavigationStart event ` , ( ) => {
67+ it ( `should retrieve the root endpoint, without using the cache, when the method is first called` , ( ) => {
6768 testScheduler . run ( ( ) => {
6869 guard . listenForRouteChanges ( ) ;
69- expect ( rootDataServiceStub . invalidateRootCache ) . toHaveBeenCalledTimes ( 1 ) ;
70+ expect ( rootDataServiceStub . findRoot ) . toHaveBeenCalledWith ( false ) ;
71+ } ) ;
72+ } ) ;
7073
74+ it ( `should invalidate the root cache on every NavigationStart event` , ( ) => {
75+ testScheduler . run ( ( ) => {
76+ guard . listenForRouteChanges ( ) ;
7177 eventSubject . next ( new NavigationStart ( 1 , '' ) ) ;
7278 eventSubject . next ( new NavigationEnd ( 1 , '' , '' ) ) ;
7379 eventSubject . next ( new NavigationStart ( 2 , '' ) ) ;
7480 eventSubject . next ( new NavigationEnd ( 2 , '' , '' ) ) ;
7581 eventSubject . next ( new NavigationStart ( 3 , '' ) ) ;
7682 } ) ;
77- expect ( rootDataServiceStub . invalidateRootCache ) . toHaveBeenCalledTimes ( 4 ) ;
83+ expect ( rootDataServiceStub . invalidateRootCache ) . toHaveBeenCalledTimes ( 3 ) ;
7884 } ) ;
7985 } ) ;
8086} ) ;
0 commit comments