From ac86d4c6db2001c357590501d81d112f2c7e09d2 Mon Sep 17 00:00:00 2001 From: Paul Bakaus Date: Wed, 30 Jul 2008 18:13:58 +0000 Subject: [PATCH] autocomplete: added init/destroy tests --- tests/autocomplete.html | 2 ++ tests/autocomplete.js | 45 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/tests/autocomplete.html b/tests/autocomplete.html index 86d77e228..609e536f8 100644 --- a/tests/autocomplete.html +++ b/tests/autocomplete.html @@ -19,6 +19,8 @@

jQuery - Autocomplete Test Suite

    diff --git a/tests/autocomplete.js b/tests/autocomplete.js index b3d36cb5a..2196e96f9 100644 --- a/tests/autocomplete.js +++ b/tests/autocomplete.js @@ -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'); + + $("").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>" );