@@ -100,9 +100,28 @@ describe('RouterState & Snapshot', () => {
100100
101101 describe ( 'equalParamsAndUrlSegments' , ( ) => {
102102 function createSnapshot ( params : Params , url : UrlSegment [ ] ) : ActivatedRouteSnapshot {
103- return new ActivatedRouteSnapshot (
103+ const snapshot = new ActivatedRouteSnapshot (
104104 url , params , < any > null , < any > null , < any > null , < any > null , < any > null , < any > null , < any > null ,
105105 - 1 , null ) ;
106+ snapshot . _routerState = new RouterStateSnapshot ( '' , new TreeNode ( snapshot , [ ] ) ) ;
107+ return snapshot ;
108+ }
109+
110+ function createSnapshotPairWithParent (
111+ params : [ Params , Params ] , parentParams : [ Params , Params ] ,
112+ urls : [ string , string ] ) : [ ActivatedRouteSnapshot , ActivatedRouteSnapshot ] {
113+ const snapshot1 = createSnapshot ( params [ 0 ] , [ ] ) ;
114+ const snapshot2 = createSnapshot ( params [ 1 ] , [ ] ) ;
115+
116+ const snapshot1Parent = createSnapshot ( parentParams [ 0 ] , [ new UrlSegment ( urls [ 0 ] , { } ) ] ) ;
117+ const snapshot2Parent = createSnapshot ( parentParams [ 1 ] , [ new UrlSegment ( urls [ 1 ] , { } ) ] ) ;
118+
119+ snapshot1 . _routerState =
120+ new RouterStateSnapshot ( '' , new TreeNode ( snapshot1Parent , [ new TreeNode ( snapshot1 , [ ] ) ] ) ) ;
121+ snapshot2 . _routerState =
122+ new RouterStateSnapshot ( '' , new TreeNode ( snapshot2Parent , [ new TreeNode ( snapshot2 , [ ] ) ] ) ) ;
123+
124+ return [ snapshot1 , snapshot2 ] ;
106125 }
107126
108127 it ( 'should return false when params are different' , ( ) => {
@@ -123,6 +142,27 @@ describe('RouterState & Snapshot', () => {
123142 createSnapshot ( { a : 1 } , [ new UrlSegment ( 'a' , { } ) ] ) ) )
124143 . toEqual ( true ) ;
125144 } ) ;
145+
146+ it ( 'should return false when upstream params are different' , ( ) => {
147+ const [ snapshot1 , snapshot2 ] =
148+ createSnapshotPairWithParent ( [ { a : 1 } , { a : 1 } ] , [ { b : 1 } , { c : 1 } ] , [ 'a' , 'a' ] ) ;
149+
150+ expect ( equalParamsAndUrlSegments ( snapshot1 , snapshot2 ) ) . toEqual ( false ) ;
151+ } ) ;
152+
153+ it ( 'should return false when upstream urls are different' , ( ) => {
154+ const [ snapshot1 , snapshot2 ] =
155+ createSnapshotPairWithParent ( [ { a : 1 } , { a : 1 } ] , [ { b : 1 } , { b : 1 } ] , [ 'a' , 'b' ] ) ;
156+
157+ expect ( equalParamsAndUrlSegments ( snapshot1 , snapshot2 ) ) . toEqual ( false ) ;
158+ } ) ;
159+
160+ it ( 'should return true when upstream urls and params are equal' , ( ) => {
161+ const [ snapshot1 , snapshot2 ] =
162+ createSnapshotPairWithParent ( [ { a : 1 } , { a : 1 } ] , [ { b : 1 } , { b : 1 } ] , [ 'a' , 'a' ] ) ;
163+
164+ expect ( equalParamsAndUrlSegments ( snapshot1 , snapshot2 ) ) . toEqual ( true ) ;
165+ } ) ;
126166 } ) ;
127167
128168 describe ( 'advanceActivatedRoute' , ( ) => {
@@ -135,9 +175,12 @@ describe('RouterState & Snapshot', () => {
135175 const queryParams = { } ;
136176 const fragment = '' ;
137177 const data = { } ;
138- return new ActivatedRouteSnapshot (
178+ const snapshot = new ActivatedRouteSnapshot (
139179 url , params , queryParams , fragment , data , < any > null , < any > null , < any > null , < any > null , - 1 ,
140180 null ) ;
181+ const state = new RouterStateSnapshot ( '' , new TreeNode ( snapshot , [ ] ) ) ;
182+ snapshot . _routerState = state ;
183+ return snapshot ;
141184 }
142185
143186 it ( 'should call change observers' , ( ) => {
0 commit comments