@@ -97,32 +97,26 @@ test( "appendTo", function() {
97
97
ac . autocomplete ( "destroy" ) ;
98
98
} ) ;
99
99
100
- test ( "autoFocus: false" , function ( ) {
100
+ function autoFocusTest ( afValue , focusedLength ) {
101
101
var ac = $ ( "#autocomplete" ) . autocomplete ( {
102
- autoFocus : false ,
102
+ autoFocus : afValue ,
103
103
delay : 0 ,
104
104
source : data ,
105
105
open : function ( event , ui ) {
106
- equals ( 0 , ac . autocomplete ( "widget" ) . children ( ".ui-menu-item:first .ui-state-focus" ) . length , "first item is not auto focused" ) ;
106
+ equals ( focusedLength , ac . autocomplete ( "widget" ) . children ( ".ui-menu-item:first .ui-state-focus" ) . length , "first item is " + afValue ? "" : " not" + " auto focused" ) ;
107
107
start ( ) ;
108
108
}
109
109
} ) ;
110
110
ac . val ( "ja" ) . keydown ( ) ;
111
111
stop ( ) ;
112
+ }
113
+
114
+ test ( "autoFocus: false" , function ( ) {
115
+ autoFocusTest ( false , 0 ) ;
112
116
} ) ;
113
117
114
118
test ( "autoFocus: true" , function ( ) {
115
- var ac = $ ( "#autocomplete" ) . autocomplete ( {
116
- autoFocus : true ,
117
- delay : 0 ,
118
- source : data ,
119
- open : function ( event , ui ) {
120
- equals ( 1 , ac . autocomplete ( "widget" ) . children ( ".ui-menu-item:first .ui-state-focus" ) . length , "first item is auto focused" ) ;
121
- start ( ) ;
122
- }
123
- } ) ;
124
- ac . val ( "ja" ) . keydown ( ) ;
125
- stop ( ) ;
119
+ autoFocusTest ( true , 1 ) ;
126
120
} ) ;
127
121
128
122
test ( "delay" , function ( ) {
0 commit comments