Backing out commit 795e880bba1f7f949df58748f7fd92e50296a8f4 - errors popping up in...
[jquery.git] / test / unit / effects.js
index 2dfe834..74b336f 100644 (file)
@@ -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("<div>").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;
@@ -127,27 +152,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("<span>").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('<span>text</span>')
-               .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("<span>").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('<span>text</span>')
+                       .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() {
@@ -700,6 +754,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);
 });