]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete tests: Cleanup.
authorScott González <scott.gonzalez@gmail.com>
Tue, 30 Apr 2013 14:27:22 +0000 (10:27 -0400)
committerScott González <scott.gonzalez@gmail.com>
Mon, 25 Nov 2013 22:29:43 +0000 (17:29 -0500)
(cherry picked from commit 7af03b73ea0786de9361f3cd21ef46047cb957d7)

tests/unit/autocomplete/autocomplete.html
tests/unit/autocomplete/autocomplete_options.js

index 571c62033e01fb9c2c3ff23b72c9eafd7014fad0..8c7b5b698abb710e1e8e7d2125017363f9b0ddcf 100644 (file)
@@ -39,8 +39,8 @@
 <ol id="qunit-tests"></ol>
 <div id="qunit-fixture">
 
-<div id="ac-wrap1" class="ac-wrap"></div>
-<div id="ac-wrap2" class="ac-wrap"><input id="autocomplete" class="foo"></div>
+<div id="autocomplete-wrap1" class="autocomplete-wrap"></div>
+<div id="autocomplete-wrap2" class="autocomplete-wrap"><input id="autocomplete" class="foo"></div>
 <div id="autocomplete-contenteditable" contenteditable="" tabindex=0></div>
 <textarea id="autocomplete-textarea"></textarea>
 
index 9f0bd2d43f211b6e6775655c9946c1eb56da66ac..0a2e07bf6b497eea47df4e081227412164d1ff24 100644 (file)
@@ -2,46 +2,55 @@
 
 module( "autocomplete: options" );
 
-var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl" ];
+var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby",
+       "python", "c", "scala", "groovy", "haskell", "perl" ];
 
 test( "appendTo", function() {
        expect( 8 );
        var detached = $( "<div>" ),
                element = $( "#autocomplete" ).autocomplete();
-       equal( element.autocomplete( "widget" ).parent()[0], document.body, "defaults to body" );
+       equal( element.autocomplete( "widget" ).parent()[ 0 ], document.body,
+               "defaults to body" );
        element.autocomplete( "destroy" );
 
        element.autocomplete({
-               appendTo: ".ac-wrap"
+               appendTo: ".autocomplete-wrap"
        });
-       equal( element.autocomplete( "widget" ).parent()[0], $( "#ac-wrap1" )[0], "first found element" );
-       equal( $( "#ac-wrap2 .ui-autocomplete" ).length, 0, "only appends to one element" );
+       equal( element.autocomplete( "widget" ).parent()[ 0 ],
+               $( "#autocomplete-wrap1" )[ 0 ], "first found element" );
+       equal( $( "#autocomplete-wrap2 .ui-autocomplete" ).length, 0,
+               "only appends to one element" );
        element.autocomplete( "destroy" );
 
-       $( "#ac-wrap2" ).addClass( "ui-front" );
+       $( "#autocomplete-wrap2" ).addClass( "ui-front" );
        element.autocomplete();
-       equal( element.autocomplete( "widget" ).parent()[0], $( "#ac-wrap2" )[0], "null, inside .ui-front" );
+       equal( element.autocomplete( "widget" ).parent()[ 0 ],
+               $( "#autocomplete-wrap2" )[ 0 ], "null, inside .ui-front" );
        element.autocomplete( "destroy" );
-       $( "#ac-wrap2" ).removeClass( "ui-front" );
+       $( "#autocomlete-wrap2" ).removeClass( "ui-front" );
 
-       element.autocomplete().autocomplete( "option", "appendTo", "#ac-wrap1" );
-       equal( element.autocomplete( "widget" ).parent()[0], $( "#ac-wrap1" )[0], "modified after init" );
+       element.autocomplete().autocomplete( "option", "appendTo", "#autocomplete-wrap1" );
+       equal( element.autocomplete( "widget" ).parent()[ 0 ],
+               $( "#autocomplete-wrap1" )[ 0 ], "modified after init" );
        element.autocomplete( "destroy" );
 
        element.autocomplete({
                appendTo: detached
        });
-       equal( element.autocomplete( "widget" ).parent()[0], detached[0], "detached jQuery object" );
+       equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ],
+               "detached jQuery object" );
        element.autocomplete( "destroy" );
 
        element.autocomplete({
-               appendTo: detached[0]
+               appendTo: detached[ 0 ]
        });
-       equal( element.autocomplete( "widget" ).parent()[0], detached[0], "detached DOM element" );
+       equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ],
+               "detached DOM element" );
        element.autocomplete( "destroy" );
 
        element.autocomplete().autocomplete( "option", "appendTo", detached );
-       equal( element.autocomplete( "widget" ).parent()[0], detached[0], "detached DOM element via option()" );
+       equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ],
+               "detached DOM element via option()" );
        element.autocomplete( "destroy" );
 });
 
@@ -51,8 +60,13 @@ function autoFocusTest( afValue, focusedLength ) {
                delay: 0,
                source: data,
                open: function() {
-                       equal( element.autocomplete( "widget" ).children( ".ui-menu-item:first" ).find( ".ui-state-focus" ).length,
-                               focusedLength, "first item is " + (afValue ? "" : "not") + " auto focused" );
+                       equal(
+                               element.autocomplete( "widget" )
+                                       .children( ".ui-menu-item:first" )
+                                       .find( ".ui-state-focus" )
+                                       .length,
+                               focusedLength,
+                               "first item is " + (afValue ? "" : "not") + " auto focused" );
                        start();
                }
        });