X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=5d2f5f407ddd38ab0e84c4736c434be12bbb7db1;hb=4ca4ce52f76f4db64f9a8350aa60ab54eba15697;hp=536e58cf5b9bc6a5d065b802c75b0e842581da87;hpb=c85243dfc4b09e6bb87532f2025f686b6ae45a22;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index 536e58c..5d2f5f4 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -451,7 +451,7 @@ test("attr(Hash)", function() { }); test("attr(String, Object)", function() { - expect(17); + expect(19); var div = jQuery("div").attr("foo", "bar"); fail = false; for ( var i = 0; i < div.size(); i++ ) { @@ -515,6 +515,16 @@ test("attr(String, Object)", function() { } ok( thrown, "Exception thrown when trying to change type property" ); equals( "checkbox", jQuery(check).attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" ); + + var check = jQuery(""); + var thrown = true; + try { + check.attr('type','checkbox'); + } catch(e) { + thrown = false; + } + ok( thrown, "Exception thrown when trying to change type property" ); + equals( "checkbox", check.attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" ); }); if ( !isLocal ) { @@ -1138,6 +1148,23 @@ test("is(String)", function() { ok( jQuery('#en').is('[lang="de"] , [lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' ); }); +test("jQuery.merge()", function() { + expect(6); + + var parse = jQuery.merge; + + same( parse([],[]), [], "Empty arrays" ); + + same( parse([1],[2]), [1,2], "Basic" ); + same( parse([1,2],[3,4]), [1,2,3,4], "Basic" ); + + same( parse([1,2],[]), [1,2], "Second empty" ); + same( parse([],[1,2]), [1,2], "First empty" ); + + // Fixed at [5998], #3641 + same( parse([-2,-1], [0,1,2]), [-2,-1,0,1,2], "Second array including a zero (falsy)"); +}); + test("jQuery.extend(Object, Object)", function() { expect(20); @@ -1309,6 +1336,14 @@ test("filter()", function() { equals( j.filter("[name]").length, 0, "Check node,textnode,comment to filter the one span" ); }); +test("closest()", function() { + expect(4); + isSet( jQuery("body").closest("body").get(), q("body"), "closest(body)" ); + isSet( jQuery("body").closest("html").get(), q("html"), "closest(html)" ); + isSet( jQuery("body").closest("div").get(), [], "closest(div)" ); + isSet( jQuery("#main").closest("span,#html").get(), q("html"), "closest(span,#html)" ); +}); + test("not()", function() { expect(8); equals( jQuery("#main > p#ap > a").not("#google").length, 2, "not('selector')" ); @@ -1458,13 +1493,20 @@ test("removeClass(String) - simple", function() { }); test("toggleClass(String)", function() { - expect(3); + expect(6); var e = jQuery("#firstp"); ok( !e.is(".test"), "Assert class not present" ); e.toggleClass("test"); ok( e.is(".test"), "Assert class present" ); e.toggleClass("test"); ok( !e.is(".test"), "Assert class not present" ); + + e.toggleClass("test", false); + ok( !e.is(".test"), "Assert class not present" ); + e.toggleClass("test", true); + ok( e.is(".test"), "Assert class present" ); + e.toggleClass("test", false); + ok( !e.is(".test"), "Assert class not present" ); }); test("removeAttr(String", function() {