This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -155,4 +155,34 @@ describe('ngOn* event binding', function() {
155
155
expect ( attrs . $attr . ngOnTitle ) . toBe ( 'ng-on-title' ) ;
156
156
} ) ;
157
157
} ) ;
158
+
159
+ it ( 'should correctly bind to kebab-cased event names' , inject ( function ( $compile , $rootScope ) {
160
+ var element = $compile ( '<span ng-on-foo-bar="cb()"></span>' ) ( $rootScope ) ;
161
+ var cb = $rootScope . cb = jasmine . createSpy ( 'ng-on cb' ) ;
162
+ $rootScope . $digest ( ) ;
163
+
164
+ element . triggerHandler ( 'foobar' ) ;
165
+ element . triggerHandler ( 'fooBar' ) ;
166
+ element . triggerHandler ( 'foo_bar' ) ;
167
+ element . triggerHandler ( 'foo:bar' ) ;
168
+ expect ( cb ) . not . toHaveBeenCalled ( ) ;
169
+
170
+ element . triggerHandler ( 'foo-bar' ) ;
171
+ expect ( cb ) . toHaveBeenCalled ( ) ;
172
+ } ) ) ;
173
+
174
+ it ( 'should correctly bind to camelCased event names' , inject ( function ( $compile , $rootScope ) {
175
+ var element = $compile ( '<span ng-on-foo_bar="cb()"></span>' ) ( $rootScope ) ;
176
+ var cb = $rootScope . cb = jasmine . createSpy ( 'ng-on cb' ) ;
177
+ $rootScope . $digest ( ) ;
178
+
179
+ element . triggerHandler ( 'foobar' ) ;
180
+ element . triggerHandler ( 'foo-bar' ) ;
181
+ element . triggerHandler ( 'foo_bar' ) ;
182
+ element . triggerHandler ( 'foo:bar' ) ;
183
+ expect ( cb ) . not . toHaveBeenCalled ( ) ;
184
+
185
+ element . triggerHandler ( 'fooBar' ) ;
186
+ expect ( cb ) . toHaveBeenCalled ( ) ;
187
+ } ) ) ;
158
188
} ) ;
You can’t perform that action at this time.
0 commit comments