aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/autocomplete/autocomplete_events.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-03-22 14:07:49 -0400
committerScott González <scott.gonzalez@gmail.com>2011-03-22 14:07:49 -0400
commite7991e33f3c5d20d6efdb18654859175ef5cac68 (patch)
tree882f97c0b9a10d2f6cdb60e65a081aed8b4975e8 /tests/unit/autocomplete/autocomplete_events.js
parentde5a98e7bcb841d3b5304dd085ad300f4848a220 (diff)
downloadjquery-ui-e7991e33f3c5d20d6efdb18654859175ef5cac68.tar.gz
jquery-ui-e7991e33f3c5d20d6efdb18654859175ef5cac68.zip
Autocomplete: Added response event. Fixes #6777 - Autocomplete callback when search is complete.
Diffstat (limited to 'tests/unit/autocomplete/autocomplete_events.js')
-rw-r--r--tests/unit/autocomplete/autocomplete_events.js40
1 files changed, 29 insertions, 11 deletions
diff --git a/tests/unit/autocomplete/autocomplete_events.js b/tests/unit/autocomplete/autocomplete_events.js
index aa0a17730..35103d89b 100644
--- a/tests/unit/autocomplete/autocomplete_events.js
+++ b/tests/unit/autocomplete/autocomplete_events.js
@@ -9,10 +9,10 @@ module("autocomplete: events", {
}
});
-var data = ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl"];
+var data = [ "Clojure", "COBOL", "ColdFusion", "Java", "JavaScript", "Scala", "Scheme" ];
test("all events", function() {
- expect(12);
+ expect(14);
var ac = $("#autocomplete").autocomplete({
autoFocus: false,
delay: 0,
@@ -20,12 +20,21 @@ test("all events", function() {
search: function(event) {
same(event.type, "autocompletesearch");
},
+ response: function(event, ui) {
+ same(event.type, "autocompleteresponse");
+ same(ui.content, [
+ { label: "Clojure", value: "Clojure" },
+ { label: "Java", value: "Java" },
+ { label: "JavaScript", value: "JavaScript" }
+ ]);
+ ui.content.splice( 0, 1 );
+ },
open: function(event) {
same(event.type, "autocompleteopen");
},
focus: function(event, ui) {
same(event.type, "autocompletefocus");
- same(ui.item, {label:"java", value:"java"});
+ same(ui.item, {label:"Java", value:"Java"});
},
close: function(event) {
same(event.type, "autocompleteclose");
@@ -33,17 +42,17 @@ test("all events", function() {
},
select: function(event, ui) {
same(event.type, "autocompleteselect");
- same(ui.item, {label:"java", value:"java"});
+ same(ui.item, {label:"Java", value:"Java"});
},
change: function(event, ui) {
same(event.type, "autocompletechange");
- same(ui.item, {label:"java", value:"java"});
+ same(ui.item, {label:"Java", value:"Java"});
same( $(".ui-menu:visible").length, 0 );
start();
}
});
stop();
- ac.focus().val("ja").keydown();
+ ac.focus().val("j").keydown();
setTimeout(function() {
same( $(".ui-menu:visible").length, 1 );
ac.simulate("keydown", { keyCode: $.ui.keyCode.DOWN });
@@ -55,7 +64,7 @@ test("all events", function() {
});
test("all events - contenteditable", function() {
- expect(12);
+ expect(14);
var ac = $("#autocomplete-contenteditable").autocomplete({
autoFocus: false,
delay: 0,
@@ -63,12 +72,21 @@ test("all events - contenteditable", function() {
search: function(event) {
same(event.type, "autocompletesearch");
},
+ response: function(event, ui) {
+ same(event.type, "autocompleteresponse");
+ same(ui.content, [
+ { label: "Clojure", value: "Clojure" },
+ { label: "Java", value: "Java" },
+ { label: "JavaScript", value: "JavaScript" }
+ ]);
+ ui.content.splice( 0, 1 );
+ },
open: function(event) {
same(event.type, "autocompleteopen");
},
focus: function(event, ui) {
same(event.type, "autocompletefocus");
- same(ui.item, {label:"java", value:"java"});
+ same(ui.item, {label:"Java", value:"Java"});
},
close: function(event) {
same(event.type, "autocompleteclose");
@@ -76,17 +94,17 @@ test("all events - contenteditable", function() {
},
select: function(event, ui) {
same(event.type, "autocompleteselect");
- same(ui.item, {label:"java", value:"java"});
+ same(ui.item, {label:"Java", value:"Java"});
},
change: function(event, ui) {
same(event.type, "autocompletechange");
- same(ui.item, {label:"java", value:"java"});
+ same(ui.item, {label:"Java", value:"Java"});
same( $(".ui-menu:visible").length, 0 );
start();
}
});
stop();
- ac.focus().text("ja").keydown();
+ ac.focus().text("j").keydown();
setTimeout(function() {
same( $(".ui-menu:visible").length, 1 );
ac.simulate("keydown", { keyCode: $.ui.keyCode.DOWN });