2008-09-20 17:42:04 +00:00
|
|
|
test("init", function() {
|
|
|
|
expect(6);
|
|
|
|
|
|
|
|
el = $("#autocomplete").autocomplete();
|
|
|
|
ok(true, '.autocomplete() called on element');
|
|
|
|
|
|
|
|
$([]).autocomplete();
|
|
|
|
ok(true, '.autocomplete() called on empty collection');
|
|
|
|
|
|
|
|
$("<input/>").autocomplete();
|
|
|
|
ok(true, '.autocomplete() called on disconnected DOMElement');
|
|
|
|
|
|
|
|
$("<input/>").autocomplete().autocomplete("foo");
|
|
|
|
ok(true, 'arbitrary method called after init');
|
|
|
|
|
|
|
|
$("<input/>").autocomplete().data("foo.autocomplete");
|
|
|
|
ok(true, 'arbitrary option getter after init');
|
|
|
|
|
|
|
|
$("<input/>").autocomplete().data("foo.autocomplete", "bar");
|
|
|
|
ok(true, 'arbitrary option setter after init');
|
|
|
|
});
|
|
|
|
|
|
|
|
test("destroy", function() {
|
|
|
|
expect(6);
|
|
|
|
|
|
|
|
$("#autocomplete").autocomplete().autocomplete("destroy");
|
|
|
|
ok(true, '.autocomplete("destroy") called on element');
|
|
|
|
|
|
|
|
$([]).autocomplete().autocomplete("destroy");
|
|
|
|
ok(true, '.autocomplete("destroy") called on empty collection');
|
|
|
|
|
|
|
|
$("<input/>").autocomplete().autocomplete("destroy");
|
|
|
|
ok(true, '.autocomplete("destroy") called on disconnected DOMElement');
|
|
|
|
|
|
|
|
$("<input/>").autocomplete().autocomplete("destroy").autocomplete("foo");
|
|
|
|
ok(true, 'arbitrary method called after destroy');
|
|
|
|
|
|
|
|
$("<input/>").autocomplete().autocomplete("destroy").data("foo.autocomplete");
|
|
|
|
ok(true, 'arbitrary option getter after destroy');
|
|
|
|
|
|
|
|
$("<input/>").autocomplete().autocomplete("destroy").data("foo.autocomplete", "bar");
|
|
|
|
ok(true, 'arbitrary option setter after destroy');
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test("highlighter", function() {
|
|
|
|
equals( jQuery.Autocompleter.defaults.highlight("Peter", "Pe"), "<strong>Pe</strong>ter" );
|
|
|
|
equals( jQuery.Autocompleter.defaults.highlight("Peter <em><Pan></em>", "Pe"), "<strong>Pe</strong>ter <em><Pan></em>" );
|
|
|
|
equals( jQuery.Autocompleter.defaults.highlight("Peter <em><Pan></em>", "a"), "Peter <em><P<strong>a</strong>n></em>" );
|
|
|
|
equals( jQuery.Autocompleter.defaults.highlight("Peter <em>(<Pan>)</em>", "(<P"), "Peter <em><strong>(<P</strong>an>)</em>" );
|
|
|
|
});
|