From a3b59d7f92c9e15af1888fc4e87639a290763a50 Mon Sep 17 00:00:00 2001 From: Corey Frang Date: Wed, 28 Sep 2011 11:55:29 -0400 Subject: 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 --- test/unit/queue.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'test/unit/queue.js') 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); -- cgit v1.2.3