diff options
author | Corey Frang <gnarf@gnarf.net> | 2013-01-08 03:33:01 -0600 |
---|---|---|
committer | Corey Frang <gnarf@gnarf.net> | 2013-01-09 11:40:33 -0600 |
commit | 58003c44ff09cc3142eeddc5bf63f9694d32e3c4 (patch) | |
tree | c152f6de1be856595dcbc332165696ea058e58dd /test | |
parent | 46bbda8d060165bc734e4e84c30b1d62f3ebce27 (diff) | |
download | jquery-58003c44ff09cc3142eeddc5bf63f9694d32e3c4.tar.gz jquery-58003c44ff09cc3142eeddc5bf63f9694d32e3c4.zip |
Adding some more test coverage for .finish()
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/effects.js | 73 |
1 files changed, 72 insertions, 1 deletions
diff --git a/test/unit/effects.js b/test/unit/effects.js index 965e9969e..1edecc07a 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -1920,7 +1920,7 @@ test( ".finish() completes all queued animations", function() { anim[ prop ] = value; // the delay shouldn't matter at all! div.css( prop, 1 ).animate( anim, function() { - ok( true, "Called animation callback" ); + ok( true, "Called animation callback for " + prop ); }).delay( 100 ); }); equal( div.queue().length, 8, "8 animations in the queue" ); @@ -1937,6 +1937,77 @@ test( ".finish() completes all queued animations", function() { jQuery.fx.tick(); }); +test( ".finish( false ) - unqueued animations", function() { + var animations = { + top: 100, + left: 100, + height: 100, + width: 100 + }, + div = jQuery("<div>"); + + expect( 10 ); + + jQuery.each( animations, function( prop, value ) { + var anim = {}; + anim[ prop ] = value; + div.css( prop, 1 ).animate( anim, { + queue: false, + complete: function() { + ok( true, "Called animation callback for " + prop ); + } + }); + }); + equal( div.queue().length, 0, "0 animations in the queue" ); + div.finish( false ); + jQuery.each( animations, function( prop, value ) { + equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" ); + }); + 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( \"custom\" ) - custom queue 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; + div.css( prop, 1 ).animate( anim, { + queue: "custom", + complete: function() { + ok( true, "Called animation callback for " + prop ); + } + }); + }); + equal( div.queue( "custom" ).length, 4, "4 animations in the queue" ); + // start the first animation + div.dequeue( "custom" ); + equal( div.is(":animated"), true, ":animated matches" ); + div.finish( "custom" ); + jQuery.each( animations, function( prop, value ) { + equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" ); + }); + 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 ) { |