autocomplete: added init/destroy tests

This commit is contained in:
Paul Bakaus 2008-07-30 18:13:58 +00:00
parent 9b8fccfa4a
commit ac86d4c6db
2 changed files with 47 additions and 0 deletions

View File

@ -19,6 +19,8 @@
<h1>jQuery - Autocomplete Test Suite</h1>
<div id="main" style="display: none">
<input type="text" name="autocomplete" value="" id="autocomplete">
</div>
<ol id="tests"></ol>

View File

@ -1,3 +1,48 @@
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>&lt;Pan&gt;</em>", "Pe"), "<strong>Pe</strong>ter <em>&lt;Pan&gt;</em>" );