aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/effects.js
diff options
context:
space:
mode:
authorCorey Frang <gnarf@gnarf.net>2012-06-22 16:03:39 -0400
committerDave Methvin <dave.methvin@gmail.com>2012-06-22 16:11:12 -0400
commit36369ce50ff276dcf2959add7dc949af83b221c2 (patch)
tree6827c650b64c27a4b67d73d1a2bc16e79cdcc5a6 /test/unit/effects.js
parent9bb3494ce99889e05a7333e38e4da9579ce6af8e (diff)
downloadjquery-36369ce50ff276dcf2959add7dc949af83b221c2.tar.gz
jquery-36369ce50ff276dcf2959add7dc949af83b221c2.zip
Fix #11797. Use Deferred for better animation callbacks. Closes gh-830.
In particular, an animation stopped with `gotoEnd` will be rejected.
Diffstat (limited to 'test/unit/effects.js')
-rw-r--r--test/unit/effects.js69
1 files changed, 65 insertions, 4 deletions
diff --git a/test/unit/effects.js b/test/unit/effects.js
index 96fa6cc29..56951d360 100644
--- a/test/unit/effects.js
+++ b/test/unit/effects.js
@@ -1369,7 +1369,7 @@ test("Do not append px to 'fill-opacity' #9548", 1, function() {
});
// Start 1.8 Animation tests
-asyncTest( "jQuery.Animation( object, props, opts )", 1, function() {
+asyncTest( "jQuery.Animation( object, props, opts )", 4, function() {
var testObject = {
foo: 0,
bar: 1,
@@ -1381,11 +1381,16 @@ asyncTest( "jQuery.Animation( object, props, opts )", 1, function() {
width: 200
};
- jQuery.Animation( testObject, testDest, { duration: 1 })
- .done( function() {
- deepEqual( testObject, testDest, "Animated foo and bar" );
+ var animation = jQuery.Animation( testObject, testDest, { duration: 1 });
+ animation.done(function() {
+ for ( var prop in testDest ) {
+ equal( testObject[ prop ], testDest[ prop ], "Animated: " + prop );
+ }
+ animation.done(function() {
+ deepEqual( testObject, testDest, "No unexpected properties" );
start();
});
+ });
});
asyncTest( "Animate Option: step: function( percent, tween )", 1, function() {
@@ -1660,4 +1665,60 @@ asyncTest( "animate does not change start value for non-px animation (#7109)", 1
});
});
+asyncTest("Animation callbacks (#11797)", 8, function() {
+ var targets = jQuery("#foo").children(),
+ done = false;
+
+ targets.eq( 0 ).animate( {}, {
+ duration: 10,
+ done: function() {
+ ok( true, "empty: done" );
+ },
+ fail: function() {
+ ok( false, "empty: fail" );
+ },
+ always: function() {
+ ok( true, "empty: always" );
+ done = true;
+ }
+ });
+
+ ok( done, "animation done" );
+
+ done = false;
+ targets.eq( 1 ).animate({
+ opacity: 0
+ }, {
+ duration: 10,
+ done: function() {
+ ok( false, "stopped: done" );
+ },
+ fail: function() {
+ ok( true, "stopped: fail" );
+ },
+ always: function() {
+ ok( true, "stopped: always" );
+ done = true;
+ }
+ }).stop();
+
+ ok( done, "animation stopped" );
+
+ targets.eq( 2 ).animate({
+ opacity: 0
+ }, {
+ duration: 10,
+ done: function() {
+ ok( true, "async: done" );
+ },
+ fail: function() {
+ ok( false, "async: fail" );
+ },
+ always: function() {
+ ok( true, "async: always" );
+ start();
+ }
+ });
+});
+
} // if ( jQuery.fx )