diff options
author | Felix Nagel <info@felixnagel.com> | 2013-04-29 23:40:26 +0200 |
---|---|---|
committer | Felix Nagel <info@felixnagel.com> | 2013-04-29 23:40:26 +0200 |
commit | 6640925db2f326932bc7d2ef76f4cd96930e92bd (patch) | |
tree | cc45853ac7e22d55ca59de17156ea167ce6f14c8 /tests | |
parent | f96ee5e0488e28445fc4ebcc254dfa10aad2b1c9 (diff) | |
parent | 5c0a6aaeb7fac32950ddc44870295d5983ece15d (diff) | |
download | jquery-ui-6640925db2f326932bc7d2ef76f4cd96930e92bd.tar.gz jquery-ui-6640925db2f326932bc7d2ef76f4cd96930e92bd.zip |
Merge branch 'master' into selectmenu
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/autocomplete/autocomplete_core.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/unit/autocomplete/autocomplete_core.js b/tests/unit/autocomplete/autocomplete_core.js index 2961cb09a..774c84417 100644 --- a/tests/unit/autocomplete/autocomplete_core.js +++ b/tests/unit/autocomplete/autocomplete_core.js @@ -89,6 +89,30 @@ test( "allow form submit on enter when menu is not active", function() { test( "down arrow moves focus - contenteditable", function() { arrowsMoveFocus( "#autocomplete-contenteditable", false ); }); + + test( "up arrow moves cursor - input", function() { + arrowsNavigateElement( "#autocomplete", true, false ); + }); + + test( "down arrow moves cursor - input", function() { + arrowsNavigateElement( "#autocomplete", false, false ); + }); + + test( "up arrow moves cursor - textarea", function() { + arrowsNavigateElement( "#autocomplete-textarea", true, true ); + }); + + test( "down arrow moves cursor - textarea", function() { + arrowsNavigateElement( "#autocomplete-textarea", false, true ); + }); + + test( "up arrow moves cursor - contenteditable", function() { + arrowsNavigateElement( "#autocomplete-contenteditable", true, true ); + }); + + test( "down arrow moves cursor - contenteditable", function() { + arrowsNavigateElement( "#autocomplete-contenteditable", false, true ); + }); function arrowsInvokeSearch( id, isKeyUp, shouldMove ) { expect( 1 ); @@ -120,6 +144,23 @@ test( "allow form submit on enter when menu is not active", function() { element.autocomplete( "search" ); element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } ); } + + function arrowsNavigateElement( id, isKeyUp, shouldMove ) { + expect( 1 ); + + var didMove = false, + element = $( id ).autocomplete({ + source: [ "a" ], + delay: 0, + minLength: 0 + }); + element.on( "keypress", function( e ) { + didMove = !e.isDefaultPrevented(); + }); + element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } ); + element.simulate( "keypress" ); + equal( didMove, shouldMove, "respond to arrow" ); + } })(); asyncTest( "handle race condition", function() { |