aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-08-30 20:45:48 -0400
committerScott González <scott.gonzalez@gmail.com>2011-08-30 20:45:48 -0400
commitc5ba0535cf8fad222bf54249fb74339faafa9310 (patch)
treef0689df45e10bf9e95adcdd0a9c7d52d9a0b305f /tests/unit
parent87f78973b919130880a42651596edbae0b2a7741 (diff)
downloadjquery-ui-c5ba0535cf8fad222bf54249fb74339faafa9310.tar.gz
jquery-ui-c5ba0535cf8fad222bf54249fb74339faafa9310.zip
Autocomplete: Fixed setting of valueMethod for textareas. Fixes #7674 - Autocomplete doesn't work with textareas.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/autocomplete/autocomplete.html1
-rw-r--r--tests/unit/autocomplete/autocomplete_events.js173
2 files changed, 70 insertions, 104 deletions
diff --git a/tests/unit/autocomplete/autocomplete.html b/tests/unit/autocomplete/autocomplete.html
index 8dc86c621..e5987350b 100644
--- a/tests/unit/autocomplete/autocomplete.html
+++ b/tests/unit/autocomplete/autocomplete.html
@@ -39,6 +39,7 @@
<div id="ac-wrap1" class="ac-wrap"></div>
<div id="ac-wrap2" class="ac-wrap"><input id="autocomplete" class="foo"></div>
<div id="autocomplete-contenteditable" contenteditable="" tabindex=0></div>
+<textarea id="autocomplete-textarea"></textarea>
</div>
</body>
diff --git a/tests/unit/autocomplete/autocomplete_events.js b/tests/unit/autocomplete/autocomplete_events.js
index c6d42ddcc..6813cfa71 100644
--- a/tests/unit/autocomplete/autocomplete_events.js
+++ b/tests/unit/autocomplete/autocomplete_events.js
@@ -4,110 +4,75 @@ module( "autocomplete: events" );
var data = [ "Clojure", "COBOL", "ColdFusion", "Java", "JavaScript", "Scala", "Scheme" ];
-asyncTest( "all events", function() {
- expect( 13 );
- var element = $( "#autocomplete" )
- .autocomplete({
- autoFocus: false,
- delay: 0,
- source: data,
- search: function( event ) {
- equal( event.originalEvent.type, "keydown", "search originalEvent" );
- },
- response: function( event, ui ) {
- deepEqual( ui.content, [
- { label: "Clojure", value: "Clojure" },
- { label: "Java", value: "Java" },
- { label: "JavaScript", value: "JavaScript" }
- ], "response ui.content" );
- ui.content.splice( 0, 1 );
- },
- open: function( event ) {
- ok( menu.is( ":visible" ), "menu open on open" );
- },
- focus: function( event, ui ) {
- equal( event.originalEvent.type, "menufocus", "focus originalEvent" );
- deepEqual( ui.item, { label: "Java", value: "Java" }, "focus ui.item" );
- },
- close: function( event ) {
- equal( event.originalEvent.type, "menuselect", "close originalEvent" );
- ok( menu.is( ":hidden" ), "menu closed on close" );
- },
- select: function( event, ui ) {
- equal( event.originalEvent.type, "menuselect", "select originalEvent" );
- deepEqual( ui.item, { label: "Java", value: "Java" }, "select ui.item" );
- },
- change: function( event, ui ) {
- equal( event.originalEvent.type, "blur", "change originalEvent" );
- deepEqual( ui.item, { label: "Java", value: "Java" }, "chnage ui.item" );
- ok( menu.is( ":hidden" ), "menu closed on change" );
- start();
- }
- }),
- menu = element.autocomplete( "widget" );
-
- element.focus().val( "j" ).keydown();
- setTimeout(function() {
- ok( menu.is( ":visible" ), "menu is visible after delay" );
- element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- // blurring through jQuery causes a bug in IE 6 which causes the
- // autocompletechange event to occur twice
- element[0].blur();
- }, 50 );
-});
-
-asyncTest( "all events - contenteditable", function() {
- expect( 13 );
- var element = $( "#autocomplete-contenteditable" )
- .autocomplete({
- autoFocus: false,
- delay: 0,
- source: data,
- search: function( event ) {
- equal( event.originalEvent.type, "keydown", "search originalEvent" );
- },
- response: function( event, ui ) {
- deepEqual( ui.content, [
- { label: "Clojure", value: "Clojure" },
- { label: "Java", value: "Java" },
- { label: "JavaScript", value: "JavaScript" }
- ], "response ui.content" );
- ui.content.splice( 0, 1 );
- },
- open: function( event ) {
- ok( menu.is( ":visible" ), "menu open on open" );
- },
- focus: function( event, ui ) {
- equal( event.originalEvent.type, "menufocus", "focus originalEvent" );
- deepEqual( ui.item, { label: "Java", value: "Java" }, "focus ui.item" );
- },
- close: function( event ) {
- equal( event.originalEvent.type, "menuselect", "close originalEvent" );
- ok( menu.is( ":hidden" ), "menu closed on close" );
- },
- select: function( event, ui ) {
- equal( event.originalEvent.type, "menuselect", "select originalEvent" );
- deepEqual( ui.item, { label: "Java", value: "Java" }, "select ui.item" );
- },
- change: function( event, ui ) {
- equal( event.originalEvent.type, "blur", "change originalEvent" );
- deepEqual( ui.item, { label: "Java", value: "Java" }, "chnage ui.item" );
- ok( menu.is( ":hidden" ), "menu closed on change" );
- start();
- }
- }),
- menu = element.autocomplete( "widget" );
-
- element.focus().text( "j" ).keydown();
- setTimeout(function() {
- ok( menu.is( ":visible" ), "menu is visible after delay" );
- element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- // TODO: blurring through jQuery causes a bug in IE 6 which causes the
- // autocompletechange event to occur twice
- element[0].blur();
- }, 50 );
+$.each([
+ {
+ type: "input",
+ selector: "#autocomplete",
+ valueMethod: "val"
+ },
+ {
+ type: "textarea",
+ selector: "#autocomplete-textarea",
+ valueMethod: "val"
+ },
+ {
+ type: "contenteditable",
+ selector: "#autocomplete-contenteditable",
+ valueMethod: "text"
+ }
+], function( i, settings ) {
+ asyncTest( "all events - " + settings.type, function() {
+ expect( 13 );
+ var element = $( settings.selector )
+ .autocomplete({
+ autoFocus: false,
+ delay: 0,
+ source: data,
+ search: function( event ) {
+ equal( event.originalEvent.type, "keydown", "search originalEvent" );
+ },
+ response: function( event, ui ) {
+ deepEqual( ui.content, [
+ { label: "Clojure", value: "Clojure" },
+ { label: "Java", value: "Java" },
+ { label: "JavaScript", value: "JavaScript" }
+ ], "response ui.content" );
+ ui.content.splice( 0, 1 );
+ },
+ open: function( event ) {
+ ok( menu.is( ":visible" ), "menu open on open" );
+ },
+ focus: function( event, ui ) {
+ equal( event.originalEvent.type, "menufocus", "focus originalEvent" );
+ deepEqual( ui.item, { label: "Java", value: "Java" }, "focus ui.item" );
+ },
+ close: function( event ) {
+ equal( event.originalEvent.type, "menuselect", "close originalEvent" );
+ ok( menu.is( ":hidden" ), "menu closed on close" );
+ },
+ select: function( event, ui ) {
+ equal( event.originalEvent.type, "menuselect", "select originalEvent" );
+ deepEqual( ui.item, { label: "Java", value: "Java" }, "select ui.item" );
+ },
+ change: function( event, ui ) {
+ equal( event.originalEvent.type, "blur", "change originalEvent" );
+ deepEqual( ui.item, { label: "Java", value: "Java" }, "chnage ui.item" );
+ ok( menu.is( ":hidden" ), "menu closed on change" );
+ start();
+ }
+ }),
+ menu = element.autocomplete( "widget" );
+
+ element.focus()[ settings.valueMethod ]( "j" ).keydown();
+ setTimeout(function() {
+ ok( menu.is( ":visible" ), "menu is visible after delay" );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
+ // blurring through jQuery causes a bug in IE 6 which causes the
+ // autocompletechange event to occur twice
+ element[0].blur();
+ }, 50 );
+ });
});
asyncTest( "change without selection", function() {