X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=b33a6eae2819cef573251d5357f88fa4f9d17218;hb=831625c43e85a010064cac18b14ea49f1531c315;hp=d4cc165c5b43d34688b29678ad536e5e2724094c;hpb=6a9b73c7b97b7a1dbb3febde80aef70ebe162cd2;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index d4cc165..b33a6ea 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -300,16 +300,23 @@ test("each(Function)", function() { }); test("index(Object)", function() { - expect(8); - equals( $([window, document]).index(window), 0, "Check for index of elements" ); - equals( $([window, document]).index(document), 1, "Check for index of elements" ); - var inputElements = $('#radio1,#radio2,#check1,#check2'); + expect(10); + + var elements = $([window, document]), + inputElements = $('#radio1,#radio2,#check1,#check2'); + + 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" ); + + // 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" ); }); test("attr(String)", function() { @@ -367,13 +374,15 @@ test("attr(Hash)", function() { test("attr(String, Object)", function() { expect(17); - var div = $("div"); - div.attr("foo", "bar"); - var pass = true; + var div = $("div").attr("foo", "bar"); + fail = false; for ( var i = 0; i < div.size(); i++ ) { - if ( div.get(i).getAttribute('foo') != "bar" ) pass = false; + if ( div.get(i).getAttribute('foo') != "bar" ){ + fail = i; + break; + } } - ok( pass, "Set Attribute" ); + equals( fail, false, "Set Attribute, the #"+fail+" element didn't get the attribute 'foo'" ); ok( $("#foo").attr({"width": null}), "Try to set an attribute to nothing" ); @@ -405,7 +414,7 @@ test("attr(String, Object)", function() { j.attr("name", "attrvalue"); equals( j.attr("name"), "attrvalue", "Check node,textnode,comment for attr" ); - j.removeAttr("name") + j.removeAttr("name"); reset();