aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorCorey Frang <gnarf@gnarf.net>2011-09-28 11:55:29 -0400
committertimmywil <timmywillisn@gmail.com>2011-09-28 11:55:29 -0400
commita3b59d7f92c9e15af1888fc4e87639a290763a50 (patch)
treecc533a93c3c0a02fae95018b3447b94927e5ff2e /test
parenta74cbb2b911b3afad96599728208d95a60d24cbf (diff)
downloadjquery-a3b59d7f92c9e15af1888fc4e87639a290763a50.tar.gz
jquery-a3b59d7f92c9e15af1888fc4e87639a290763a50.zip
Landing pull request 514. 1.7 - queue refactoring to handle delay stop - Fixes #6150.
More Details: - https://github.com/jquery/jquery/pull/514 - http://bugs.jquery.com/ticket/6150
Diffstat (limited to 'test')
-rw-r--r--test/unit/effects.js54
-rw-r--r--test/unit/queue.js38
2 files changed, 91 insertions, 1 deletions
diff --git a/test/unit/effects.js b/test/unit/effects.js
index d13bd587c..da1dd0a62 100644
--- a/test/unit/effects.js
+++ b/test/unit/effects.js
@@ -357,9 +357,26 @@ test("animate option (queue === false)", function () {
});
*/
+asyncTest( "animate option { queue: false }", function() {
+ expect( 2 );
+ var foo = jQuery( "#foo" );
+
+ foo.animate({
+ fontSize: "2em"
+ }, {
+ queue: false,
+ duration: 10,
+ complete: function() {
+ ok( true, "Animation Completed" );
+ start();
+ }
+ });
+
+ equals( foo.queue().length, 0, "Queue is empty" );
+});
+
asyncTest( "animate option { queue: 'name' }", function() {
expect( 5 );
-
var foo = jQuery( "#foo" ),
origWidth = foo.width(),
order = [];
@@ -608,6 +625,41 @@ test("stop(clearQueue, gotoEnd)", function() {
}, 100);
});
+asyncTest( "stop( ..., ..., queue ) - Stop single queues", function() {
+ expect( 3 );
+ var foo = jQuery( "#foo" ),
+ saved;
+
+ foo.width( 200 ).height( 200 );
+ foo.animate({
+ width: 400
+ },{
+ duration: 1000,
+ complete: function() {
+ equals( foo.width(), 400, "Animation completed for standard queue" );
+ equals( foo.height(), saved, "Height was not changed after the second stop")
+ start();
+ }
+ });
+
+ foo.animate({
+ height: 400
+ },{
+ duration: 1000,
+ queue: "height"
+ }).dequeue( "height" ).stop( false, true, "height" );
+
+ equals( foo.height(), 400, "Height was stopped with gotoEnd" );
+
+ foo.animate({
+ height: 200
+ },{
+ duration: 1000,
+ queue: "height"
+ }).dequeue( "height" ).stop( false, false, "height" );
+ saved = foo.height();
+})
+
test("toggle()", function() {
expect(6);
var x = jQuery("#foo");
diff --git a/test/unit/queue.js b/test/unit/queue.js
index b5c058caa..95bbfc97e 100644
--- a/test/unit/queue.js
+++ b/test/unit/queue.js
@@ -130,6 +130,44 @@ test("delay()", function() {
equals( run, 0, "The delay delayed the next function from running." );
});
+test("delay() can be stopped", function() {
+ expect( 3 );
+ stop();
+
+ var foo = jQuery({}), run = 0;
+
+ foo
+ .queue( "alternate", function( next ) {
+ run++;
+ ok( true, "This first function was dequeued" );
+ next();
+ })
+ .delay( 100, "alternate" )
+ .queue( "alternate", function() {
+ run++;
+ ok( true, "The function was dequeued immediately, the delay was stopped" );
+ })
+ .dequeue( "alternate" )
+
+ // stop( false ) will NOT clear the queue, so it should automatically dequeue the next
+ .stop( false, false, "alternate" )
+
+ // this test
+ .delay( 100 )
+ .queue(function() {
+ run++;
+ ok( false, "This queue should never run" );
+ })
+
+ // stop( clearQueue ) should clear the queue
+ .stop( true, false );
+
+ equal( run, 2, "Queue ran the proper functions" );
+
+ setTimeout( start, 200 );
+});
+
+
test("clearQueue(name) clears the queue", function() {
expect(2);