diff options
author | jzaefferer <joern.zaefferer@gmail.com> | 2010-04-08 12:05:52 +0200 |
---|---|---|
committer | jzaefferer <joern.zaefferer@gmail.com> | 2010-04-08 12:05:52 +0200 |
commit | c01b3baef97808a3a7dfafaea084c03a27e92564 (patch) | |
tree | 1f16a1304e620f012081b6f3f6f49a9107ea8c50 /tests/unit/autocomplete | |
parent | 10ea61be5644dc10fa2e11179458ca05b85eb5bc (diff) | |
download | jquery-ui-c01b3baef97808a3a7dfafaea084c03a27e92564.tar.gz jquery-ui-c01b3baef97808a3a7dfafaea084c03a27e92564.zip |
Autocomplete: Track input changes and fire change-event on blur, along with selected item, if available. Fix for #5490
Diffstat (limited to 'tests/unit/autocomplete')
-rw-r--r-- | tests/unit/autocomplete/autocomplete_events.js | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/tests/unit/autocomplete/autocomplete_events.js b/tests/unit/autocomplete/autocomplete_events.js index ccbe66c1b..28a72145e 100644 --- a/tests/unit/autocomplete/autocomplete_events.js +++ b/tests/unit/autocomplete/autocomplete_events.js @@ -12,7 +12,7 @@ module("autocomplete: events", { var data = ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl"]; test("all events", function() { - expect(11); + expect(12); var ac = $("#autocomplete").autocomplete({ delay: 0, source: data, @@ -34,21 +34,38 @@ test("all events", function() { same(event.type, "autocompleteselect"); same(ui.item, {label:"java", value:"java"}); }, - change: function(event) { + change: function(event, ui) { same(event.type, "autocompletechange"); + same(ui.item, {label:"java", value:"java"}); same( $(".ui-menu:visible").length, 0 ); + start(); } }); stop(); - ac.val("ja").keydown(); + ac.focus().val("ja").keydown(); setTimeout(function() { same( $(".ui-menu:visible").length, 1 ); ac.simulate("keydown", { keyCode: $.ui.keyCode.DOWN }); ac.simulate("keydown", { keyCode: $.ui.keyCode.ENTER }); - start(); + ac.blur(); }, 50); }); +test("change without selection", function() { + expect(2); + stop(); + var ac = $("#autocomplete").autocomplete({ + delay: 0, + source: data, + change: function(event, ui) { + same(event.type, "autocompletechange"); + same(ui.item, null); + start(); + } + }); + ac.focus().val("ja").blur(); +}); + test("cancel search", function() { expect(6); var first = true; |