Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 736e299

Browse files
committed
test(ngOn*): add tests for binding to camelCased event names
Closes #16757
1 parent 06d154f commit 736e299

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/ng/ngOnSpec.js

+30
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,34 @@ describe('ngOn* event binding', function() {
155155
expect(attrs.$attr.ngOnTitle).toBe('ng-on-title');
156156
});
157157
});
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+
}));
158188
});

0 commit comments

Comments
 (0)