@@ -9,7 +9,7 @@ import SpyObj = jasmine.SpyObj;
99describe ( 'ServerCheckGuard' , ( ) => {
1010 let guard : ServerCheckGuard ;
1111 let router : Router ;
12- const eventSubject = new ReplaySubject < RouterEvent > ( 1 ) ;
12+ let eventSubject : ReplaySubject < RouterEvent > ;
1313 let rootDataServiceStub : SpyObj < RootDataService > ;
1414 let testScheduler : TestScheduler ;
1515 let redirectUrlTree : UrlTree ;
@@ -24,6 +24,7 @@ describe('ServerCheckGuard', () => {
2424 findRoot : jasmine . createSpy ( 'findRoot' )
2525 } ) ;
2626 redirectUrlTree = new UrlTree ( ) ;
27+ eventSubject = new ReplaySubject < RouterEvent > ( 1 ) ;
2728 router = {
2829 events : eventSubject . asObservable ( ) ,
2930 navigateByUrl : jasmine . createSpy ( 'navigateByUrl' ) ,
@@ -64,10 +65,10 @@ describe('ServerCheckGuard', () => {
6465 } ) ;
6566
6667 describe ( `listenForRouteChanges` , ( ) => {
67- it ( `should retrieve the root endpoint, without using the cache, when the method is first called` , ( ) => {
68+ it ( `should invalidate the root cache, when the method is first called` , ( ) => {
6869 testScheduler . run ( ( ) => {
6970 guard . listenForRouteChanges ( ) ;
70- expect ( rootDataServiceStub . findRoot ) . toHaveBeenCalledWith ( false ) ;
71+ expect ( rootDataServiceStub . invalidateRootCache ) . toHaveBeenCalledTimes ( 1 ) ;
7172 } ) ;
7273 } ) ;
7374
@@ -80,7 +81,8 @@ describe('ServerCheckGuard', () => {
8081 eventSubject . next ( new NavigationEnd ( 2 , '' , '' ) ) ;
8182 eventSubject . next ( new NavigationStart ( 3 , '' ) ) ;
8283 } ) ;
83- expect ( rootDataServiceStub . invalidateRootCache ) . toHaveBeenCalledTimes ( 3 ) ;
84+ // once when the method is first called, and then 3 times for NavigationStart events
85+ expect ( rootDataServiceStub . invalidateRootCache ) . toHaveBeenCalledTimes ( 1 + 3 ) ;
8486 } ) ;
8587 } ) ;
8688} ) ;
0 commit comments