test("init", function() { expect(6); el = $("#autocomplete").autocomplete(); ok(true, '.autocomplete() called on element'); $([]).autocomplete(); ok(true, '.autocomplete() called on empty collection'); $("").autocomplete(); ok(true, '.autocomplete() called on disconnected DOMElement'); $("").autocomplete().autocomplete("foo"); ok(true, 'arbitrary method called after init'); $("").autocomplete().data("foo.autocomplete"); ok(true, 'arbitrary option getter after init'); $("").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'); $("").autocomplete().autocomplete("destroy"); ok(true, '.autocomplete("destroy") called on disconnected DOMElement'); $("").autocomplete().autocomplete("destroy").autocomplete("foo"); ok(true, 'arbitrary method called after destroy'); $("").autocomplete().autocomplete("destroy").data("foo.autocomplete"); ok(true, 'arbitrary option getter after destroy'); $("").autocomplete().autocomplete("destroy").data("foo.autocomplete", "bar"); ok(true, 'arbitrary option setter after destroy'); }); test("highlighter", function() { equals( jQuery.Autocompleter.defaults.highlight("Peter", "Pe"), "Peter" ); equals( jQuery.Autocompleter.defaults.highlight("Peter <Pan>", "Pe"), "Peter <Pan>" ); equals( jQuery.Autocompleter.defaults.highlight("Peter <Pan>", "a"), "Peter <Pan>" ); equals( jQuery.Autocompleter.defaults.highlight("Peter (<Pan>)", "(<P"), "Peter (<Pan>)" ); });