-test("filter()", function() {
- expect(6);
- isSet( jQuery("#form input").filter(":checked").get(), q("radio2", "check1"), "filter(String)" );
- isSet( jQuery("p").filter("#ap, #sndp").get(), q("ap", "sndp"), "filter('String, String')" );
- isSet( jQuery("p").filter("#ap,#sndp").get(), q("ap", "sndp"), "filter('String,String')" );
- isSet( jQuery("p").filter(function() { return !jQuery("a", this).length }).get(), q("sndp", "first"), "filter(Function)" );
+test("index()", function() {
+ expect(1);
+
+ equals( jQuery("#text2").index(), 2, "Returns the index of a child amongst its siblings" )
+});
+
+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" );
+});
+
+test("filter(Selector)", function() {
+ expect(5);
+ same( jQuery("#form input").filter(":checked").get(), q("radio2", "check1"), "filter(String)" );
+ same( jQuery("p").filter("#ap, #sndp").get(), q("ap", "sndp"), "filter('String, String')" );
+ same( jQuery("p").filter("#ap,#sndp").get(), q("ap", "sndp"), "filter('String,String')" );