2010-01-20 14:00:14 +00:00
|
|
|
/*
|
|
|
|
* autocomplete_methods.js
|
|
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
|
2010-03-11 03:28:00 +00:00
|
|
|
module("autocomplete: methods", {
|
|
|
|
teardown: function() {
|
|
|
|
$( ":ui-autocomplete" ).autocomplete( "destroy" );
|
|
|
|
}
|
|
|
|
});
|
2010-01-20 14:00:14 +00:00
|
|
|
|
|
|
|
test("destroy", function() {
|
2011-02-25 10:33:48 +00:00
|
|
|
domEqual("#autocomplete", function() {
|
|
|
|
$("#autocomplete").autocomplete().autocomplete("destroy");
|
|
|
|
});
|
2010-01-20 14:00:14 +00:00
|
|
|
})
|
|
|
|
|
2010-03-20 14:37:18 +00:00
|
|
|
var data = ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl"];
|
2010-01-20 14:00:14 +00:00
|
|
|
|
|
|
|
test("search", function() {
|
|
|
|
var ac = $("#autocomplete").autocomplete({
|
|
|
|
source: data,
|
|
|
|
minLength: 0
|
|
|
|
});
|
|
|
|
ac.autocomplete("search");
|
|
|
|
same( $(".ui-menu .ui-menu-item").length, data.length, "all items for a blank search" );
|
|
|
|
|
|
|
|
ac.val("has");
|
|
|
|
ac.autocomplete("search")
|
|
|
|
same( $(".ui-menu .ui-menu-item").text(), "haskell", "only one item for set input value" );
|
|
|
|
|
|
|
|
ac.autocomplete("search", "ja");
|
|
|
|
same( $(".ui-menu .ui-menu-item").length, 2, "only java and javascript for 'ja'" );
|
|
|
|
|
|
|
|
$("#autocomplete").autocomplete("destroy");
|
2010-07-30 16:38:18 +00:00
|
|
|
})
|
2010-01-20 14:00:14 +00:00
|
|
|
|
|
|
|
})(jQuery);
|