@@ -30,9 +30,20 @@ describe('RouterLink', () => {
3030 } ) ;
3131
3232 describe ( 'on a non-anchor' , ( ) => {
33- @Component ( { template : `<div [routerLink]="link"></div>` } )
33+ @Component ( {
34+ template : `
35+ <div
36+ [routerLink]="link"
37+ [preserveFragment]="preserveFragment"
38+ [skipLocationChange]="skipLocationChange"
39+ [replaceUrl]="replaceUrl"></div>
40+ `
41+ } )
3442 class LinkComponent {
3543 link : string | null | undefined = '/' ;
44+ preserveFragment : unknown ;
45+ skipLocationChange : unknown ;
46+ replaceUrl : unknown ;
3647 }
3748 let fixture : ComponentFixture < LinkComponent > ;
3849 let link : HTMLDivElement ;
@@ -76,18 +87,20 @@ describe('RouterLink', () => {
7687 const dir = fixture . debugElement . query ( By . directive ( RouterLink ) ) . injector . get ( RouterLink ) ;
7788
7889 for ( const truthy of [ true , '' , 'true' , 'anything' ] ) {
79- dir . preserveFragment = truthy ;
80- dir . skipLocationChange = truthy ;
81- dir . replaceUrl = truthy ;
90+ fixture . componentInstance . preserveFragment = truthy ;
91+ fixture . componentInstance . skipLocationChange = truthy ;
92+ fixture . componentInstance . replaceUrl = truthy ;
93+ fixture . detectChanges ( ) ;
8294 expect ( dir . preserveFragment ) . toBeTrue ( ) ;
8395 expect ( dir . skipLocationChange ) . toBeTrue ( ) ;
8496 expect ( dir . replaceUrl ) . toBeTrue ( ) ;
8597 }
8698
8799 for ( const falsy of [ false , null , undefined , 'false' ] ) {
88- dir . preserveFragment = falsy ;
89- dir . skipLocationChange = falsy ;
90- dir . replaceUrl = falsy ;
100+ fixture . componentInstance . preserveFragment = falsy ;
101+ fixture . componentInstance . skipLocationChange = falsy ;
102+ fixture . componentInstance . replaceUrl = falsy ;
103+ fixture . detectChanges ( ) ;
91104 expect ( dir . preserveFragment ) . toBeFalse ( ) ;
92105 expect ( dir . skipLocationChange ) . toBeFalse ( ) ;
93106 expect ( dir . replaceUrl ) . toBeFalse ( ) ;
@@ -97,9 +110,20 @@ describe('RouterLink', () => {
97110
98111 describe ( 'on an anchor' , ( ) => {
99112 describe ( 'RouterLink for elements with `href` attributes' , ( ) => {
100- @Component ( { template : `<a [routerLink]="link"></a>` } )
113+ @Component ( {
114+ template : `
115+ <a
116+ [routerLink]="link"
117+ [preserveFragment]="preserveFragment"
118+ [skipLocationChange]="skipLocationChange"
119+ [replaceUrl]="replaceUrl"></a>
120+ `
121+ } )
101122 class LinkComponent {
102123 link : string | null | undefined = '/' ;
124+ preserveFragment : unknown ;
125+ skipLocationChange : unknown ;
126+ replaceUrl : unknown ;
103127 }
104128 let fixture : ComponentFixture < LinkComponent > ;
105129 let link : HTMLAnchorElement ;
@@ -132,18 +156,20 @@ describe('RouterLink', () => {
132156 const dir = fixture . debugElement . query ( By . directive ( RouterLink ) ) . injector . get ( RouterLink ) ;
133157
134158 for ( const truthy of [ true , '' , 'true' , 'anything' ] ) {
135- dir . preserveFragment = truthy ;
136- dir . skipLocationChange = truthy ;
137- dir . replaceUrl = truthy ;
159+ fixture . componentInstance . preserveFragment = truthy ;
160+ fixture . componentInstance . skipLocationChange = truthy ;
161+ fixture . componentInstance . replaceUrl = truthy ;
162+ fixture . detectChanges ( ) ;
138163 expect ( dir . preserveFragment ) . toBeTrue ( ) ;
139164 expect ( dir . skipLocationChange ) . toBeTrue ( ) ;
140165 expect ( dir . replaceUrl ) . toBeTrue ( ) ;
141166 }
142167
143168 for ( const falsy of [ false , null , undefined , 'false' ] ) {
144- dir . preserveFragment = falsy ;
145- dir . skipLocationChange = falsy ;
146- dir . replaceUrl = falsy ;
169+ fixture . componentInstance . preserveFragment = falsy ;
170+ fixture . componentInstance . skipLocationChange = falsy ;
171+ fixture . componentInstance . replaceUrl = falsy ;
172+ fixture . detectChanges ( ) ;
147173 expect ( dir . preserveFragment ) . toBeFalse ( ) ;
148174 expect ( dir . skipLocationChange ) . toBeFalse ( ) ;
149175 expect ( dir . replaceUrl ) . toBeFalse ( ) ;
0 commit comments