X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;ds=inline;f=test%2Funit%2Feffects.js;h=b7b60abbe495b8539d23c7b78ffcf88a13efec7c;hb=d9660e1bf4f378e0fcb77ba266f27cdec7cda022;hp=dd95d1ba61b975b524c4c55e3343204bc7f8a758;hpb=91028794d5029365eca0c3d40cfdae016403cbe6;p=jquery.git
diff --git a/test/unit/effects.js b/test/unit/effects.js
index dd95d1b..b7b60ab 100644
--- a/test/unit/effects.js
+++ b/test/unit/effects.js
@@ -6,7 +6,32 @@ test("sanity check", function() {
});
test("show()", function() {
- expect(23);
+ expect(28);
+
+ var hiddendiv = jQuery("div.hidden");
+
+ hiddendiv.hide().show();
+
+ equals( hiddendiv.css("display"), "block", "Make sure a pre-hidden div is visible." );
+
+ var div = jQuery("
").hide().appendTo("body").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("#main div");
div.show().each(function(){
if ( this.style.display == "none" ) pass = false;
@@ -38,9 +63,10 @@ test("show()", function() {
});
// #show-tests * is set display: none in CSS
- jQuery("#main").append('
');
+ jQuery("#main").append('
');
- var old = jQuery("#show-tests table").show().css("display") !== "table";
+ var old = jQuery("#test-table").show().css("display") !== "table";
+ jQuery("#test-table").remove();
var test = {
"div" : "block",
@@ -71,10 +97,11 @@ test("show(Number) - other displays", function() {
stop();
// #show-tests * is set display: none in CSS
- jQuery("#main").append('
');
+ jQuery("#main").append('
');
- var old = jQuery("#show-tests table").show().css("display") !== "table",
+ var old = jQuery("#test-table").show().css("display") !== "table",
num = 0;
+ jQuery("#test-table").remove();
var test = {
"div" : "block",
@@ -94,10 +121,7 @@ test("show(Number) - other displays", function() {
};
jQuery.each(test, function(selector, expected) {
- // IE sometimes has issues with chained functions referencing
- // assignments from outside the closure
- var elem = jQuery(selector, "#show-tests");
- elem.show(1, function() {
+ var elem = jQuery(selector, "#show-tests").show(1, function() {
equals( elem.css("display"), expected, "Show using correct display type for " + selector );
if ( ++num === 15 ) {
start();
@@ -106,6 +130,45 @@ test("show(Number) - other displays", function() {
});
});
+
+
+// Supports #7397
+test("Persist correct display value", function() {
+ expect(3);
+ QUnit.reset();
+ stop();
+
+ // #show-tests * is set display: none in CSS
+ jQuery("#main").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() {
+
+ equals($span.css("display"), display, "Expecting display: " + display);
+
+ $span.fadeOut(100, function () {
+
+ equals($span.css("display"), displayNone, "Expecting display: " + displayNone);
+
+ $span.fadeIn(100, function() {
+
+ equals($span.css("display"), display, "Expecting display: " + display);
+
+ start();
+ });
+ });
+ });
+});
+
test("animate(Hash, Object, Function)", function() {
expect(1);
stop();
@@ -128,27 +191,56 @@ test("animate negative height", function() {
test("animate block as inline width/height", function() {
expect(3);
- stop();
- jQuery("#foo").css({ display: "inline", width: '', height: '' }).animate({ width: 42, height: 42 }, 100, function() {
- equals( jQuery(this).css("display"), jQuery.support.inlineBlockNeedsLayout ? "inline" : "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
- equals( this.offsetWidth, 42, "width was animated" );
- equals( this.offsetHeight, 42, "height was animated" );
- start();
- });
+
+ var span = jQuery("
").css("display", "inline-block").appendTo("body"),
+ expected = span.css("display");
+
+ span.remove();
+
+ if ( jQuery.support.inlineBlockNeedsLayout || expected === "inline-block" ) {
+ stop();
+
+ jQuery("#foo").css({ display: "inline", width: '', height: '' }).animate({ width: 42, height: 42 }, 100, function() {
+ equals( jQuery(this).css("display"), jQuery.support.inlineBlockNeedsLayout ? "inline" : "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
+ equals( this.offsetWidth, 42, "width was animated" );
+ equals( this.offsetHeight, 42, "height was animated" );
+ start();
+ });
+
+ // Browser doesn't support inline-block
+ } else {
+ ok( true, "Browser doesn't support inline-block" );
+ ok( true, "Browser doesn't support inline-block" );
+ ok( true, "Browser doesn't support inline-block" );
+ }
});
test("animate native inline width/height", function() {
expect(3);
- stop();
- jQuery("#foo").css({ display: "", width: '', height: '' })
- .append('text')
- .children('span')
- .animate({ width: 42, height: 42 }, 100, function() {
- equals( jQuery(this).css("display"), "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
- equals( this.offsetWidth, 42, "width was animated" );
- equals( this.offsetHeight, 42, "height was animated" );
- start();
- });
+
+ var span = jQuery("").css("display", "inline-block").appendTo("body"),
+ expected = span.css("display");
+
+ span.remove();
+
+ if ( jQuery.support.inlineBlockNeedsLayout || expected === "inline-block" ) {
+ stop();
+ jQuery("#foo").css({ display: "", width: '', height: '' })
+ .append('text')
+ .children('span')
+ .animate({ width: 42, height: 42 }, 100, function() {
+ equals( jQuery(this).css("display"), "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
+ equals( this.offsetWidth, 42, "width was animated" );
+ equals( this.offsetHeight, 42, "height was animated" );
+ start();
+ });
+
+ // Browser doesn't support inline-block
+ } else {
+ ok( true, "Browser doesn't support inline-block" );
+ ok( true, "Browser doesn't support inline-block" );
+ ok( true, "Browser doesn't support inline-block" );
+ }
});
test("animate block width/height", function() {
@@ -468,6 +560,23 @@ jQuery.checkOverflowDisplay = function(){
start();
}
+test("support negative values < -10000 (bug #7193)", function () {
+ expect(1);
+ stop();
+
+ jQuery.extend(jQuery.fx.step, {
+ "marginBottom": function(fx) {
+ equals( fx.cur(), -11000, "Element has margin-bottom of -11000" );
+ delete jQuery.fx.step.marginBottom;
+ }
+ });
+
+ jQuery("#main").css("marginBottom", "-11000px").animate({ marginBottom: "-11001px" }, {
+ duration: 1,
+ complete: start
+ });
+});
+
test("JS Overflow and Display", function() {
expect(2);
stop();
@@ -701,6 +810,13 @@ test("Chain slideToggle out", function() {
jQuery('#slidetoggleout div').saveState(jQuery.support.shrinkWrapBlocks).slideToggle('fast').slideToggle('fast',jQuery.checkState);
});
+test("Chain fadeToggle in", function() {
+ jQuery('#fadetogglein div').saveState().fadeToggle('fast').fadeToggle('fast',jQuery.checkState);
+});
+test("Chain fadeToggle out", function() {
+ jQuery('#fadetoggleout div').saveState().fadeToggle('fast').fadeToggle('fast',jQuery.checkState);
+});
+
test("Chain fadeTo 0.5 1.0 with easing and callback)", function() {
jQuery('#fadeto div').saveState().fadeTo('fast',0.5).fadeTo('fast',1.0,'linear',jQuery.checkState);
});
@@ -771,3 +887,33 @@ test("animate with per-property easing", function(){
});
});
+
+test("hide hidden elements (bug #7141)", function() {
+ expect(3);
+ QUnit.reset();
+
+ var div = jQuery("").appendTo("#main");
+ equals( div.css("display"), "none", "Element is hidden by default" );
+ div.hide();
+ ok( !div.data("olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
+ div.show();
+ equals( div.css("display"), "block", "Show a double-hidden element" );
+
+ div.remove();
+});
+
+test("hide hidden elements, with animation (bug #7141)", function() {
+ expect(3);
+ QUnit.reset();
+ stop();
+
+ var div = jQuery("").appendTo("#main");
+ equals( div.css("display"), "none", "Element is hidden by default" );
+ div.hide(1, function () {
+ ok( !div.data("olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
+ div.show(1, function () {
+ equals( div.css("display"), "block", "Show a double-hidden element" );
+ start();
+ });
+ });
+});