From c27d8e298832b25836dc6ff698cd8400ef207e13 Mon Sep 17 00:00:00 2001 From: Corey Frang Date: Tue, 8 Jan 2013 01:16:50 +0000 Subject: Fix #13103. Add .finish() method. Cherry picked from b6abb31df4d5be80dc13844d9988fb0c990ae5ae. --- test/unit/effects.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'test/unit') diff --git a/test/unit/effects.js b/test/unit/effects.js index b615dfd6d..965e9969e 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -1904,4 +1904,53 @@ test( "jQuery.fx.start & jQuery.fx.stop hook points", function() { jQuery.fx.stop = oldStop; }); +test( ".finish() completes all queued animations", function() { + var animations = { + top: 100, + left: 100, + height: 100, + width: 100 + }, + div = jQuery("
"); + + expect( 11 ); + + jQuery.each( animations, function( prop, value ) { + var anim = {}; + anim[ prop ] = value; + // the delay shouldn't matter at all! + div.css( prop, 1 ).animate( anim, function() { + ok( true, "Called animation callback" ); + }).delay( 100 ); + }); + equal( div.queue().length, 8, "8 animations in the queue" ); + div.finish(); + jQuery.each( animations, function( prop, value ) { + equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" ); + }); + equal( div.queue().length, 0, "empty queue when done" ); + equal( div.is(":animated"), false, ":animated doesn't match" ); + + // cleanup + div.remove(); + // leaves a "shadow timer" which does nothing around, need to force a tick + jQuery.fx.tick(); +}); + +test( ".finish() calls finish of custom queue functions", function() { + function queueTester( next ) { + + } + var div = jQuery( "
" ); + + expect( 3 ); + queueTester.finish = function() { + ok( true, "Finish called on custom queue function" ); + }; + + div.queue( queueTester ).queue( queueTester ).queue( queueTester ).finish(); + + div.remove(); +}); + } // if ( jQuery.fx ) -- cgit v1.2.3