aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRichard Worth <rdworth@gmail.com>2011-03-15 09:36:36 -0400
committerRichard Worth <rdworth@gmail.com>2011-03-15 09:37:18 -0400
commit1fe58dbf525c614dd1b490a66dad43a1711181ee (patch)
treeba29f6af9b3f5cc0e4eb93ee021f616682ca02e2 /tests
parent218100e7042cdf0a27fd1f3b7a954944878838f9 (diff)
downloadjquery-ui-1fe58dbf525c614dd1b490a66dad43a1711181ee.tar.gz
jquery-ui-1fe58dbf525c614dd1b490a66dad43a1711181ee.zip
Autocomplete: refactored unit tests for autoFocus option
(cherry picked from commit c1a0f2bf6c7155e73e373818c44b06dcbe18c847)
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/autocomplete/autocomplete_options.js22
1 files changed, 8 insertions, 14 deletions
diff --git a/tests/unit/autocomplete/autocomplete_options.js b/tests/unit/autocomplete/autocomplete_options.js
index 09cfb6b5f..be2f28391 100644
--- a/tests/unit/autocomplete/autocomplete_options.js
+++ b/tests/unit/autocomplete/autocomplete_options.js
@@ -97,32 +97,26 @@ test( "appendTo", function() {
ac.autocomplete( "destroy" );
});
-test( "autoFocus: false", function() {
+function autoFocusTest( afValue, focusedLength ) {
var ac = $( "#autocomplete" ).autocomplete({
- autoFocus: false,
+ autoFocus: afValue,
delay: 0,
source: data,
open: function( event, ui ) {
- equals( 0, ac.autocomplete( "widget" ).children( ".ui-menu-item:first .ui-state-focus" ).length, "first item is not auto focused" );
+ equals( focusedLength, ac.autocomplete( "widget" ).children( ".ui-menu-item:first .ui-state-focus" ).length, "first item is " + afValue ? "" : "not" + " auto focused" );
start();
}
});
ac.val( "ja" ).keydown();
stop();
+}
+
+test( "autoFocus: false", function() {
+ autoFocusTest( false, 0 );
});
test( "autoFocus: true", function() {
- var ac = $( "#autocomplete" ).autocomplete({
- autoFocus: true,
- delay: 0,
- source: data,
- open: function( event, ui ) {
- equals( 1, ac.autocomplete( "widget" ).children( ".ui-menu-item:first .ui-state-focus" ).length, "first item is auto focused" );
- start();
- }
- });
- ac.val( "ja" ).keydown();
- stop();
+ autoFocusTest( true, 1 );
});
test("delay", function() {