diff options
author | Corey Frang <gnarf@gnarf.net> | 2013-01-08 01:16:50 +0000 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2013-01-08 01:23:22 +0000 |
commit | c27d8e298832b25836dc6ff698cd8400ef207e13 (patch) | |
tree | dbd52a3b84e830cc2f024d09644bf957deec78de /test/unit | |
parent | 4e0bc169df0f6dee45fe7c19925216453b431ebb (diff) | |
download | jquery-c27d8e298832b25836dc6ff698cd8400ef207e13.tar.gz jquery-c27d8e298832b25836dc6ff698cd8400ef207e13.zip |
Fix #13103. Add .finish() method. Cherry picked from b6abb31df4d5be80dc13844d9988fb0c990ae5ae.
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/effects.js | 49 |
1 files changed, 49 insertions, 0 deletions
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("<div>"); + + 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( "<div>" ); + + 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 ) |