blob: 5b73c2dd6a8b19b256009e64e4d89feaa6d96938 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
'use strict';
describe('event directives', function() {
var element;
afterEach(function() {
dealoc(element);
});
describe('ngSubmit', function() {
it('should get called on form submit', inject(function($rootScope, $compile) {
element = $compile('<form action="" ng-submit="submitted = true">' +
'<input type="submit"/>' +
'</form>')($rootScope);
$rootScope.$digest();
expect($rootScope.submitted).not.toBeDefined();
browserTrigger(element.children()[0]);
expect($rootScope.submitted).toEqual(true);
}));
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');
}));
});
});
|