Make toArray an alias for .get(). Closes #3999
[jquery.git] / test / unit / core.js
index abd4f67..aad9e6e 100644 (file)
@@ -328,6 +328,13 @@ test("get()", function() {
        isSet( jQuery("p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );
 });
 
+test("toArray()", function() {
+       expect(1);
+       isSet ( jQuery("p").toArray(),
+               q("firstp","ap","sndp","en","sap","first"),
+               "Convert jQuery object to an Array" )
+})
+
 test("get(Number)", function() {
        expect(1);
        equals( jQuery("p").get(0), document.getElementById("firstp"), "Get A Single Element" );
@@ -373,7 +380,7 @@ test("each(Function)", function() {
 });
 
 test("index(Object|String|undefined)", function() {
-       expect(15);
+       expect(16);
 
        var elements = jQuery([window, document]),
                inputElements = jQuery('#radio1,#radio2,#check1,#check2');
@@ -399,6 +406,7 @@ test("index(Object|String|undefined)", function() {
        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" );
 });
 
@@ -493,7 +501,7 @@ test("jQuery.extend(Object, Object)", function() {
 });
 
 test("jQuery.each(Object,Function)", function() {
-       expect(12);
+       expect(13);
        jQuery.each( [0,1,2], function(i, n){
                equals( i, n, "Check array iteration" );
        });
@@ -518,6 +526,13 @@ test("jQuery.each(Object,Function)", function() {
        total = 0;
        jQuery.each({"a":3,"b":3,"c":3}, function(i,v){ total += v; return false; });
        equals( total, 3, "Looping over an object, with break" );
+       
+       var f = function(){};
+       f.foo = 'bar';
+       jQuery.each(f, function(i){
+               f[i] = 'baz';
+       });
+       equals( "baz", f.foo, "Loop over a function" );
 });
 
 test("jQuery.makeArray", function(){