Commit 08894dcc authored by Corey Frang's avatar Corey Frang

Rewriting unit test to be less sticky based on time issues

(cherry picked from commit 31a19a80)
parent 986d0f59
...@@ -597,28 +597,37 @@ test("stop()", function() { ...@@ -597,28 +597,37 @@ test("stop()", function() {
}); });
test("stop() - several in queue", function() { test("stop() - several in queue", function() {
expect(3); expect( 5 );
stop();
var $foo = jQuery("#foo"); var nw, time,
var w = 0; $foo = jQuery( "#foo" ),
$foo.hide( 1000 ).css( "width", 200 ).css("width"); w = 0;
$foo.animate({ "width": "show" }, 1500); // default duration is 400ms, so 800px ensures we aren't 0 or 1 after 1ms
$foo.animate({ "width": "hide" }, 1000); $foo.hide().css( "width", 800 );
$foo.animate({ "width": "show" }, 1000);
setTimeout(function(){
equal( $foo.queue().length, 3, "All 3 still in the queue" );
var nw = $foo.css("width");
notEqual( parseFloat( nw ), w, "An animation occurred " + nw + " " + w + "px");
$foo.stop();
nw = $foo.css("width"); $foo.animate({ "width": "show" }, 400, "linear");
notEqual( parseFloat( nw ), w, "Stop didn't reset the animation " + nw + " " + w + "px"); $foo.animate({ "width": "hide" });
$foo.animate({ "width": "show" });
$foo.stop(true); // could be replaced by something nicer using sinon.
start(); time = jQuery.now();
}, 200); while( time === jQuery.now() ) {}
jQuery.fx.tick();
equal( $foo.queue().length, 3, "3 in the queue" );
nw = $foo.css( "width" );
notEqual( parseFloat( nw ), 1, "An animation occurred " + nw );
$foo.stop();
equal( $foo.queue().length, 2, "2 in the queue" );
nw = $foo.css( "width" );
notEqual( parseFloat( nw ), 1, "Stop didn't reset the animation " + nw );
$foo.stop( true );
equal( $foo.queue().length, 0, "0 in the queue" );
}); });
test("stop(clearQueue)", function() { test("stop(clearQueue)", function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment