Repository: jquery/jquery
File: test/unit/effects.js (JavaScript)

Code before:
				$span.fadeIn( 100, function() {
					assert.equal( $span.css( "display" ), display, "Expecting display: " + display );
				} );
			} );
		} );

		clock.tick( 300 );

		assert.expectJqData( this, $span, "olddisplay" );
	} );

	QUnit[ document.body.attachShadow ? "test" : "skip" ](
		"Persist correct display value - " + type + " hidden, shadow child", function( assert ) {
		assert.expect( 3 );

		jQuery( "<div id='shadowHost'></div>" ).appendTo( "#qunit-fixture" );

		var shadowHost = document.querySelector( "#shadowHost" );
		var shadowRoot = shadowHost.attachShadow( { mode: "open" } );
		shadowRoot.innerHTML = "<style>.hidden{display: none;}</style>" +
			"<span id='shadowChild' class='hidden'></span>";
		var shadowChild = shadowRoot.querySelector( "#shadowChild" );

		var $shadowChild = jQuery( shadowChild );
		var displayNone = $shadowChild.css( "display" );
		var display = "block";
		var clock = this.clock;

		$shadowChild.fadeIn( 100, function() {
			assert.equal( $shadowChild.css( "display" ), display, "Expecting shadow display: " + display );
			$shadowChild.fadeOut( 100, function() {
				assert.equal( $shadowChild.css( "display" ), displayNone, "Expecting shadow display: " + displayNone );
				$shadowChild.fadeIn( 100, function() {
					assert.equal( $shadowChild.css( "display" ), display, "Expecting shadow display: " + display );
				} );
			} );
		} );

		clock.tick( 300 );

		assert.expectJqData( this, $shadowChild, "olddisplay" );
	} );
} );

QUnit.test( "animate(Hash, Object, Function)", function( assert ) {
	assert.expect( 1 );
	var hash = { opacity: "show" },
		hashCopy = jQuery.extend( {}, hash );
	jQuery( "#foo" ).animate( hash, 0, function() {
		assert.equal( hash.opacity, hashCopy.opacity, "Check if animate changed the hash parameter" );
	} );

Review comment (suggestion):
@gibson042 Note that this hardcodes `"block"` as opposed to the non-shadow test above this one. But, as @SaptakS made me realize - the check for `$span.css( "display" )` in the non-shadow test requires to show the element and later hide it which changes how the element is hidden so the test doesn't really seem to test what it should. Also, in both cases, the expected value is `"block"` so it doesn't make sense to compute it during the test.

What do you think about changing the non-shadow test to avoid this check? (outside of this PR, of course).

Code after:
				$span.fadeIn( 100, function() {
					assert.equal( $span.css( "display" ), display, "Expecting display: " + display );
				} );
			} );
		} );

		clock.tick( 300 );

		assert.expectJqData( this, $span, "olddisplay" );
	} );

	QUnit[ document.body.attachShadow ? "test" : "skip" ](
		"Persist correct display value - " + type + " hidden, shadow child", function( assert ) {
		assert.expect( 3 );

		jQuery( "<div id='shadowHost'></div>" ).appendTo( "#qunit-fixture" );

		var shadowHost = document.querySelector( "#shadowHost" );
		var shadowRoot = shadowHost.attachShadow( { mode: "open" } );
		shadowRoot.innerHTML = "<style>.hidden{display: none;}</style>" +
			"<span id='shadowChild' class='hidden'></span>";
		var shadowChild = shadowRoot.querySelector( "#shadowChild" );

		var $shadowChild = jQuery( shadowChild );
		var displayNone = "none";
		var display = "inline";
		var clock = this.clock;

		$shadowChild.fadeIn( 100, function() {
			assert.equal( $shadowChild.css( "display" ), display, "Expecting shadow display: " + display );
			$shadowChild.fadeOut( 100, function() {
				assert.equal( $shadowChild.css( "display" ), displayNone, "Expecting shadow display: " + displayNone );
				$shadowChild.fadeIn( 100, function() {
					assert.equal( $shadowChild.css( "display" ), display, "Expecting shadow display: " + display );
				} );
			} );
		} );

		clock.tick( 300 );

		assert.expectJqData( this, $shadowChild, "olddisplay" );
	} );
} );

QUnit.test( "animate(Hash, Object, Function)", function( assert ) {
	assert.expect( 1 );
	var hash = { opacity: "show" },
		hashCopy = jQuery.extend( {}, hash );
	jQuery( "#foo" ).animate( hash, 0, function() {
		assert.equal( hash.opacity, hashCopy.opacity, "Check if animate changed the hash parameter" );
	} );