X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=ac93ddaa2edb6bb3042a5c8ee12842b1322d9ec7;hb=e8eff25f3b6d9a0c03f6581089406cebcc86aa34;hp=abd4f679dfb1de4c44b31b6f235e21c677e592af;hpb=c6b59263b5fb13f84ecdae4e51e4dd15198a6bdf;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index abd4f67..ac93dda 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -373,7 +373,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 +399,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 +494,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 +519,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(){