@@ -567,4 +567,41 @@ describe('MenuService', () => {
567567 } ) ;
568568 } ) ;
569569
570+ describe ( `resolveSubstitutions` , ( ) => {
571+ let linkPrefix ;
572+ let link ;
573+ let uuid ;
574+
575+ beforeEach ( ( ) => {
576+ linkPrefix = 'statistics_collection_' ;
577+ link = `${ linkPrefix } :id` ;
578+ uuid = 'f7cc3ca4-3c2c-464d-8af8-add9f84f711c' ;
579+ } ) ;
580+
581+ it ( `shouldn't do anything when there are no params` , ( ) => {
582+ let result = ( service as any ) . resolveSubstitutions ( link , undefined ) ;
583+ expect ( result ) . toEqual ( link ) ;
584+ result = ( service as any ) . resolveSubstitutions ( link , null ) ;
585+ expect ( result ) . toEqual ( link ) ;
586+ result = ( service as any ) . resolveSubstitutions ( link , { } ) ;
587+ expect ( result ) . toEqual ( link ) ;
588+ } ) ;
589+
590+ it ( `should replace link params that are also route params` , ( ) => {
591+ const result = ( service as any ) . resolveSubstitutions ( link , { 'id' : uuid } ) ;
592+ expect ( result ) . toEqual ( linkPrefix + uuid ) ;
593+ } ) ;
594+
595+ it ( `should not replace link params that aren't route params` , ( ) => {
596+ const result = ( service as any ) . resolveSubstitutions ( link , { 'something' : 'else' } ) ;
597+ expect ( result ) . toEqual ( link ) ;
598+ } ) ;
599+
600+ it ( `should gracefully deal with routes that contain the name of the route param` , ( ) => {
601+ const selfReferentialParam = `:id:something` ;
602+ const result = ( service as any ) . resolveSubstitutions ( link , { 'id' : selfReferentialParam } ) ;
603+ expect ( result ) . toEqual ( linkPrefix + selfReferentialParam ) ;
604+ } ) ;
605+ } ) ;
606+
570607} ) ;
0 commit comments