@@ -220,7 +220,20 @@ function sourceTest( source, async ) {
220220} ) ,
221221menu = element . autocomplete ( "widget" ) ;
222222function 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+ } ) ;
224237element . autocomplete ( "destroy" ) ;
225238if ( async ) {
226239start ( ) ;
@@ -230,52 +243,58 @@ function sourceTest( source, async ) {
230243stop ( ) ;
231244$ ( document ) . one ( "ajaxStop" , result ) ;
232245}
233- element . val ( "ja " ) . autocomplete ( "search" ) ;
246+ element . val ( "j " ) . autocomplete ( "search" ) ;
234247if ( ! async ) {
235248result ( ) ;
236249}
237250}
238251
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 ) ;
241254sourceTest ( [
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" }
246260] ) ;
247261} ) ;
248262
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 ) ;
251265sourceTest ( [
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" }
256271] ) ;
257272} ) ;
258273
259274test ( "source, url string with remote json string array" , function ( ) {
260- expect ( 1 ) ;
275+ expect ( 4 ) ;
261276sourceTest ( "remote_string_array.txt" , true ) ;
262277} ) ;
263278
264279test ( "source, url string with remote json object array, only value properties" , function ( ) {
265- expect ( 1 ) ;
280+ expect ( 4 ) ;
266281sourceTest ( "remote_object_array_values.txt" , true ) ;
267282} ) ;
268283
269284test ( "source, url string with remote json object array, only label properties" , function ( ) {
270- expect ( 1 ) ;
285+ expect ( 4 ) ;
271286sourceTest ( "remote_object_array_labels.txt" , true ) ;
272287} ) ;
273288
274289test ( "source, custom" , function ( ) {
275- expect ( 2 ) ;
290+ expect ( 5 ) ;
276291sourceTest ( 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+ ] ) ;
279298} ) ;
280299} ) ;
281300
0 commit comments