2012-03-08 23:00:38 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
2012-04-09 18:20:55 +00:00
|
|
|
describe('ngClick', function() {
|
2012-03-08 23:00:38 +00:00
|
|
|
var element;
|
|
|
|
|
|
|
|
|
|
afterEach(function() {
|
|
|
|
|
dealoc(element);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should get called on a click', inject(function($rootScope, $compile) {
|
2012-03-09 08:00:05 +00:00
|
|
|
element = $compile('<div ng-click="clicked = true"></div>')($rootScope);
|
2012-03-08 23:00:38 +00:00
|
|
|
$rootScope.$digest();
|
|
|
|
|
expect($rootScope.clicked).toBeFalsy();
|
|
|
|
|
|
|
|
|
|
browserTrigger(element, 'click');
|
|
|
|
|
expect($rootScope.clicked).toEqual(true);
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
it('should pass event object', inject(function($rootScope, $compile) {
|
2012-03-09 08:00:05 +00:00
|
|
|
element = $compile('<div ng-click="event = $event"></div>')($rootScope);
|
2012-03-08 23:00:38 +00:00
|
|
|
$rootScope.$digest();
|
|
|
|
|
|
|
|
|
|
browserTrigger(element, 'click');
|
|
|
|
|
expect($rootScope.event).toBeDefined();
|
|
|
|
|
}));
|
|
|
|
|
});
|