Skip to content

Commit 56b7ec1

Browse files
committed
Autocomplete: added unit tests for autoFocus. Fixed #7032 - Autocomplete: Add option to automatically highlight the first result
1 parent 2f5eade commit 56b7ec1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/unit/autocomplete/autocomplete_options.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,33 @@ test( "appendTo", function() {
9797
ac.autocomplete( "destroy" );
9898
});
9999

100+
test( "autoFocus: false", function() {
101+
var ac = $( "#autocomplete" ).autocomplete({
102+
autoFocus: false,
103+
delay: 0,
104+
source: data,
105+
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" );
107+
start();
108+
}
109+
});
110+
ac.val( "ja" ).keydown();
111+
stop();
112+
});
113+
114+
test( "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();
126+
});
100127

101128
test("delay", function() {
102129
var ac = $("#autocomplete").autocomplete({

0 commit comments

Comments
 (0)