aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/effects.js
diff options
context:
space:
mode:
authorCorey Frang <gnarf@gnarf.net>2012-05-22 23:04:45 -0400
committerDave Methvin <dave.methvin@gmail.com>2012-05-22 23:04:45 -0400
commit4621a0131b98461e41082aa0aaf73f9c6f4ca9ce (patch)
tree49288a493e5e4bcd6205409f106caac09fc0e5d9 /test/unit/effects.js
parentae20e732f02c7e3bdd76324979b1a816c567ec22 (diff)
downloadjquery-4621a0131b98461e41082aa0aaf73f9c6f4ca9ce.tar.gz
jquery-4621a0131b98461e41082aa0aaf73f9c6f4ca9ce.zip
Optimizations to animation queue/promise logic, closes gh-776.
Diffstat (limited to 'test/unit/effects.js')
-rw-r--r--test/unit/effects.js81
1 files changed, 81 insertions, 0 deletions
diff --git a/test/unit/effects.js b/test/unit/effects.js
index fed25eeb0..a2645b106 100644
--- a/test/unit/effects.js
+++ b/test/unit/effects.js
@@ -1628,3 +1628,84 @@ asyncTest( "hide, fadeOut and slideUp called on element width height and width =
start();
});
});
+
+asyncTest( "Handle queue:false promises", 10, function() {
+ var foo = jQuery( "#foo" ).clone().andSelf(),
+ step = 1;
+
+ foo.animate({
+ top: 1
+ }, {
+ duration: 10,
+ queue: false,
+ complete: function() {
+ ok( step++ <= 2, "Step one or two" );
+ }
+ }).animate({
+ bottom: 1
+ }, {
+ duration: 10,
+ complete: function() {
+ ok( step > 2 && step < 5, "Step three or four" );
+ step++;
+ }
+ });
+
+ foo.promise().done( function() {
+ equal( step++, 5, "steps 1-5: queue:false then queue:fx done" );
+ foo.animate({
+ top: 10
+ }, {
+ duration: 10,
+ complete: function() {
+ ok( step > 5 && step < 8, "Step six or seven" );
+ step++;
+ }
+ }).animate({
+ bottom: 10
+ }, {
+ duration: 10,
+ queue: false,
+ complete: function() {
+ ok( step > 7 && step < 10, "Step eight or nine" );
+ step++;
+ }
+ }).promise().done( function() {
+ equal( step++, 10, "steps 6-10: queue:fx then queue:false" );
+ start();
+ });
+
+ });
+});
+
+asyncTest( "multiple unqueued and promise", 4, function() {
+ var foo = jQuery( "#foo" ),
+ step = 1;
+ foo.animate({
+ marginLeft: 300
+ }, {
+ duration: 500,
+ queue: false,
+ complete: function() {
+ strictEqual( step++, 2, "Step 2" );
+ }
+ }).animate({
+ top: 100
+ }, {
+ duration: 1500,
+ queue: false,
+ complete: function() {
+ strictEqual( step++, 3, "Step 3" );
+ }
+ }).animate({}, {
+ duration: 2000,
+ queue: false,
+ complete: function() {
+ // no properties is a non-op and finishes immediately
+ strictEqual( step++, 1, "Step 1" );
+ }
+ }).promise().done( function() {
+ strictEqual( step++, 4, "Step 4" );
+ start();
+ });
+}); \ No newline at end of file