From 2ef1b16e4d3aa8766084e50f4a1d806c434e7e43 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 20 Jan 2014 16:13:55 -0500 Subject: Autocomplete: Fall back to .ui-front searching for empty jQuery objects Fixes #9755 --- tests/unit/autocomplete/autocomplete_options.js | 37 +++++++++++++++++-------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'tests/unit/autocomplete') diff --git a/tests/unit/autocomplete/autocomplete_options.js b/tests/unit/autocomplete/autocomplete_options.js index e6f08785b..fee37aee4 100644 --- a/tests/unit/autocomplete/autocomplete_options.js +++ b/tests/unit/autocomplete/autocomplete_options.js @@ -5,13 +5,18 @@ module( "autocomplete: options" ); var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl" ]; -test( "appendTo", function() { - expect( 8 ); - var detached = $( "
" ), - element = $( "#autocomplete" ).autocomplete(); +test( "appendTo: null", function() { + expect( 1 ); + var element = $( "#autocomplete" ).autocomplete(); equal( element.autocomplete( "widget" ).parent()[ 0 ], document.body, "defaults to body" ); element.autocomplete( "destroy" ); +}); + +test( "appendTo: explicit", function() { + expect( 6 ); + var detached = $( "
" ), + element = $( "#autocomplete" ); element.autocomplete({ appendTo: ".autocomplete-wrap" @@ -22,13 +27,6 @@ test( "appendTo", function() { "only appends to one element" ); element.autocomplete( "destroy" ); - $( "#autocomplete-wrap2" ).addClass( "ui-front" ); - element.autocomplete(); - equal( element.autocomplete( "widget" ).parent()[ 0 ], - $( "#autocomplete-wrap2" )[ 0 ], "null, inside .ui-front" ); - element.autocomplete( "destroy" ); - $( "#autocomlete-wrap2" ).removeClass( "ui-front" ); - element.autocomplete().autocomplete( "option", "appendTo", "#autocomplete-wrap1" ); equal( element.autocomplete( "widget" ).parent()[ 0 ], $( "#autocomplete-wrap1" )[ 0 ], "modified after init" ); @@ -54,6 +52,23 @@ test( "appendTo", function() { element.autocomplete( "destroy" ); }); +test( "appendTo: ui-front", function() { + expect( 2 ); + var element = $( "#autocomplete" ); + + $( "#autocomplete-wrap2" ).addClass( "ui-front" ); + element.autocomplete(); + equal( element.autocomplete( "widget" ).parent()[ 0 ], + $( "#autocomplete-wrap2" )[ 0 ], "null, inside .ui-front" ); + element.autocomplete( "destroy" ); + + element.autocomplete({ + appendTo: $() + }); + equal( element.autocomplete( "widget" ).parent()[ 0 ], + $( "#autocomplete-wrap2" )[ 0 ], "null, inside .ui-front" ); +}); + function autoFocusTest( afValue, focusedLength ) { var element = $( "#autocomplete" ).autocomplete({ autoFocus: afValue, -- cgit v1.2.3