@@ -141,7 +141,7 @@ describe('uiStateRef', function() {
141
141
ctrlKey : undefined ,
142
142
shiftKey : undefined ,
143
143
altKey : undefined ,
144
- button : undefined
144
+ button : undefined
145
145
} ) ;
146
146
timeoutFlush ( ) ;
147
147
$q . flush ( ) ;
@@ -156,7 +156,7 @@ describe('uiStateRef', function() {
156
156
157
157
timeoutFlush ( ) ;
158
158
$q . flush ( ) ;
159
-
159
+
160
160
expect ( $state . current . name ) . toEqual ( 'top' ) ;
161
161
expect ( $stateParams ) . toEqualData ( { } ) ;
162
162
} ) ) ;
@@ -222,7 +222,7 @@ describe('uiStateRef', function() {
222
222
223
223
it ( 'should allow passing params to current state' , inject ( function ( $compile , $rootScope , $state ) {
224
224
$state . current . name = 'contacts.item.detail' ;
225
-
225
+
226
226
el = angular . element ( "<a ui-sref=\"{id: $index}\">Details</a>" ) ;
227
227
$rootScope . $index = 3 ;
228
228
$rootScope . $apply ( ) ;
@@ -231,10 +231,10 @@ describe('uiStateRef', function() {
231
231
$rootScope . $digest ( ) ;
232
232
expect ( el . attr ( 'href' ) ) . toBe ( '#/contacts/3' ) ;
233
233
} ) ) ;
234
-
234
+
235
235
it ( 'should allow multi-line attribute values when passing params to current state' , inject ( function ( $compile , $rootScope , $state ) {
236
236
$state . current . name = 'contacts.item.detail' ;
237
-
237
+
238
238
el = angular . element ( "<a ui-sref=\"{\n\tid: $index\n}\">Details</a>" ) ;
239
239
$rootScope . $index = 3 ;
240
240
$rootScope . $apply ( ) ;
@@ -460,6 +460,37 @@ describe('uiStateRef', function() {
460
460
expect ( $state . $current . name ) . toBe ( "contacts" ) ;
461
461
} ) ) ;
462
462
} ) ;
463
+
464
+ describe ( 'DOM event bind to ui-sref' , function ( ) {
465
+
466
+ it ( 'should bind click event by default' , inject ( function ( $rootScope , $compile , $state , $timeout ) {
467
+ el = angular . element ( '<a ui-sref="contacts"></a>' ) ;
468
+ template = $compile ( el ) ( $rootScope ) ;
469
+ $rootScope . $digest ( ) ;
470
+
471
+ expect ( $state . current . name ) . toEqual ( 'top' ) ;
472
+
473
+ triggerClick ( el ) ;
474
+ $timeout . flush ( ) ;
475
+
476
+ expect ( $state . current . name ) . toEqual ( 'contacts' ) ;
477
+ } ) ) ;
478
+
479
+ it ( 'should bind events from ui-sref-opts' , inject ( function ( $rootScope , $compile , $state , $timeout ) {
480
+ el = angular . element ( '<input type="text" ui-sref="contacts" ui-sref-opts="{ event: [\'change\'] }">' ) ;
481
+ template = $compile ( el ) ( $rootScope ) ;
482
+ $rootScope . $digest ( ) ;
483
+
484
+ expect ( $state . current . name ) . toEqual ( 'top' ) ;
485
+
486
+ var change = document . createEvent ( "HTMLEvents" ) ;
487
+ change . initEvent ( "change" , false , true ) ;
488
+ el [ 0 ] . dispatchEvent ( change ) ;
489
+ $timeout . flush ( ) ;
490
+
491
+ expect ( $state . current . name ) . toEqual ( 'contacts' ) ;
492
+ } ) ) ;
493
+ } ) ;
463
494
} ) ;
464
495
465
496
describe ( 'uiSrefActive' , function ( ) {
0 commit comments