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(){ $foo.animate({ "width": "show" }, 400, "linear");
equal( $foo.queue().length, 3, "All 3 still in the queue" ); $foo.animate({ "width": "hide" });
var nw = $foo.css("width"); $foo.animate({ "width": "show" });
notEqual( parseFloat( nw ), w, "An animation occurred " + nw + " " + w + "px");
// could be replaced by something nicer using sinon.
time = jQuery.now();
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(); $foo.stop();
nw = $foo.css("width"); equal( $foo.queue().length, 2, "2 in the queue" );
notEqual( parseFloat( nw ), w, "Stop didn't reset the animation " + nw + " " + w + "px"); nw = $foo.css( "width" );
notEqual( parseFloat( nw ), 1, "Stop didn't reset the animation " + nw );
$foo.stop(true); $foo.stop( true );
start();
}, 200); 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