Skip to content
Permalink
Browse files

Autocomplete: Added a test for exceeding minLength, then falling belo…

…w, then exceeding again.
  • Loading branch information
scottgonzalez committed Feb 15, 2012
1 parent 9095938 commit f262a531fa0978c3aaa0cc1c0a75cb1b8fec0155
Showing with 28 additions and 7 deletions.
  1. +28 −7 tests/unit/autocomplete/autocomplete_options.js
@@ -127,13 +127,34 @@ asyncTest( "minLength, exceed then drop below", function() {
}, 50 );
});

// TODO: figure out how to implement this test
// When fixing #7523, I couldn't figure out a test that would fail when
// calling .close() (instead of ._close()) from ._response().
// Use the remote demo and type "je", delete, "a", you should get results for "ja"
// but if we call .close() from ._response() the results are ignored.
//asyncTest( "minLength, exceed then drop below", function() {
//});
test( "minLength, exceed then drop below then exceed", function() {
expect( 3 );
var _res = [],
element = $( "#autocomplete" ).autocomplete({
minLength: 2,
source: function( req, res ) {
_res.push( res );
}
}),
menu = element.autocomplete( "widget" );

// trigger a valid search
ok( menu.is( ":hidden" ), "menu is hidden before first search" );
element.autocomplete( "search", "12" );

// trigger a search below the minLength, to turn on cancelSearch flag
ok( menu.is( ":hidden" ), "menu is hidden before second search" );
element.autocomplete( "search", "1" );

// trigger a valid search
element.autocomplete( "search", "13" );
// react as if the first search was cancelled (default ajax behavior)
_res[ 0 ]([]);
// react to second search
_res[ 1 ]([ "13" ]);

ok( menu.is( ":visible" ), "menu is visible after searches" );
});

test( "source, local string array", function() {
expect( 1 );

0 comments on commit f262a53

Please sign in to comment.
You can’t perform that action at this time.