]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete: added unit tests for autoFocus. Fixed #7032 - Autocomplete: Add option...
authorRichard Worth <rdworth@gmail.com>
Tue, 15 Mar 2011 12:42:28 +0000 (08:42 -0400)
committerRichard Worth <rdworth@gmail.com>
Tue, 15 Mar 2011 12:43:53 +0000 (08:43 -0400)
(cherry picked from commit 56b7ec134d8e1203f700f99dabcdad8c50a9b0c2)

tests/unit/autocomplete/autocomplete_options.js

index 2800fbab84446ef9c76417b78b2dc118ac3efd54..09cfb6b5f1016ddcc9d95e7f39fae8da6664734f 100644 (file)
@@ -97,6 +97,33 @@ test( "appendTo", function() {
        ac.autocomplete( "destroy" );
 });
 
+test( "autoFocus: false", function() {
+       var ac = $( "#autocomplete" ).autocomplete({
+               autoFocus: false,
+               delay: 0,
+               source: data,
+               open: function( event, ui ) {
+                       equals( 0, ac.autocomplete( "widget" ).children( ".ui-menu-item:first .ui-state-focus" ).length, "first item is not auto focused" );
+                       start();                        
+               }
+       });
+       ac.val( "ja" ).keydown();
+       stop();
+});
+
+test( "autoFocus: true", function() {
+       var ac = $( "#autocomplete" ).autocomplete({
+               autoFocus: true,
+               delay: 0,
+               source: data,
+               open: function( event, ui ) {
+                       equals( 1, ac.autocomplete( "widget" ).children( ".ui-menu-item:first .ui-state-focus" ).length, "first item is auto focused" );
+                       start();                        
+               }
+       });
+       ac.val( "ja" ).keydown();
+       stop();
+});
 
 test("delay", function() {
        var ac = $("#autocomplete").autocomplete({