module("effects", { teardown: moduleTeardown }); test("sanity check", function() { expect(1); ok( jQuery("#dl:visible, #qunit-fixture:visible, #foo:visible").length === 3, "QUnit state is correct for testing effects" ); }); test("show()", function() { expect(28); var hiddendiv = jQuery("div.hidden"); hiddendiv.hide().show(); equal( hiddendiv.css("display"), "block", "Make sure a pre-hidden div is visible." ); var div = jQuery("
").hide().appendTo("#qunit-fixture").show(); equal( div.css("display"), "block", "Make sure pre-hidden divs show" ); QUnit.reset(); hiddendiv = jQuery("div.hidden"); equal(jQuery.css( hiddendiv[0], "display"), "none", "hiddendiv is display: none"); hiddendiv.css("display", "block"); equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block"); hiddendiv.show(); equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block"); hiddendiv.css("display",""); var pass = true; div = jQuery("#qunit-fixture div"); div.show().each(function(){ if ( this.style.display == "none" ) pass = false; }); ok( pass, "Show" ); var speeds = { "null speed": null, "undefined speed": undefined, "empty string speed": "", "false speed": false }; jQuery.each(speeds, function(name, speed) { pass = true; div.hide().show(speed).each(function() { if ( this.style.display == "none" ) pass = false; }); ok( pass, "Show with " + name); }); jQuery.each(speeds, function(name, speed) { pass = true; div.hide().show(speed, function() { pass = false; }); ok( pass, "Show with " + name + " does not call animate callback" ); }); // #show-tests * is set display: none in CSS jQuery("#qunit-fixture").append("

"); var old = jQuery("#test-table").show().css("display") !== "table"; jQuery("#test-table").remove(); var test = { "div" : "block", "p" : "block", "a" : "inline", "code" : "inline", "pre" : "block", "span" : "inline", "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" : old ? "block" : "list-item" }; jQuery.each(test, function(selector, expected) { var elem = jQuery(selector, "#show-tests").show(); equal( elem.css("display"), expected, "Show using correct display type for " + selector ); }); // Make sure that showing or hiding a text node doesn't cause an error jQuery("
test
text test").show().remove(); jQuery("
test
text test").hide().remove(); }); test("show(Number) - other displays", function() { expect(15); QUnit.reset(); stop(); // #show-tests * is set display: none in CSS jQuery("#qunit-fixture").append("

"); var old = jQuery("#test-table").show().css("display") !== "table", num = 0; jQuery("#test-table").remove(); var test = { "div" : "block", "p" : "block", "a" : "inline", "code" : "inline", "pre" : "block", "span" : "inline", "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" : old ? "block" : "list-item" }; jQuery.each(test, function(selector, expected) { var elem = jQuery(selector, "#show-tests").show(1, function() { equal( elem.css("display"), expected, "Show using correct display type for " + selector ); if ( ++num === 15 ) { start(); } }); }); }); // Supports #7397 test("Persist correct display value", function() { expect(3); QUnit.reset(); stop(); // #show-tests * is set display: none in CSS jQuery("#qunit-fixture").append("
foo
"); var $span = jQuery("#show-tests span"), displayNone = $span.css("display"), display = "", num = 0; $span.show(); display = $span.css("display"); $span.hide(); $span.fadeIn(100, function() { equal($span.css("display"), display, "Expecting display: " + display); $span.fadeOut(100, function () { equal($span.css("display"), displayNone, "Expecting display: " + displayNone); $span.fadeIn(100, function() { equal($span.css("display"), display, "Expecting display: " + display); start(); }); }); }); }); test("show() resolves correct default display #8099", function() { expect(7); var tt8099 = jQuery("").appendTo("body"), dfn8099 = jQuery("", { html: "foo"}).appendTo("body"); equal( tt8099.css("display"), "none", "default display override for all tt" ); equal( tt8099.show().css("display"), "inline", "Correctly resolves display:inline" ); equal( jQuery("#foo").hide().show().css("display"), "block", "Correctly resolves display:block after hide/show" ); equal( tt8099.hide().css("display"), "none", "default display override for all tt" ); equal( tt8099.show().css("display"), "inline", "Correctly resolves display:inline" ); equal( dfn8099.css("display"), "none", "default display override for all dfn" ); equal( dfn8099.show().css("display"), "inline", "Correctly resolves display:inline" ); tt8099.remove(); dfn8099.remove(); }); test( "show() resolves correct default display, detached nodes (#10006)", function(){ // Tests originally contributed by Orkel in // https://github.com/jquery/jquery/pull/458 expect( 11 ); var div, span; div = jQuery("