Skip to content

Commit 4eef88c

Browse files
committed
Add unit tests for animation toggling from hide position. Supplements #10848.
1 parent e8673ae commit 4eef88c

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

test/unit/effects.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,25 +1146,42 @@ jQuery.each({
11461146
},
11471147
function( method, defProp ) {
11481148
test( method + "().stop()." + method + "()", function() {
1149-
expect( 4 );
1149+
expect( 8 );
1150+
1151+
var animTime = 100;
11501152

11511153
jQuery.each([ "in", "out" ], function( i, type ) {
11521154
var $elem = jQuery( "#" + method.toLowerCase() + type ),
11531155
startVal = defProp( $elem );
11541156

1155-
$elem[ method ]("fast");
1157+
$elem[ method ]( animTime );
11561158
stop();
11571159

11581160
setTimeout( function() {
11591161
$elem.stop();
11601162

11611163
notEqual( defProp( $elem ), startVal, ".stop() is called about halfway through animation." );
11621164

1163-
$elem[ method ]("fast", function() {
1164-
equal( defProp( jQuery(this) ), startVal, "After doing .stop() halfway, check that state has been saved for returning to original property value." );
1165-
start();
1165+
$elem[ method ](animTime, function() {
1166+
equal( defProp( $elem ), startVal, "After doing .stop() halfway through hide, check that state has been saved for returning to original property value." );
1167+
1168+
// Start from hidden position to show this time
1169+
$elem.hide()[ method ]( animTime );
1170+
setTimeout( function() {
1171+
$elem.stop();
1172+
1173+
notEqual( defProp( $elem ), startVal, ".stop() is called about halfway through animation." );
1174+
1175+
$elem[ method ](animTime, function() {
1176+
equal( defProp( $elem ), startVal, "After doing .stop() halfway through show, check that state has been saved for returning to original property value." );
1177+
1178+
// Remove olddisplay data from .hide() call
1179+
jQuery.removeData( this, "olddisplay", true );
1180+
start();
1181+
});
1182+
}, animTime / 2);
11661183
});
1167-
}, 100);
1184+
}, animTime / 2);
11681185
});
11691186
});
11701187
});

0 commit comments

Comments
 (0)