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

Code before:
		$span.show();

		display = $span.css( "display" );

		$span.hide();

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

		clock.tick( 300 );

		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>" +
			"<div id='shadowChild' class='hidden'></div>";
		var shadowChild = shadowRoot.querySelector( "#shadowChild" );

		var $shadowChild = jQuery( shadowChild );
		$shadowChild.fadeIn( 100, function() {
			assert.equal( $shadowChild.css( "display" ), "block", "Expecting shadow display: " + "block" );
			$shadowChild.fadeOut( 100, function() {
				assert.equal( $shadowChild.css( "display" ), "none", "Expecting shadow display: " + "none" );
				$shadowChild.fadeIn( 100, function() {
					assert.equal( $shadowChild.css( "display" ), "block", "Expecting shadow display: " + "block" );
				} );
			} );
		} );

		clock.tick( 300 );

		assert.expectJqData( this, $span, "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):
This needs to be put in a separate `QUnit.test` block so that the test can be skipped in browsers not supporting Shadow DOM - as in other test files.

Code after:
		$span.show();

		display = $span.css( "display" );

		$span.hide();

		$span.fadeIn( 100, function() {
			assert.equal( $span.css( "display" ), display, "Expecting display: " + display );
			$span.fadeOut( 100, function() {
				assert.equal( $span.css( "display" ), displayNone, "Expecting display: " + displayNone );
				$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" );