@@ -5,7 +5,7 @@ import { By } from '@angular/platform-browser';
55
66import { UIRouterModule } from '../../src/uiRouterNgModule' ;
77import { UISref } from '../../src/directives/uiSref' ;
8- import { UIRouter , TargetState , TransitionOptions } from '@uirouter/core' ;
8+ import { UIRouter , StateDeclaration , TargetState , TransitionOptions } from '@uirouter/core' ;
99import { Subscription } from 'rxjs' ;
1010import { clickOnElement } from '../testUtils' ;
1111
@@ -14,6 +14,7 @@ describe('uiSref', () => {
1414 template : `
1515 <a [uiSref]="linkA" [target]="targetA" [uiParams]="linkAParams" [uiOptions]="linkAOptions"></a>
1616 <a [uiSref]="linkB"></a>
17+ <a [uiSref]="linkC"></a>
1718 ` ,
1819 } )
1920 class TestComponent {
@@ -22,6 +23,7 @@ describe('uiSref', () => {
2223 linkAOptions : TransitionOptions ;
2324 targetA : string ;
2425 linkB : string ;
26+ linkC : StateDeclaration ;
2527
2628 @ViewChildren ( UISref ) srefs : QueryList < UISref > ;
2729
@@ -35,6 +37,7 @@ describe('uiSref', () => {
3537 this . linkAOptions = null ;
3638 this . targetA = '' ;
3739 this . linkB = '' ;
40+ this . linkC = { } ;
3841 }
3942 }
4043
@@ -108,6 +111,16 @@ describe('uiSref', () => {
108111 expect ( gospy . mock . calls [ 0 ] [ 0 ] ) . toBe ( 'stateref' ) ;
109112 } ) ;
110113
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+
111124 it ( 'should ignore the click event when target is _blank' , ( ) => {
112125 const { fixture, srefElements, router } = setup ( ) ;
113126 const gospy = jest . spyOn ( router . stateService , 'go' ) ;
0 commit comments