2019-02-18 18:02:38 +00:00
|
|
|
QUnit.module( "queue", { afterEach: moduleTeardown } );
|
2009-12-06 22:19:33 +00:00
|
|
|
|
2020-01-07 22:59:08 +00:00
|
|
|
( function() {
|
|
|
|
|
2022-06-28 10:39:01 +00:00
|
|
|
if ( !includesModule( "queue" ) ) {
|
2020-01-07 22:59:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-16 03:45:28 +00:00
|
|
|
QUnit.test( "queue() with other types", function( assert ) {
|
2019-02-18 18:02:38 +00:00
|
|
|
var done = assert.async( 2 );
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.expect( 14 );
|
2015-07-29 15:10:04 +00:00
|
|
|
|
2011-04-11 11:40:14 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
var $div = jQuery( {} ),
|
2013-04-09 15:45:09 +00:00
|
|
|
counter = 0;
|
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
$div.promise( "foo" ).done( function() {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.equal( counter, 0, "Deferred for collection with no queue is automatically resolved" );
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-06 22:19:33 +00:00
|
|
|
$div
|
2015-08-16 06:59:58 +00:00
|
|
|
.queue( "foo", function() {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.equal( ++counter, 1, "Dequeuing" );
|
2015-08-16 06:59:58 +00:00
|
|
|
jQuery.dequeue( this, "foo" );
|
|
|
|
} )
|
|
|
|
.queue( "foo", function() {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.equal( ++counter, 2, "Dequeuing" );
|
2015-08-16 06:59:58 +00:00
|
|
|
jQuery( this ).dequeue( "foo" );
|
|
|
|
} )
|
|
|
|
.queue( "foo", function() {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.equal( ++counter, 3, "Dequeuing" );
|
2015-08-16 06:59:58 +00:00
|
|
|
} )
|
|
|
|
.queue( "foo", function() {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.equal( ++counter, 4, "Dequeuing" );
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
$div.promise( "foo" ).done( function() {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.equal( counter, 4, "Testing previous call to dequeue in deferred" );
|
2019-02-18 18:02:38 +00:00
|
|
|
done();
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2011-04-11 11:40:14 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
assert.equal( $div.queue( "foo" ).length, 4, "Testing queue length" );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2022-01-04 15:27:18 +00:00
|
|
|
assert.equal( $div.queue( "foo", undefined ).queue( "foo" ).length, 4, ".queue('name',undefined) does nothing but is chainable (trac-5571)" );
|
2011-12-06 20:25:38 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
$div.dequeue( "foo" );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.equal( counter, 3, "Testing previous call to dequeue" );
|
2015-08-16 06:59:58 +00:00
|
|
|
assert.equal( $div.queue( "foo" ).length, 1, "Testing queue length" );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
$div.dequeue( "foo" );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.equal( counter, 4, "Testing previous call to dequeue" );
|
2015-08-16 06:59:58 +00:00
|
|
|
assert.equal( $div.queue( "foo" ).length, 0, "Testing queue length" );
|
2012-08-13 17:43:49 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
$div.dequeue( "foo" );
|
2012-08-13 17:43:49 +00:00
|
|
|
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.equal( counter, 4, "Testing previous call to dequeue" );
|
2015-08-16 06:59:58 +00:00
|
|
|
assert.equal( $div.queue( "foo" ).length, 0, "Testing queue length" );
|
2019-02-18 18:02:38 +00:00
|
|
|
done();
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2009-12-06 22:19:33 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
QUnit.test( "queue(name) passes in the next item in the queue as a parameter", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
var div = jQuery( {} ),
|
2013-04-09 15:45:09 +00:00
|
|
|
counter = 0;
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
div.queue( "foo", function( next ) {
|
|
|
|
assert.equal( ++counter, 1, "Dequeueing" );
|
2009-12-06 22:19:33 +00:00
|
|
|
next();
|
2015-08-16 06:59:58 +00:00
|
|
|
} ).queue( "foo", function( next ) {
|
|
|
|
assert.equal( ++counter, 2, "Next was called" );
|
2009-12-06 22:19:33 +00:00
|
|
|
next();
|
2015-08-16 06:59:58 +00:00
|
|
|
} ).queue( "bar", function() {
|
|
|
|
assert.equal( ++counter, 3, "Other queues are not triggered by next()" );
|
|
|
|
} );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
div.dequeue( "foo" );
|
|
|
|
} );
|
2009-12-06 22:19:33 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
QUnit.test( "queue() passes in the next item in the queue as a parameter to fx queues", function( assert ) {
|
2019-02-18 18:02:38 +00:00
|
|
|
var done = assert.async();
|
2015-08-16 06:59:58 +00:00
|
|
|
assert.expect( 3 );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
var div = jQuery( {} ),
|
2013-04-09 15:45:09 +00:00
|
|
|
counter = 0;
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
div.queue( function( next ) {
|
|
|
|
assert.equal( ++counter, 1, "Dequeueing" );
|
2023-09-18 16:39:00 +00:00
|
|
|
setTimeout( function() {
|
|
|
|
next();
|
|
|
|
}, 500 );
|
2015-08-16 06:59:58 +00:00
|
|
|
} ).queue( function( next ) {
|
|
|
|
assert.equal( ++counter, 2, "Next was called" );
|
2009-12-06 22:19:33 +00:00
|
|
|
next();
|
2015-08-16 06:59:58 +00:00
|
|
|
} ).queue( "bar", function() {
|
|
|
|
assert.equal( ++counter, 3, "Other queues are not triggered by next()" );
|
|
|
|
} );
|
2009-12-06 22:19:33 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
jQuery.when( div.promise( "fx" ), div ).done( function() {
|
|
|
|
assert.equal( counter, 2, "Deferreds resolved" );
|
2019-02-18 18:02:38 +00:00
|
|
|
done();
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
|
|
|
} );
|
2011-05-11 18:31:42 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
QUnit.test( "callbacks keep their place in the queue", function( assert ) {
|
2019-02-18 18:02:38 +00:00
|
|
|
var done = assert.async();
|
2015-08-16 06:59:58 +00:00
|
|
|
assert.expect( 5 );
|
|
|
|
var div = jQuery( "<div>" ),
|
2011-05-11 18:31:42 +00:00
|
|
|
counter = 0;
|
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
div.queue( function( next ) {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.equal( ++counter, 1, "Queue/callback order: first called" );
|
2011-05-11 18:31:42 +00:00
|
|
|
setTimeout( next, 200 );
|
2015-08-16 06:59:58 +00:00
|
|
|
} ).delay( 100 ).queue( function( next ) {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.equal( ++counter, 2, "Queue/callback order: second called" );
|
2015-08-16 06:59:58 +00:00
|
|
|
jQuery( this ).delay( 100 ).queue( function( next ) {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.equal( ++counter, 4, "Queue/callback order: fourth called" );
|
2012-05-29 02:25:04 +00:00
|
|
|
next();
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2012-05-29 02:25:04 +00:00
|
|
|
next();
|
2015-08-16 06:59:58 +00:00
|
|
|
} ).queue( function( next ) {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.equal( ++counter, 3, "Queue/callback order: third called" );
|
2011-05-11 18:31:42 +00:00
|
|
|
next();
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2011-04-11 11:40:14 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
div.promise( "fx" ).done( function() {
|
|
|
|
assert.equal( counter, 4, "Deferreds resolved" );
|
2019-02-18 18:02:38 +00:00
|
|
|
done();
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
|
|
|
} );
|
2009-12-06 22:19:33 +00:00
|
|
|
|
2015-08-16 03:45:28 +00:00
|
|
|
QUnit.test( "jQuery.queue should return array while manipulating the queue", function( assert ) {
|
|
|
|
assert.expect( 1 );
|
2015-07-29 15:10:04 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
var div = document.createElement( "div" );
|
2013-04-08 19:36:24 +00:00
|
|
|
|
2016-08-14 10:54:16 +00:00
|
|
|
assert.ok( Array.isArray( jQuery.queue( div, "fx", jQuery.noop ) ), "jQuery.queue should return an array while manipulating the queue" );
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2013-04-08 19:36:24 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
QUnit.test( "delay()", function( assert ) {
|
2019-02-18 18:02:38 +00:00
|
|
|
var done = assert.async();
|
2015-08-16 06:59:58 +00:00
|
|
|
assert.expect( 2 );
|
2009-12-06 22:19:33 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
var foo = jQuery( {} ), run = 0;
|
2009-12-06 22:19:33 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
foo.delay( 100 ).queue( function() {
|
2009-12-06 22:19:33 +00:00
|
|
|
run = 1;
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.ok( true, "The function was dequeued." );
|
2019-02-18 18:02:38 +00:00
|
|
|
done();
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2009-12-06 22:19:33 +00:00
|
|
|
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.equal( run, 0, "The delay delayed the next function from running." );
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2009-12-06 22:19:33 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
QUnit.test( "clearQueue(name) clears the queue", function( assert ) {
|
2019-02-18 18:02:38 +00:00
|
|
|
var done = assert.async( 2 );
|
2015-08-16 06:59:58 +00:00
|
|
|
assert.expect( 2 );
|
2011-04-11 11:40:14 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
var div = jQuery( {} ),
|
2013-04-09 15:45:09 +00:00
|
|
|
counter = 0;
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
div.queue( "foo", function( next ) {
|
2009-12-06 22:19:33 +00:00
|
|
|
counter++;
|
2015-08-16 06:59:58 +00:00
|
|
|
jQuery( this ).clearQueue( "foo" );
|
2009-12-06 22:19:33 +00:00
|
|
|
next();
|
2015-08-16 06:59:58 +00:00
|
|
|
} ).queue( "foo", function() {
|
2009-12-06 22:19:33 +00:00
|
|
|
counter++;
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
div.promise( "foo" ).done( function() {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.ok( true, "dequeue resolves the deferred" );
|
2019-02-18 18:02:38 +00:00
|
|
|
done();
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2011-04-11 11:40:14 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
div.dequeue( "foo" );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
assert.equal( counter, 1, "the queue was cleared" );
|
2019-02-18 18:02:38 +00:00
|
|
|
done();
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2009-12-06 22:19:33 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
QUnit.test( "clearQueue() clears the fx queue", function( assert ) {
|
|
|
|
assert.expect( 1 );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
var div = jQuery( {} ),
|
2013-04-09 15:45:09 +00:00
|
|
|
counter = 0;
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
div.queue( function( next ) {
|
2009-12-06 22:19:33 +00:00
|
|
|
counter++;
|
|
|
|
var self = this;
|
2023-09-18 16:39:00 +00:00
|
|
|
setTimeout( function() {
|
|
|
|
jQuery( self ).clearQueue(); next();
|
|
|
|
}, 50 );
|
2015-08-16 06:59:58 +00:00
|
|
|
} ).queue( function() {
|
2009-12-06 22:19:33 +00:00
|
|
|
counter++;
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
assert.equal( counter, 1, "the queue was cleared" );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-06 22:19:33 +00:00
|
|
|
div.removeData();
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2011-04-11 11:40:14 +00:00
|
|
|
|
2019-02-18 18:02:38 +00:00
|
|
|
QUnit.test( "fn.promise() - called when fx queue is empty", function( assert ) {
|
|
|
|
assert.expect( 3 );
|
2013-02-27 03:55:36 +00:00
|
|
|
var foo = jQuery( "#foo" ).clone().addBack(),
|
2019-02-18 18:02:38 +00:00
|
|
|
promised = false,
|
|
|
|
done = assert.async();
|
2011-04-11 11:40:14 +00:00
|
|
|
|
2012-05-23 03:04:45 +00:00
|
|
|
foo.queue( function( next ) {
|
2015-08-16 06:59:58 +00:00
|
|
|
|
2012-05-23 03:04:45 +00:00
|
|
|
// called twice!
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.ok( !promised, "Promised hasn't been called" );
|
2012-05-23 03:04:45 +00:00
|
|
|
setTimeout( next, 10 );
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2012-05-23 03:04:45 +00:00
|
|
|
foo.promise().done( function() {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.ok( promised = true, "Promised" );
|
2019-02-18 18:02:38 +00:00
|
|
|
done();
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
|
|
|
} );
|
2011-04-11 11:40:14 +00:00
|
|
|
|
2019-02-18 18:02:38 +00:00
|
|
|
QUnit.test( "fn.promise( \"queue\" ) - called whenever last queue function is dequeued", function( assert ) {
|
|
|
|
assert.expect( 5 );
|
|
|
|
var done = assert.async();
|
2012-05-23 03:04:45 +00:00
|
|
|
var foo = jQuery( "#foo" ),
|
|
|
|
test;
|
|
|
|
foo.promise( "queue" ).done( function() {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.strictEqual( test, undefined, "called immediately when queue was already empty" );
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2012-05-23 03:04:45 +00:00
|
|
|
test = 1;
|
|
|
|
foo.queue( "queue", function( next ) {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.strictEqual( test++, 1, "step one" );
|
2012-05-23 03:04:45 +00:00
|
|
|
setTimeout( next, 0 );
|
2015-08-16 06:59:58 +00:00
|
|
|
} ).queue( "queue", function( next ) {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.strictEqual( test++, 2, "step two" );
|
2012-05-23 03:04:45 +00:00
|
|
|
setTimeout( function() {
|
|
|
|
next();
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.strictEqual( test++, 4, "step four" );
|
2019-02-18 18:02:38 +00:00
|
|
|
done();
|
2012-05-23 03:04:45 +00:00
|
|
|
}, 10 );
|
2015-08-16 06:59:58 +00:00
|
|
|
} ).promise( "queue" ).done( function() {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.strictEqual( test++, 3, "step three" );
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2011-04-11 11:40:14 +00:00
|
|
|
|
2012-05-23 03:04:45 +00:00
|
|
|
foo.dequeue( "queue" );
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2011-12-09 17:41:35 +00:00
|
|
|
|
2022-06-28 10:39:01 +00:00
|
|
|
if ( includesModule( "effects" ) ) {
|
2016-05-10 09:12:28 +00:00
|
|
|
|
2019-02-18 18:02:38 +00:00
|
|
|
QUnit.test( "fn.promise( \"queue\" ) - waits for animation to complete before resolving", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
|
|
|
var done = assert.async();
|
2012-08-13 17:43:49 +00:00
|
|
|
var foo = jQuery( "#foo" ),
|
|
|
|
test = 1;
|
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
foo.animate( {
|
2012-08-13 17:43:49 +00:00
|
|
|
top: 100
|
|
|
|
}, {
|
|
|
|
duration: 1,
|
|
|
|
queue: "queue",
|
|
|
|
complete: function() {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.strictEqual( test++, 1, "step one" );
|
2012-08-13 17:43:49 +00:00
|
|
|
}
|
2015-08-16 06:59:58 +00:00
|
|
|
} ).dequeue( "queue" );
|
2012-08-13 17:43:49 +00:00
|
|
|
|
|
|
|
foo.promise( "queue" ).done( function() {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.strictEqual( test++, 2, "step two" );
|
2019-02-18 18:02:38 +00:00
|
|
|
done();
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2012-08-13 17:43:49 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2015-10-09 19:52:29 +00:00
|
|
|
}
|
2012-08-13 17:43:49 +00:00
|
|
|
|
2015-08-16 03:45:28 +00:00
|
|
|
QUnit.test( ".promise(obj)", function( assert ) {
|
2015-08-16 06:59:58 +00:00
|
|
|
assert.expect( 2 );
|
2011-12-09 17:41:35 +00:00
|
|
|
|
2013-04-09 15:45:09 +00:00
|
|
|
var obj = {},
|
|
|
|
promise = jQuery( "#foo" ).promise( "promise", obj );
|
2011-12-09 17:41:35 +00:00
|
|
|
|
2017-12-13 06:43:30 +00:00
|
|
|
assert.ok( typeof promise.promise === "function", ".promise(type, obj) returns a promise" );
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.strictEqual( promise, obj, ".promise(type, obj) returns obj" );
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2012-05-23 03:04:45 +00:00
|
|
|
|
2022-06-28 10:39:01 +00:00
|
|
|
QUnit[ includesModule( "effects" ) ? "test" : "skip" ]( "delay() can be stopped", function( assert ) {
|
2019-05-13 19:39:56 +00:00
|
|
|
var done = assert.async();
|
|
|
|
assert.expect( 3 );
|
|
|
|
var storage = {};
|
|
|
|
jQuery( {} )
|
|
|
|
.queue( "alternate", function( next ) {
|
|
|
|
storage.alt1 = true;
|
|
|
|
assert.ok( true, "This first function was dequeued" );
|
|
|
|
next();
|
|
|
|
} )
|
|
|
|
.delay( 1000, "alternate" )
|
|
|
|
.queue( "alternate", function() {
|
|
|
|
storage.alt2 = true;
|
|
|
|
assert.ok( true, "The function was dequeued immediately, the delay was stopped" );
|
|
|
|
} )
|
|
|
|
.dequeue( "alternate" )
|
2012-05-29 02:25:04 +00:00
|
|
|
|
2019-05-13 19:39:56 +00:00
|
|
|
// stop( "alternate", false ) will NOT clear the queue, so it should automatically dequeue the next
|
|
|
|
.stop( "alternate", false, false )
|
2012-05-23 03:04:45 +00:00
|
|
|
|
2019-05-13 19:39:56 +00:00
|
|
|
// this test
|
|
|
|
.delay( 1 )
|
|
|
|
.queue( function() {
|
|
|
|
storage.default1 = true;
|
|
|
|
assert.ok( false, "This queue should never run" );
|
|
|
|
} )
|
2012-05-29 02:25:04 +00:00
|
|
|
|
2019-05-13 19:39:56 +00:00
|
|
|
// stop( clearQueue ) should clear the queue
|
|
|
|
.stop( true, false );
|
2012-05-29 02:25:04 +00:00
|
|
|
|
2019-05-13 19:39:56 +00:00
|
|
|
assert.deepEqual( storage, { alt1: true, alt2: true }, "Queue ran the proper functions" );
|
2012-05-29 02:25:04 +00:00
|
|
|
|
2019-05-13 19:39:56 +00:00
|
|
|
setTimeout( function() {
|
|
|
|
done();
|
|
|
|
}, 1500 );
|
|
|
|
} );
|
|
|
|
|
2022-06-28 10:39:01 +00:00
|
|
|
QUnit[ includesModule( "effects" ) ? "test" : "skip" ]( "queue stop hooks", function( assert ) {
|
2019-05-13 19:39:56 +00:00
|
|
|
assert.expect( 2 );
|
|
|
|
var done = assert.async();
|
|
|
|
var foo = jQuery( "#foo" );
|
|
|
|
|
|
|
|
foo.queue( function( next, hooks ) {
|
|
|
|
hooks.stop = function( gotoEnd ) {
|
|
|
|
assert.equal( !!gotoEnd, false, "Stopped without gotoEnd" );
|
|
|
|
};
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2019-05-13 19:39:56 +00:00
|
|
|
foo.stop();
|
2012-05-23 03:04:45 +00:00
|
|
|
|
2019-05-13 19:39:56 +00:00
|
|
|
foo.queue( function( next, hooks ) {
|
|
|
|
hooks.stop = function( gotoEnd ) {
|
|
|
|
assert.equal( gotoEnd, true, "Stopped with gotoEnd" );
|
|
|
|
done();
|
|
|
|
};
|
|
|
|
} );
|
|
|
|
|
|
|
|
foo.stop( false, true );
|
|
|
|
} );
|
2020-01-07 22:59:08 +00:00
|
|
|
|
|
|
|
} )();
|