2011-06-13 18:09:44 +00:00
|
|
|
(function( $ ) {
|
2010-01-20 14:00:14 +00:00
|
|
|
|
2011-06-13 18:09:44 +00:00
|
|
|
module( "autocomplete: methods" );
|
2010-01-20 14:00:14 +00:00
|
|
|
|
2011-06-13 18:09:44 +00:00
|
|
|
test( "destroy", function() {
|
|
|
|
expect( 1 );
|
|
|
|
domEqual( "#autocomplete", function() {
|
|
|
|
$( "#autocomplete" ).autocomplete().autocomplete( "destroy" );
|
|
|
|
});
|
2010-03-11 03:28:00 +00:00
|
|
|
});
|
2010-01-20 14:00:14 +00:00
|
|
|
|
2012-01-31 19:21:18 +00:00
|
|
|
test( "search, close", function() {
|
|
|
|
expect( 6 );
|
2011-06-13 18:09:44 +00:00
|
|
|
var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl" ],
|
|
|
|
element = $( "#autocomplete" ).autocomplete({
|
|
|
|
source: data,
|
|
|
|
minLength: 0
|
|
|
|
}),
|
|
|
|
menu = element.autocomplete( "widget" );
|
2012-01-31 19:21:18 +00:00
|
|
|
|
|
|
|
ok( menu.is( ":hidden" ), "menu is hidden on init" );
|
|
|
|
|
2011-06-13 18:09:44 +00:00
|
|
|
element.autocomplete( "search" );
|
2012-01-31 19:21:18 +00:00
|
|
|
ok( menu.is( ":visible" ), "menu is visible after search" );
|
2011-06-13 18:09:44 +00:00
|
|
|
equal( menu.find( ".ui-menu-item" ).length, data.length, "all items for a blank search" );
|
2010-01-20 14:00:14 +00:00
|
|
|
|
2011-06-13 18:09:44 +00:00
|
|
|
element.val( "has" ).autocomplete( "search" );
|
|
|
|
equal( menu.find( ".ui-menu-item" ).text(), "haskell", "only one item for set input value" );
|
2010-01-20 14:00:14 +00:00
|
|
|
|
2011-06-13 18:09:44 +00:00
|
|
|
element.autocomplete( "search", "ja" );
|
|
|
|
equal( menu.find( ".ui-menu-item" ).length, 2, "only java and javascript for 'ja'" );
|
2012-01-31 19:21:18 +00:00
|
|
|
|
|
|
|
element.autocomplete( "close" );
|
|
|
|
ok( menu.is( ":hidden" ), "menu is hidden after close" );
|
2011-06-13 18:09:44 +00:00
|
|
|
});
|
2010-01-20 14:00:14 +00:00
|
|
|
|
2011-06-13 18:09:44 +00:00
|
|
|
}( jQuery ) );
|