Fixed #1854 by using wizzud's suggestion. The only real difference is the code is...
[jquery.git] / test / unit / core.js
index 7ba7eb5..12b4056 100644 (file)
@@ -864,7 +864,7 @@ test("find(String)", function() {
 });
 
 test("clone()", function() {
-       expect(4);
+       expect(6);
        ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Assert text for #en' );
        var clone = $('#yahoo').clone();
        ok( 'Try them out:Yahoo' == $('#first').append(clone).text(), 'Check for clone' );
@@ -872,6 +872,16 @@ test("clone()", function() {
        // using contents will get comments regular, text, and comment nodes
        var cl = $("#nonnodes").contents().clone();
        ok( cl.length >= 2, "Check node,textnode,comment clone works (some browsers delete comments on clone)" );
+
+       stop();
+       $.get("data/dashboard.xml", function (xml) {
+               var root = $(xml.documentElement).clone();
+               $("tab:first", xml).text("origval");
+               $("tab:first", root).text("cloneval");
+               equals($("tab:first", xml).text(), "origval", "Check original XML node was correctly set");
+               equals($("tab:first", root).text(), "cloneval", "Check cloned XML node was correctly set");
+               start();
+       });
 });
 
 test("is(String)", function() {
@@ -1022,7 +1032,8 @@ test("html(String)", function() {
 
        $("#main").html('foo <form><script type="text/javascript">ok( true, "$().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script></form>');
 
-       $("#main").html("<script>ok(scriptorder++ == 0, 'Script is executed in order');ok($('#scriptorder').length == 0,'Execute before html')<\/script><span id='scriptorder'><script>ok(scriptorder++ == 1, 'Script is executed in order');ok($('#scriptorder').length == 1,'Execute after html')<\/script></span><script>ok(scriptorder++ == 2, 'Script is executed in order');ok($('#scriptorder').length == 1,'Execute after html')<\/script>");
+       // it was decided that waiting to execute ALL scripts makes sense since nested ones have to wait anyway so this test case is changed, see #1959
+       $("#main").html("<script>ok(scriptorder++ == 0, 'Script is executed in order');ok($('#scriptorder').length == 1,'Execute after html (even though appears before)')<\/script><span id='scriptorder'><script>ok(scriptorder++ == 1, 'Script (nested) is executed in order');ok($('#scriptorder').length == 1,'Execute after html')<\/script></span><script>ok(scriptorder++ == 2, 'Script (unnested) is executed in order');ok($('#scriptorder').length == 1,'Execute after html')<\/script>");
 
        setTimeout( start, 100 );
 });
@@ -1041,10 +1052,12 @@ test("filter()", function() {
 });
 
 test("not()", function() {
-       expect(3);
+       expect(5);
        ok( $("#main > p#ap > a").not("#google").length == 2, "not('selector')" );
+       isSet( $("p").not(".result").get(), q("firstp", "ap", "sndp", "en", "sap", "first"), "not('.class')" );
        isSet( $("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" );
        isSet( $("p").not($("#ap, #sndp, .result")).get(), q("firstp", "en", "sap", "first"), "not(jQuery)" );
+       isSet( $("#form option").not("option.emptyopt:contains('Nothing'),[selected],[value='1']").get(), q("option1c", "option1d", "option2c", "option3d" ), "not('complex selector')");
 });
 
 test("andSelf()", function() {
@@ -1106,12 +1119,35 @@ test("prev([String])", function() {
 });
 
 test("show()", function() {
-       expect(1);
+       expect(15);
        var pass = true, div = $("div");
        div.show().each(function(){
                if ( this.style.display == "none" ) pass = false;
        });
        ok( pass, "Show" );
+       
+       $("#main").append('<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div>');
+       var test = {
+               "div"      : "block",
+               "p"        : "block",
+               "a"        : "inline",
+               "code"     : "inline",
+               "pre"      : "block",
+               "span"     : "inline",
+               "table"    : $.browser.msie ? "block" : "table",
+               "thead"    : $.browser.msie ? "block" : "table-header-group",
+               "tbody"    : $.browser.msie ? "block" : "table-row-group",
+               "tr"       : $.browser.msie ? "block" : "table-row",
+               "th"       : $.browser.msie ? "block" : "table-cell",
+               "td"       : $.browser.msie ? "block" : "table-cell",
+               "ul"       : "block",
+               "li"       : $.browser.msie ? "block" : "list-item"
+       };
+       
+       $.each(test, function(selector, expected) {
+               var elem = $(selector, "#show-tests").show();
+               equals( elem.css("display"), expected, "Show using correct display type for " + selector );
+       });
 });
 
 test("addClass(String)", function() {