aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Bakaus <paul.bakaus@googlemail.com>2008-07-30 18:13:58 +0000
committerPaul Bakaus <paul.bakaus@googlemail.com>2008-07-30 18:13:58 +0000
commitac86d4c6db2001c357590501d81d112f2c7e09d2 (patch)
tree4b70961b1c18654e2a20927181c511b98589d9b4 /tests
parent9b8fccfa4a279000fe55458ff00b849558c0cbaf (diff)
downloadjquery-ui-ac86d4c6db2001c357590501d81d112f2c7e09d2.tar.gz
jquery-ui-ac86d4c6db2001c357590501d81d112f2c7e09d2.zip
autocomplete: added init/destroy tests
Diffstat (limited to 'tests')
-rw-r--r--tests/autocomplete.html2
-rw-r--r--tests/autocomplete.js45
2 files changed, 47 insertions, 0 deletions
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 @@
<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>
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');
+
+ $("<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>" );