2012-03-08 23:00:38 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
describe('event directives', function() {
|
|
|
|
|
var element;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
afterEach(function() {
|
|
|
|
|
dealoc(element);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
2012-04-09 18:20:55 +00:00
|
|
|
describe('ngSubmit', function() {
|
2012-03-08 23:00:38 +00:00
|
|
|
|
|
|
|
|
it('should get called on form submit', inject(function($rootScope, $compile) {
|
2012-03-09 08:00:05 +00:00
|
|
|
element = $compile('<form action="" ng-submit="submitted = true">' +
|
2012-03-08 23:00:38 +00:00
|
|
|
'<input type="submit"/>' +
|
|
|
|
|
'</form>')($rootScope);
|
|
|
|
|
$rootScope.$digest();
|
|
|
|
|
expect($rootScope.submitted).not.toBeDefined();
|
|
|
|
|
|
|
|
|
|
browserTrigger(element.children()[0]);
|
|
|
|
|
expect($rootScope.submitted).toEqual(true);
|
|
|
|
|
}));
|
2013-05-23 15:22:55 +00:00
|
|
|
|
|
|
|
|
it('should expose event on form submit', inject(function($rootScope, $compile) {
|
|
|
|
|
$rootScope.formSubmission = function(e) {
|
|
|
|
|
if (e) {
|
|
|
|
|
$rootScope.formSubmitted = 'foo';
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
element = $compile('<form action="" ng-submit="formSubmission($event)">' +
|
|
|
|
|
'<input type="submit"/>' +
|
|
|
|
|
'</form>')($rootScope);
|
|
|
|
|
$rootScope.$digest();
|
|
|
|
|
expect($rootScope.formSubmitted).not.toBeDefined();
|
|
|
|
|
|
|
|
|
|
browserTrigger(element.children()[0]);
|
|
|
|
|
expect($rootScope.formSubmitted).toEqual('foo');
|
|
|
|
|
}));
|
2012-03-08 23:00:38 +00:00
|
|
|
});
|
|
|
|
|
});
|