@@ -56,31 +56,31 @@ test("selector state", function() {
5656 expect ( 30 ) ;
5757
5858 var test ;
59-
59+
6060 test = jQuery ( ) ;
6161 equals ( test . selector , "" , "Empty jQuery Selector" ) ;
6262 equals ( test . context , undefined , "Empty jQuery Context" ) ;
63-
63+
6464 test = jQuery ( document ) ;
6565 equals ( test . selector , "" , "Document Selector" ) ;
6666 equals ( test . context , document , "Document Context" ) ;
67-
67+
6868 test = jQuery ( document . body ) ;
6969 equals ( test . selector , "" , "Body Selector" ) ;
7070 equals ( test . context , document . body , "Body Context" ) ;
71-
71+
7272 test = jQuery ( "#main" ) ;
7373 equals ( test . selector , "#main" , "#main Selector" ) ;
7474 equals ( test . context , document , "#main Context" ) ;
7575
7676 test = jQuery ( "#notfoundnono" ) ;
7777 equals ( test . selector , "#notfoundnono" , "#notfoundnono Selector" ) ;
7878 equals ( test . context , document , "#notfoundnono Context" ) ;
79-
79+
8080 test = jQuery ( "#main" , document ) ;
8181 equals ( test . selector , "#main" , "#main Selector" ) ;
8282 equals ( test . context , document , "#main Context" ) ;
83-
83+
8484 test = jQuery ( "#main" , document . body ) ;
8585 equals ( test . selector , "#main" , "#main Selector" ) ;
8686 equals ( test . context , document . body , "#main Context" ) ;
@@ -89,31 +89,31 @@ test("selector state", function() {
8989 test = jQuery ( test ) ;
9090 equals ( test . selector , "#main" , "#main Selector" ) ;
9191 equals ( test . context , document . body , "#main Context" ) ;
92-
92+
9393 test = jQuery ( document . body ) . find ( "#main" ) ;
9494 equals ( test . selector , "#main" , "#main find Selector" ) ;
9595 equals ( test . context , document . body , "#main find Context" ) ;
9696
9797 test = jQuery ( "#main" ) . filter ( "div" ) ;
9898 equals ( test . selector , "#main.filter(div)" , "#main filter Selector" ) ;
9999 equals ( test . context , document , "#main filter Context" ) ;
100-
100+
101101 test = jQuery ( "#main" ) . not ( "div" ) ;
102102 equals ( test . selector , "#main.not(div)" , "#main not Selector" ) ;
103103 equals ( test . context , document , "#main not Context" ) ;
104-
104+
105105 test = jQuery ( "#main" ) . filter ( "div" ) . not ( "div" ) ;
106106 equals ( test . selector , "#main.filter(div).not(div)" , "#main filter, not Selector" ) ;
107107 equals ( test . context , document , "#main filter, not Context" ) ;
108-
108+
109109 test = jQuery ( "#main" ) . filter ( "div" ) . not ( "div" ) . end ( ) ;
110110 equals ( test . selector , "#main.filter(div)" , "#main filter, not, end Selector" ) ;
111111 equals ( test . context , document , "#main filter, not, end Context" ) ;
112-
112+
113113 test = jQuery ( "#main" ) . parent ( "body" ) ;
114114 equals ( test . selector , "#main.parent(body)" , "#main parent Selector" ) ;
115115 equals ( test . context , document , "#main parent Context" ) ;
116-
116+
117117 test = jQuery ( "#main" ) . eq ( 0 ) ;
118118 equals ( test . selector , "#main.slice(0,1)" , "#main eq Selector" ) ;
119119 equals ( test . context , document , "#main eq Context" ) ;
@@ -366,12 +366,13 @@ test("each(Function)", function() {
366366 ok ( pass , "Execute a function, Relative" ) ;
367367} ) ;
368368
369- test ( "index(Object)" , function ( ) {
370- expect ( 10 ) ;
369+ test ( "index(Object|String|undefined )" , function ( ) {
370+ expect ( 15 ) ;
371371
372372 var elements = jQuery ( [ window , document ] ) ,
373373 inputElements = jQuery ( '#radio1,#radio2,#check1,#check2' ) ;
374374
375+ // Passing a node
375376 equals ( elements . index ( window ) , 0 , "Check for index of elements" ) ;
376377 equals ( elements . index ( document ) , 1 , "Check for index of elements" ) ;
377378 equals ( inputElements . index ( document . getElementById ( 'radio1' ) ) , 0 , "Check for index of elements" ) ;
@@ -381,24 +382,33 @@ test("index(Object)", function() {
381382 equals ( inputElements . index ( window ) , - 1 , "Check for not found index" ) ;
382383 equals ( inputElements . index ( document ) , - 1 , "Check for not found index" ) ;
383384
385+ // Passing a jQuery object
384386 // enabled since [5500]
385387 equals ( elements . index ( elements ) , 0 , "Pass in a jQuery object" ) ;
386388 equals ( elements . index ( elements . eq ( 1 ) ) , 1 , "Pass in a jQuery object" ) ;
389+ equals ( jQuery ( "#form :radio" ) . index ( jQuery ( "#radio2" ) ) , 1 , "Pass in a jQuery object" ) ;
390+
391+ // Passing a selector or nothing
392+ // enabled since [6329]
393+ equals ( jQuery ( '#text2' ) . index ( ) , 2 , "Check for index amongst siblings" ) ;
394+ equals ( jQuery ( '#form' ) . children ( ) . eq ( 4 ) . index ( ) , 4 , "Check for index amongst siblings" ) ;
395+ equals ( jQuery ( '#radio2' ) . index ( '#form :radio' ) , 1 , "Check for index within a selector" ) ;
396+ equals ( jQuery ( '#radio2' ) . index ( '#form :text' ) , - 1 , "Check for index not found within a selector" ) ;
387397} ) ;
388398
389399test ( "jQuery.merge()" , function ( ) {
390400 expect ( 6 ) ;
391-
401+
392402 var parse = jQuery . merge ;
393-
403+
394404 same ( parse ( [ ] , [ ] ) , [ ] , "Empty arrays" ) ;
395-
405+
396406 same ( parse ( [ 1 ] , [ 2 ] ) , [ 1 , 2 ] , "Basic" ) ;
397407 same ( parse ( [ 1 , 2 ] , [ 3 , 4 ] ) , [ 1 , 2 , 3 , 4 ] , "Basic" ) ;
398-
408+
399409 same ( parse ( [ 1 , 2 ] , [ ] ) , [ 1 , 2 ] , "Second empty" ) ;
400- same ( parse ( [ ] , [ 1 , 2 ] ) , [ 1 , 2 ] , "First empty" ) ;
401-
410+ same ( parse ( [ ] , [ 1 , 2 ] ) , [ 1 , 2 ] , "First empty" ) ;
411+
402412 // Fixed at [5998], #3641
403413 same ( parse ( [ - 2 , - 1 ] , [ 0 , 1 , 2 ] ) , [ - 2 , - 1 , 0 , 1 , 2 ] , "Second array including a zero (falsy)" ) ;
404414} ) ;
@@ -531,7 +541,7 @@ test("jQuery.makeArray", function(){
531541
532542 // function, is tricky as it has length
533543 equals ( jQuery . makeArray ( function ( ) { return 1 ; } ) [ 0 ] ( ) , 1 , "Pass makeArray a function" ) ;
534-
544+
535545 //window, also has length
536546 equals ( jQuery . makeArray ( window ) [ 0 ] , window , "Pass makeArray the window" ) ;
537547
0 commit comments