diff options
| author | Mark Nadig | 2012-11-28 16:27:51 -0700 | 
|---|---|---|
| committer | Pawel Kozlowski | 2012-12-18 22:57:58 +0100 | 
| commit | e03182f018f5069acd5e883ce2e9349b83f2d03f (patch) | |
| tree | 68825603b151ea2f38743e1dae92bc15ecb94cff /test/ng/directive/ngKeySpec.js | |
| parent | f2d526190a4fb38d1192803dccc9b60492e9ab76 (diff) | |
| download | angular.js-e03182f018f5069acd5e883ce2e9349b83f2d03f.tar.bz2 | |
feat(directive): ng:keydown, ng:keyup
New directives for binding to keydown and keyup events.
Closes #1035
Diffstat (limited to 'test/ng/directive/ngKeySpec.js')
| -rw-r--r-- | test/ng/directive/ngKeySpec.js | 29 | 
1 files changed, 29 insertions, 0 deletions
diff --git a/test/ng/directive/ngKeySpec.js b/test/ng/directive/ngKeySpec.js new file mode 100644 index 00000000..d8c6f9de --- /dev/null +++ b/test/ng/directive/ngKeySpec.js @@ -0,0 +1,29 @@ +'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); +  })); + +}); +  | 
