X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=5d2f5f407ddd38ab0e84c4736c434be12bbb7db1;hb=8cd50a398dfd9ab8ad93c7c26749c67345c14d74;hp=1ae2dfa5f93421c81da88e57d9ae3819cc15037c;hpb=6b090328643988869e2288a4874935680d8573ca;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index 1ae2dfa..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); @@ -1466,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() {