forked from angular/angular.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathngKeySpec.js
38 lines (28 loc) · 1.08 KB
/
ngKeySpec.js
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
'use strict';
describe('ngKeyup and ngKeydown directives', function() {
var element;
afterEach(function() {
dealoc(element);
});
it('should get called on a keyup', inject(function($rootScope, $compile) {
element = $compile('<input ng-keyup="touched = true">')($rootScope);
$rootScope.$digest();
expect($rootScope.touched).toBeFalsy();
browserTrigger(element, 'keyup');
expect($rootScope.touched).toEqual(true);
}));
it('should get called on a keydown', inject(function($rootScope, $compile) {
element = $compile('<input ng-keydown="touched = true">')($rootScope);
$rootScope.$digest();
expect($rootScope.touched).toBeFalsy();
browserTrigger(element, 'keydown');
expect($rootScope.touched).toEqual(true);
}));
it('should get called on a keypress', inject(function($rootScope, $compile) {
element = $compile('<input ng-keypress="touched = true">')($rootScope);
$rootScope.$digest();
expect($rootScope.touched).toBeFalsy();
browserTrigger(element, 'keypress');
expect($rootScope.touched).toEqual(true);
}));
});