@@ -80,4 +80,90 @@ test( "allow form submit on enter when menu is not active", function() {
80
80
ok ( ! event . isDefaultPrevented ( ) , "default action is prevented" ) ;
81
81
} ) ;
82
82
83
+ ( function ( ) {
84
+ test ( "up arrow invokes search - input" , function ( ) {
85
+ arrowsInvokeSearch ( "#autocomplete" , true , true ) ;
86
+ } ) ;
87
+
88
+ test ( "down arrow invokes search - input" , function ( ) {
89
+ arrowsInvokeSearch ( "#autocomplete" , false , true ) ;
90
+ } ) ;
91
+
92
+ test ( "up arrow invokes search - textarea" , function ( ) {
93
+ arrowsInvokeSearch ( "#autocomplete-textarea" , true , false ) ;
94
+ } ) ;
95
+
96
+ test ( "down arrow invokes search - textarea" , function ( ) {
97
+ arrowsInvokeSearch ( "#autocomplete-textarea" , false , false ) ;
98
+ } ) ;
99
+
100
+ test ( "up arrow invokes search - contenteditable" , function ( ) {
101
+ arrowsInvokeSearch ( "#autocomplete-contenteditable" , true , false ) ;
102
+ } ) ;
103
+
104
+ test ( "down arrow invokes search - contenteditable" , function ( ) {
105
+ arrowsInvokeSearch ( "#autocomplete-contenteditable" , false , false ) ;
106
+ } ) ;
107
+
108
+ test ( "up arrow moves focus - input" , function ( ) {
109
+ arrowsMoveFocus ( "#autocomplete" , true ) ;
110
+ } ) ;
111
+
112
+ test ( "down arrow moves focus - input" , function ( ) {
113
+ arrowsMoveFocus ( "#autocomplete" , false ) ;
114
+ } ) ;
115
+
116
+ test ( "up arrow moves focus - textarea" , function ( ) {
117
+ arrowsMoveFocus ( "#autocomplete-textarea" , true ) ;
118
+ } ) ;
119
+
120
+ test ( "down arrow moves focus - textarea" , function ( ) {
121
+ arrowsMoveFocus ( "#autocomplete-textarea" , false ) ;
122
+ } ) ;
123
+
124
+ test ( "up arrow moves focus - contenteditable" , function ( ) {
125
+ arrowsMoveFocus ( "#autocomplete-contenteditable" , true ) ;
126
+ } ) ;
127
+
128
+ test ( "down arrow moves focus - contenteditable" , function ( ) {
129
+ arrowsMoveFocus ( "#autocomplete-contenteditable" , false ) ;
130
+ } ) ;
131
+
132
+ function arrowsInvokeSearch ( id , isKeyUp , shouldMove ) {
133
+ expect ( 1 ) ;
134
+
135
+ var didMove = false ,
136
+ element = $ ( id ) . autocomplete ( {
137
+ source : [ "a" ] ,
138
+ delay : 0 ,
139
+ minLength : 0
140
+ } ) ;
141
+ element . data ( "autocomplete" ) . _move = function ( ) {
142
+ didMove = true ;
143
+ } ;
144
+ element . simulate ( "keydown" , { keyCode : ( isKeyUp ? $ . ui . keyCode . UP : $ . ui . keyCode . DOWN ) } ) ;
145
+ equal ( didMove , shouldMove , "respond to arrow" ) ;
146
+ }
147
+
148
+ function arrowsMoveFocus ( id , isKeyUp ) {
149
+ expect ( 1 ) ;
150
+
151
+ var didMove = false ,
152
+ element = $ ( id ) . autocomplete ( {
153
+ source : [ "a" ] ,
154
+ delay : 0 ,
155
+ minLength : 0
156
+ } ) ;
157
+ element . data ( "autocomplete" ) . _move = function ( ) {
158
+ ok ( true , "repsond to arrow" ) ;
159
+ } ;
160
+ element . autocomplete ( "search" ) ;
161
+ element . simulate ( "keydown" , { keyCode : ( isKeyUp ? $ . ui . keyCode . UP : $ . ui . keyCode . DOWN ) } ) ;
162
+ }
163
+ } ) ( ) ;
164
+
165
+ ( function ( ) {
166
+
167
+ } ) ( ) ;
168
+
83
169
} ( jQuery ) ) ;
0 commit comments