Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added unit tests for 'which' property on events

  • Loading branch information...
commit 5817e5bd5932cec5fd40cb9a2ffe5f35c93432cd 1 parent d8a8026
@mmonteleone authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 spec/jquery.autotype.specs.js
View
13 spec/jquery.autotype.specs.js
@@ -102,6 +102,12 @@ QUnit.specify("jQuery.autotype", function() {
assert(log[5].value).equals('ab');
assert(log[5].type).equals('keyup');
});
+ it('should include which on down, up, and press event', function(){
+ $('textarea').autotype('a');
+ assert(log[0].event.which).equals(65);
+ assert(log[1].event.which).equals(97);
+ assert(log[2].event.which).equals(65);
+ });
it('should include keycode only on down and up event', function(){
$('textarea').autotype('a');
assert(log[0].event.keyCode).equals(65);
@@ -186,6 +192,13 @@ QUnit.specify("jQuery.autotype", function() {
assert(log[0].event.keyCode).equals(expectedKeyCode);
assert(log[2].event.keyCode).equals(expectedKeyCode);
});
+ given(['pgup',33],['pgdn',34],['home',36],['end',35],['left',37],['right',39],['down',40],['up',38]).
+ it('should pass correct which codes for non-modifier control keys', function(keyName, expectedWhichCode) {
+ $('textarea').autotype('{{' + keyName + '}}');
+ assert(log.length).equals(3);
+ assert(log[0].event.which).equals(expectedWhichCode);
+ assert(log[2].event.which).equals(expectedWhichCode);
+ });
describe('when contorl key is an enter', function(){
it('should add a newline to value', function(){
$('textarea').autotype('line1{{enter}}line2');
Please sign in to comment.
Something went wrong with that request. Please try again.