jquery-ui/tests/unit/autocomplete/autocomplete_methods.js

31 lines
941 B
JavaScript
Raw Normal View History

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-01-20 14:00:14 +00:00
2011-06-13 18:09:44 +00:00
test( "search", function() {
expect( 3 );
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" );
element.autocomplete( "search" );
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'" );
});
2010-01-20 14:00:14 +00:00
2011-06-13 18:09:44 +00:00
}( jQuery ) );