@@ -5,7 +5,7 @@ import { By } from '@angular/platform-browser';
5
5
6
6
import { UIRouterModule } from '../../src/uiRouterNgModule' ;
7
7
import { UISref } from '../../src/directives/uiSref' ;
8
- import { UIRouter , TargetState , TransitionOptions } from '@uirouter/core' ;
8
+ import { UIRouter , StateDeclaration , TargetState , TransitionOptions } from '@uirouter/core' ;
9
9
import { Subscription } from 'rxjs' ;
10
10
import { clickOnElement } from '../testUtils' ;
11
11
@@ -14,6 +14,7 @@ describe('uiSref', () => {
14
14
template : `
15
15
<a [uiSref]="linkA" [target]="targetA" [uiParams]="linkAParams" [uiOptions]="linkAOptions"></a>
16
16
<a [uiSref]="linkB"></a>
17
+ <a [uiSref]="linkC"></a>
17
18
` ,
18
19
} )
19
20
class TestComponent {
@@ -22,6 +23,7 @@ describe('uiSref', () => {
22
23
linkAOptions : TransitionOptions ;
23
24
targetA : string ;
24
25
linkB : string ;
26
+ linkC : StateDeclaration ;
25
27
26
28
@ViewChildren ( UISref ) srefs : QueryList < UISref > ;
27
29
@@ -35,6 +37,7 @@ describe('uiSref', () => {
35
37
this . linkAOptions = null ;
36
38
this . targetA = '' ;
37
39
this . linkB = '' ;
40
+ this . linkC = { } ;
38
41
}
39
42
}
40
43
@@ -108,6 +111,16 @@ describe('uiSref', () => {
108
111
expect ( gospy . mock . calls [ 0 ] [ 0 ] ) . toBe ( 'stateref' ) ;
109
112
} ) ;
110
113
114
+ it ( 'should handle when param is stateDeclaration' , ( ) => {
115
+ const { fixture, srefElements, router } = setup ( ) ;
116
+ const gospy = jest . spyOn ( router . stateService , 'go' ) ;
117
+ fixture . componentInstance . linkC = { name : 'stateref' } ;
118
+ fixture . detectChanges ( ) ;
119
+ clickOnElement ( srefElements [ 2 ] ) ;
120
+ expect ( gospy ) . toHaveBeenCalledTimes ( 1 ) ;
121
+ expect ( gospy . mock . calls [ 0 ] [ 0 ] ) . toEqual ( { name : 'stateref' } ) ;
122
+ } ) ;
123
+
111
124
it ( 'should ignore the click event when target is _blank' , ( ) => {
112
125
const { fixture, srefElements, router } = setup ( ) ;
113
126
const gospy = jest . spyOn ( router . stateService , 'go' ) ;
0 commit comments