@@ -127,13 +127,34 @@ asyncTest( "minLength, exceed then drop below", function() {
127127 } , 50 ) ;
128128} ) ;
129129
130- // TODO: figure out how to implement this test
131- // When fixing #7523, I couldn't figure out a test that would fail when
132- // calling .close() (instead of ._close()) from ._response().
133- // Use the remote demo and type "je", delete, "a", you should get results for "ja"
134- // but if we call .close() from ._response() the results are ignored.
135- //asyncTest( "minLength, exceed then drop below", function() {
136- //});
130+ test ( "minLength, exceed then drop below then exceed" , function ( ) {
131+ expect ( 3 ) ;
132+ var _res = [ ] ,
133+ element = $ ( "#autocomplete" ) . autocomplete ( {
134+ minLength : 2 ,
135+ source : function ( req , res ) {
136+ _res . push ( res ) ;
137+ }
138+ } ) ,
139+ menu = element . autocomplete ( "widget" ) ;
140+
141+ // trigger a valid search
142+ ok ( menu . is ( ":hidden" ) , "menu is hidden before first search" ) ;
143+ element . autocomplete ( "search" , "12" ) ;
144+
145+ // trigger a search below the minLength, to turn on cancelSearch flag
146+ ok ( menu . is ( ":hidden" ) , "menu is hidden before second search" ) ;
147+ element . autocomplete ( "search" , "1" ) ;
148+
149+ // trigger a valid search
150+ element . autocomplete ( "search" , "13" ) ;
151+ // react as if the first search was cancelled (default ajax behavior)
152+ _res [ 0 ] ( [ ] ) ;
153+ // react to second search
154+ _res [ 1 ] ( [ "13" ] ) ;
155+
156+ ok ( menu . is ( ":visible" ) , "menu is visible after searches" ) ;
157+ } ) ;
137158
138159test ( "source, local string array" , function ( ) {
139160 expect ( 1 ) ;
0 commit comments