X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=bfaceca38bf3c8f28ee93d3ea0a76f0f4fa40914;hb=de6520b50e481ba588e9021abcab16d06ea61141;hp=d4cc165c5b43d34688b29678ad536e5e2724094c;hpb=6a9b73c7b97b7a1dbb3febde80aef70ebe162cd2;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index d4cc165..bfaceca 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -121,10 +121,10 @@ test("isFunction", function() { // Check built-ins // Safari uses "(Internal Function)" - ok( jQuery.isFunction(String), "String Function" ); - ok( jQuery.isFunction(Array), "Array Function" ); - ok( jQuery.isFunction(Object), "Object Function" ); - ok( jQuery.isFunction(Function), "Function Function" ); + ok( jQuery.isFunction(String), "String Function("+String+")" ); + ok( jQuery.isFunction(Array), "Array Function("+Array+")" ); + ok( jQuery.isFunction(Object), "Object Function("+Object+")" ); + ok( jQuery.isFunction(Function), "Function Function("+Function+")" ); // When stringified, this could be misinterpreted var mystr = "function"; @@ -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();