Skip to content

Commit

Permalink
Autocomplete: Added a test for exceeding minLength, then falling belo…
Browse files Browse the repository at this point in the history
…w, then exceeding again.
  • Loading branch information
scottgonzalez committed Feb 15, 2012
1 parent 9095938 commit f262a53
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions tests/unit/autocomplete/autocomplete_options.js
Expand Up @@ -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 );
Expand Down

0 comments on commit f262a53

Please sign in to comment.