Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tests: Replace CSS & Effects #show-tests with inline display: none
  • Loading branch information
gibson042 committed Apr 6, 2015
commit f64a6b69851ea0900dba9b919f94c6765f28b5b5
13 changes: 9 additions & 4 deletions test/unit/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,8 @@ test("show();", function() {

expect( 18 );

var hiddendiv, div, pass, old, test;
hiddendiv = jQuery("div.hidden");
var hiddendiv, div, pass, old, test;
hiddendiv = jQuery("div.hidden");

equal(jQuery.css( hiddendiv[0], "display"), "none", "hiddendiv is display: none");

Expand All @@ -512,8 +512,13 @@ test("show();", function() {
});
ok( pass, "Show" );

// #show-tests * is set display: none in CSS
jQuery("#qunit-fixture").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><table id='test-table'></table>");
jQuery(
"<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>" +
"<table id='test-table'></table>"
).appendTo( "#qunit-fixture" ).find( "*" ).css( "display", "none" );

old = jQuery("#test-table").show().css("display") !== "table";
jQuery("#test-table").remove();
Expand Down
36 changes: 19 additions & 17 deletions test/unit/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,13 @@ test("sanity check", function() {
equal( jQuery("#dl:visible, #qunit-fixture:visible, #foo:visible").length, 2, "QUnit state is correct for testing effects" );
});

test("show() basic", 2, function() {
var div,
hiddendiv = jQuery("div.hidden");

hiddendiv.hide().show();

equal( hiddendiv.css("display"), "block", "Make sure a pre-hidden div is visible." );

div = jQuery("<div>").hide().appendTo("#qunit-fixture").show();
test("show() basic", 1, function() {
var div = jQuery("<div>").hide().appendTo("#qunit-fixture").show();

equal( div.css("display"), "block", "Make sure pre-hidden divs show" );

// Clean up the detached node
div.remove();

QUnit.expectJqData( this, hiddendiv, "olddisplay" );
});

test("show()", 27, function () {
Expand Down Expand Up @@ -94,8 +85,13 @@ test("show()", 27, function () {
// Tolerate data from show()/hide()
QUnit.expectJqData( this, div, "olddisplay" );

// #show-tests * is set display: none in CSS
jQuery("#qunit-fixture").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><table id='test-table'></table>");
jQuery(
"<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>" +
"<table id='test-table'></table>"
).appendTo( "#qunit-fixture" ).find( "*" ).css( "display", "none" );

old = jQuery("#test-table").show().css("display") !== "table";
jQuery("#test-table").remove();
Expand Down Expand Up @@ -132,11 +128,17 @@ test("show()", 27, function () {
test("show(Number) - other displays", function() {
expect(15);

// #show-tests * is set display: none in CSS
jQuery("#qunit-fixture").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><table id='test-table'></table>");
jQuery(
"<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>" +
"<table id='test-table'></table>"
).appendTo( "#qunit-fixture" ).find( "*" ).css( "display", "none" );

var test,
old = jQuery("#test-table").show().css("display") !== "table";

jQuery("#test-table").remove();

// Note: inline elements are expected to be inline-block
Expand Down Expand Up @@ -174,8 +176,8 @@ test("show(Number) - other displays", function() {
test("Persist correct display value", function() {
expect(3);

// #show-tests * is set display: none in CSS
jQuery("#qunit-fixture").append("<div id='show-tests'><span style='position:absolute;'>foo</span></div>");
jQuery( "<div id='show-tests'><span style='position:absolute;'>foo</span></div>" )
.appendTo( "#qunit-fixture" ).find( "*" ).css( "display", "none" );

var $span = jQuery("#show-tests span"),
displayNone = $span.css("display"),
Expand Down