@@ -97,32 +97,26 @@ test( "appendTo", function() {
9797 ac . autocomplete ( "destroy" ) ;
9898} ) ;
9999
100- test ( "autoFocus: false" , function ( ) {
100+ function autoFocusTest ( afValue , focusedLength ) {
101101 var ac = $ ( "#autocomplete" ) . autocomplete ( {
102- autoFocus : false ,
102+ autoFocus : afValue ,
103103 delay : 0 ,
104104 source : data ,
105105 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" ) ;
107107 start ( ) ;
108108 }
109109 } ) ;
110110 ac . val ( "ja" ) . keydown ( ) ;
111111 stop ( ) ;
112+ }
113+
114+ test ( "autoFocus: false" , function ( ) {
115+ autoFocusTest ( false , 0 ) ;
112116} ) ;
113117
114118test ( "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 ) ;
126120} ) ;
127121
128122test ( "delay" , function ( ) {
0 commit comments