-test("index(Object|String|undefined)", function() {
- expect(16);
-
- var elements = jQuery([window, document]),
- inputElements = jQuery('#radio1,#radio2,#check1,#check2');
-
- // Passing a node
- equals( elements.index(window), 0, "Check for index of elements" );
- equals( elements.index(document), 1, "Check for index of elements" );
- equals( inputElements.index(document.getElementById('radio1')), 0, "Check for index of elements" );
- equals( inputElements.index(document.getElementById('radio2')), 1, "Check for index of elements" );
- equals( inputElements.index(document.getElementById('check1')), 2, "Check for index of elements" );
- equals( inputElements.index(document.getElementById('check2')), 3, "Check for index of elements" );
- equals( inputElements.index(window), -1, "Check for not found index" );
- equals( inputElements.index(document), -1, "Check for not found index" );
-
- // Passing a jQuery object
- // enabled since [5500]
- equals( elements.index( elements ), 0, "Pass in a jQuery object" );
- equals( elements.index( elements.eq(1) ), 1, "Pass in a jQuery object" );
- equals( jQuery("#form :radio").index( jQuery("#radio2") ), 1, "Pass in a jQuery object" );
-
- // Passing a selector or nothing
- // enabled since [6330]
- equals( jQuery('#text2').index(), 2, "Check for index amongst siblings" );
- equals( jQuery('#form').children().eq(4).index(), 4, "Check for index amongst siblings" );
- equals( jQuery('#radio2').index('#form :radio') , 1, "Check for index within a selector" );
- equals( jQuery('#form :radio').index( jQuery('#radio2') ), 1, "Check for index within a selector" );
- equals( jQuery('#radio2').index('#form :text') , -1, "Check for index not found within a selector" );