Skip to content

Commit

Permalink
Autocomplete: added unit tests for autoFocus. Fixed #7032 - Autocompl…
Browse files Browse the repository at this point in the history
…ete: Add option to automatically highlight the first result
  • Loading branch information
rdworth committed Mar 15, 2011
1 parent 2f5eade commit 56b7ec1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/unit/autocomplete/autocomplete_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,33 @@ test( "appendTo", function() {
ac.autocomplete( "destroy" );
});

test( "autoFocus: false", function() {
var ac = $( "#autocomplete" ).autocomplete({
autoFocus: false,
delay: 0,
source: data,
open: function( event, ui ) {
equals( 0, ac.autocomplete( "widget" ).children( ".ui-menu-item:first .ui-state-focus" ).length, "first item is not auto focused" );
start();
}
});
ac.val( "ja" ).keydown();
stop();
});

test( "autoFocus: true", function() {
var ac = $( "#autocomplete" ).autocomplete({
autoFocus: true,
delay: 0,
source: data,
open: function( event, ui ) {
equals( 1, ac.autocomplete( "widget" ).children( ".ui-menu-item:first .ui-state-focus" ).length, "first item is auto focused" );
start();
}
});
ac.val( "ja" ).keydown();
stop();
});

test("delay", function() {
var ac = $("#autocomplete").autocomplete({
Expand Down

2 comments on commit 56b7ec1

@jzaefferer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you refactor these? The test should be just test("autoFocus: true/false", function() { autoFocusTest(true/false, 1/0); });

@rdworth
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Please sign in to comment.