X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=69a0676560345c4694f0c351be5c1a41c41bb2b3;hb=db8623ebc83b26d1862248083f51bb6ecc0c596b;hp=b2ddca4c60b71bf8c29bf168a09277e6e8a42ebc;hpb=b536d2ac67077aa45ed5d72bd702dab3c81e5d28;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index b2ddca4..69a0676 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -909,7 +909,7 @@ test("append(String|Element|Array<Element>|jQuery)", function() { }); test("appendTo(String|Element|Array<Element>|jQuery)", function() { - expect(7); + expect(12); var defaultText = 'Try them out:' jQuery('buga').appendTo('#first'); equals( jQuery("#first").text(), defaultText + 'buga', 'Check if text appending works' ); @@ -936,6 +936,27 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() { reset(); jQuery('#select1').appendTo('#foo'); t( 'Append select', '#foo select', ['select1'] ); + + reset(); + var div = jQuery("
").click(function(){ + ok(true, "Running a cloned click."); + }); + div.appendTo("#main, #moretests"); + + jQuery("#main div:last").click(); + jQuery("#moretests div:last").click(); + + reset(); + var div = jQuery("
").appendTo("#main, #moretests"); + + equals( div.length, 2, "appendTo returns the inserted elements" ); + + div.addClass("test"); + + ok( jQuery("#main div:last").hasClass("test"), "appendTo element was modified after the insertion" ); + ok( jQuery("#moretests div:last").hasClass("test"), "appendTo element was modified after the insertion" ); + + reset(); }); test("prepend(String|Element|Array<Element>|jQuery)", function() { @@ -975,12 +996,12 @@ test("prependTo(String|Element|Array<Element>|jQuery)", function() { reset(); expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog"; - jQuery([document.getElementById('yahoo'), document.getElementById('first')]).prependTo('#sap'); + jQuery([document.getElementById('first'), document.getElementById('yahoo')]).prependTo('#sap'); equals( expected, jQuery('#sap').text(), "Check for prepending of array of elements" ); reset(); - expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog"; - jQuery("#yahoo, #first").prependTo('#sap'); + expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog"; + jQuery("#first, #yahoo").prependTo('#sap'); equals( expected, jQuery('#sap').text(), "Check for prepending of jQuery object" ); reset(); @@ -1069,12 +1090,12 @@ test("insertAfter(String|Element|Array<Element>|jQuery)", function() { reset(); expected = "This is a normal link: YahooTry them out:diveintomark"; - jQuery([document.getElementById('mark'), document.getElementById('first')]).insertAfter('#yahoo'); + jQuery([document.getElementById('first'), document.getElementById('mark')]).insertAfter('#yahoo'); equals( expected, jQuery('#en').text(), "Insert array of elements after" ); reset(); - expected = "This is a normal link: YahooTry them out:diveintomark"; - jQuery("#mark, #first").insertAfter('#yahoo'); + expected = "This is a normal link: YahoodiveintomarkTry them out:"; + jQuery("#first, #mark").insertAfter('#yahoo'); equals( expected, jQuery('#en').text(), "Insert jQuery after" ); }); @@ -1532,6 +1553,9 @@ test("show()", function() { ok( pass, "Show" ); jQuery("#main").append('

'); + + var old = jQuery("#show-tests table").show().css("display") !== "table"; + var test = { "div" : "block", "p" : "block", @@ -1539,14 +1563,14 @@ test("show()", function() { "code" : "inline", "pre" : "block", "span" : "inline", - "table" : jQuery.browser.msie ? "block" : "table", - "thead" : jQuery.browser.msie ? "block" : "table-header-group", - "tbody" : jQuery.browser.msie ? "block" : "table-row-group", - "tr" : jQuery.browser.msie ? "block" : "table-row", - "th" : jQuery.browser.msie ? "block" : "table-cell", - "td" : jQuery.browser.msie ? "block" : "table-cell", + "table" : old ? "block" : "table", + "thead" : old ? "block" : "table-header-group", + "tbody" : old ? "block" : "table-row-group", + "tr" : old ? "block" : "table-row", + "th" : old ? "block" : "table-cell", + "td" : old ? "block" : "table-cell", "ul" : "block", - "li" : jQuery.browser.msie ? "block" : "list-item" + "li" : old ? "block" : "list-item" }; jQuery.each(test, function(selector, expected) {