Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
test(datepicker): add test for ENTER keypress to close datepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
vmlf01 authored and mgcrea committed Dec 29, 2014
1 parent 51cc071 commit 96d0a11
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/datepicker/test/datepicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ describe('datepicker', function() {
return jQuery(element[0]);
}

function triggerKeyDown(elm, keyCode) {
var evt = $.Event('keydown');
evt.which = evt.keyCode = keyCode;
angular.element(elm[0]).triggerHandler(evt);
}

// Tests

describe('with default template', function() {
Expand All @@ -217,6 +223,16 @@ describe('datepicker', function() {
expect(sandboxEl.children('.dropdown-menu.datepicker').length).toBe(0);
});

it('should close on ENTER keypress', function() {
var elm = compileDirective('default');
expect(sandboxEl.children('.dropdown-menu.datepicker').length).toBe(0);
angular.element(elm[0]).triggerHandler('focus');
// flush timeout to allow for keyboard events to hookup
$timeout.flush();
triggerKeyDown(elm, 13);
expect(sandboxEl.children('.dropdown-menu.datepicker').length).toBe(0);
});

it('should correctly compile inner content', function() {
var elm = compileDirective('default');
angular.element(elm[0]).triggerHandler('focus');
Expand Down

0 comments on commit 96d0a11

Please sign in to comment.