@@ -220,7 +220,20 @@ function sourceTest( source, async ) {
220
220
} ) ,
221
221
menu = element . autocomplete ( "widget" ) ;
222
222
function result ( ) {
223
- equal ( menu . find ( ".ui-menu-item" ) . text ( ) , "javajavascript" ) ;
223
+ var items = menu . find ( ".ui-menu-item" ) ;
224
+ equal ( items . length , 3 , "Should find three results." ) ;
225
+ deepEqual ( items . eq ( 0 ) . data ( "ui-autocomplete-item" ) , {
226
+ label : "java" ,
227
+ value : "java"
228
+ } ) ;
229
+ deepEqual ( items . eq ( 1 ) . data ( "ui-autocomplete-item" ) , {
230
+ label : "javascript" ,
231
+ value : "javascript"
232
+ } ) ;
233
+ deepEqual ( items . eq ( 2 ) . data ( "ui-autocomplete-item" ) , {
234
+ label : "clojure" ,
235
+ value : "clojure"
236
+ } ) ;
224
237
element . autocomplete ( "destroy" ) ;
225
238
if ( async ) {
226
239
start ( ) ;
@@ -230,52 +243,58 @@ function sourceTest( source, async ) {
230
243
stop ( ) ;
231
244
$ ( document ) . one ( "ajaxStop" , result ) ;
232
245
}
233
- element . val ( "ja " ) . autocomplete ( "search" ) ;
246
+ element . val ( "j " ) . autocomplete ( "search" ) ;
234
247
if ( ! async ) {
235
248
result ( ) ;
236
249
}
237
250
}
238
251
239
- test ( "source, local object array, only label property " , function ( ) {
240
- expect ( 1 ) ;
252
+ test ( "source, local object array, only labels " , function ( ) {
253
+ expect ( 4 ) ;
241
254
sourceTest ( [
242
- { label : "java" } ,
243
- { label : "php" } ,
244
- { label : "coldfusion" } ,
245
- { label : "javascript" }
255
+ { label : "java" , value : null } ,
256
+ { label : "php" , value : null } ,
257
+ { label : "coldfusion" , value : "" } ,
258
+ { label : "javascript" , value : "" } ,
259
+ { label : "clojure" }
246
260
] ) ;
247
261
} ) ;
248
262
249
- test ( "source, local object array, only value property " , function ( ) {
250
- expect ( 1 ) ;
263
+ test ( "source, local object array, only values " , function ( ) {
264
+ expect ( 4 ) ;
251
265
sourceTest ( [
252
- { value : "java" } ,
253
- { value : "php" } ,
254
- { value : "coldfusion" } ,
255
- { value : "javascript" }
266
+ { value : "java" , label : null } ,
267
+ { value : "php" , label : null } ,
268
+ { value : "coldfusion" , label : "" } ,
269
+ { value : "javascript" , label : "" } ,
270
+ { value : "clojure" }
256
271
] ) ;
257
272
} ) ;
258
273
259
274
test ( "source, url string with remote json string array" , function ( ) {
260
- expect ( 1 ) ;
275
+ expect ( 4 ) ;
261
276
sourceTest ( "remote_string_array.txt" , true ) ;
262
277
} ) ;
263
278
264
279
test ( "source, url string with remote json object array, only value properties" , function ( ) {
265
- expect ( 1 ) ;
280
+ expect ( 4 ) ;
266
281
sourceTest ( "remote_object_array_values.txt" , true ) ;
267
282
} ) ;
268
283
269
284
test ( "source, url string with remote json object array, only label properties" , function ( ) {
270
- expect ( 1 ) ;
285
+ expect ( 4 ) ;
271
286
sourceTest ( "remote_object_array_labels.txt" , true ) ;
272
287
} ) ;
273
288
274
289
test ( "source, custom" , function ( ) {
275
- expect ( 2 ) ;
290
+ expect ( 5 ) ;
276
291
sourceTest ( function ( request , response ) {
277
- equal ( request . term , "ja" ) ;
278
- response ( [ "java" , "javascript" ] ) ;
292
+ equal ( request . term , "j" ) ;
293
+ response ( [
294
+ "java" ,
295
+ { label : "javascript" , value : null } ,
296
+ { value : "clojure" , label : null }
297
+ ] ) ;
279
298
} ) ;
280
299
} ) ;
281
300
0 commit comments