@@ -4,7 +4,7 @@ import { By } from '@angular/platform-browser';
4
4
5
5
import { UIRouterModule } from '../../src/uiRouterNgModule' ;
6
6
import { UISref } from '../../src/directives/uiSref' ;
7
- import { UIRouter , TargetState , TransitionOptions } from '@uirouter/core' ;
7
+ import { UIRouter , TargetState , TransitionOptions , StateService } from '@uirouter/core' ;
8
8
import { Subject } from 'rxjs/Subject' ;
9
9
import { Subscription } from 'rxjs/Subscription' ;
10
10
import { clickOnElement } from '../testUtils' ;
@@ -46,6 +46,7 @@ describe('uiSref', () => {
46
46
describe ( 'when the uiSref is empty' , ( ) => {
47
47
let des : DebugElement [ ] ;
48
48
let fixture : ComponentFixture < TestComponent > ;
49
+ let gospy : jasmine . Spy ;
49
50
50
51
beforeEach ( ( ) => {
51
52
fixture = TestBed . configureTestingModule ( {
@@ -54,13 +55,23 @@ describe('uiSref', () => {
54
55
} ) . createComponent ( TestComponent ) ;
55
56
fixture . detectChanges ( ) ;
56
57
des = fixture . debugElement . queryAll ( By . directive ( UISref ) ) ;
58
+ const stateService = fixture . debugElement . injector . get ( StateService ) ;
59
+ gospy = spyOn ( stateService , "go" ) ;
57
60
} ) ;
58
61
59
62
60
63
it ( 'should not bind "null" string to `href`' , ( ) => {
61
64
expect ( des [ 0 ] . nativeElement . hasAttribute ( 'href' ) ) . toBeFalsy ( ) ;
62
65
expect ( des [ 1 ] . nativeElement . hasAttribute ( 'href' ) ) . toBeFalsy ( ) ;
63
66
} ) ;
67
+
68
+ it ( 'should ignore the click event' , ( ) => {
69
+ clickOnElement ( des [ 0 ] ) ;
70
+ expect ( gospy ) . not . toHaveBeenCalled ( ) ;
71
+
72
+ clickOnElement ( des [ 1 ] ) ;
73
+ expect ( gospy ) . not . toHaveBeenCalled ( ) ;
74
+ } ) ;
64
75
} ) ;
65
76
66
77
describe ( 'when the uiSref is not empty' , ( ) => {
@@ -117,6 +128,7 @@ describe('uiSref', () => {
117
128
describe ( 'when target is not _blank' , ( ) => {
118
129
beforeEach ( ( ) => {
119
130
comp . targetA = '' ;
131
+ comp . linkA = 'state' ;
120
132
fixture . detectChanges ( ) ;
121
133
} ) ;
122
134
0 commit comments