aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/queue.js
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2012-05-28 22:25:04 -0400
committerDave Methvin <dave.methvin@gmail.com>2012-05-28 22:36:23 -0400
commit7f2cc46955b35dc3d5a0526d0cb038d4a50b936b (patch)
treee2a4e841e16f90c93118130ec93319013eb3f08f /test/unit/queue.js
parent82d4c72fb15edd91869afa01a5bca3af678852fb (diff)
downloadjquery-7f2cc46955b35dc3d5a0526d0cb038d4a50b936b.tar.gz
jquery-7f2cc46955b35dc3d5a0526d0cb038d4a50b936b.zip
Fix #11767. Modularize build and unit tests for exluding effects.
Closes gh-785. To build a version of jQuery without effects, use `grunt build:*:*:-effects`. The unit tests feature-check for the interfaces and skip the unit tests for effects if they don't detect it.
Diffstat (limited to 'test/unit/queue.js')
-rw-r--r--test/unit/queue.js113
1 files changed, 59 insertions, 54 deletions
diff --git a/test/unit/queue.js b/test/unit/queue.js
index 6a614edb6..fac74f906 100644
--- a/test/unit/queue.js
+++ b/test/unit/queue.js
@@ -101,11 +101,13 @@ test("callbacks keep their place in the queue", function() {
div.queue(function( next ) {
equal( ++counter, 1, "Queue/callback order: first called" );
setTimeout( next, 200 );
- }).show(100, function() {
+ }).delay( 100 ).queue(function( next ) {
equal( ++counter, 2, "Queue/callback order: second called" );
- jQuery(this).hide(100, function() {
+ jQuery( this ).delay( 100 ).queue(function( next ) {
equal( ++counter, 4, "Queue/callback order: fourth called" );
+ next();
});
+ next();
}).queue(function( next ) {
equal( ++counter, 3, "Queue/callback order: third called" );
next();
@@ -133,44 +135,6 @@ test("delay()", function() {
equal( 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( 1000, "alternate" )
- .queue( "alternate", function() {
- run++;
- ok( true, "The function was dequeued immediately, the delay was stopped" );
- })
- .dequeue( "alternate" )
-
- // stop( "alternate", false ) will NOT clear the queue, so it should automatically dequeue the next
- .stop( "alternate", false, false )
-
- // this test
- .delay( 1000 )
- .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, 2000 );
-});
-
-
test("clearQueue(name) clears the queue", function() {
expect(2);
@@ -265,22 +229,63 @@ test( ".promise(obj)", function() {
strictEqual( promise, obj, ".promise(type, obj) returns obj" );
});
-asyncTest( "queue stop hooks", 2, function() {
- var foo = jQuery( "#foo" );
- foo.queue( function( next, hooks ) {
- hooks.stop = function( gotoEnd ) {
- equal( !!gotoEnd, false, "Stopped without gotoEnd" );
- };
+if ( jQuery.fn.stop ) {
+ 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( 1000, "alternate" )
+ .queue( "alternate", function() {
+ run++;
+ ok( true, "The function was dequeued immediately, the delay was stopped" );
+ })
+ .dequeue( "alternate" )
+
+ // stop( "alternate", false ) will NOT clear the queue, so it should automatically dequeue the next
+ .stop( "alternate", false, false )
+
+ // this test
+ .delay( 1000 )
+ .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, 2000 );
});
- foo.stop();
- foo.queue( function( next, hooks ) {
- hooks.stop = function( gotoEnd ) {
- equal( gotoEnd, true, "Stopped with gotoEnd" );
- start();
- };
+ asyncTest( "queue stop hooks", 2, function() {
+ var foo = jQuery( "#foo" );
+
+ foo.queue( function( next, hooks ) {
+ hooks.stop = function( gotoEnd ) {
+ equal( !!gotoEnd, false, "Stopped without gotoEnd" );
+ };
+ });
+ foo.stop();
+
+ foo.queue( function( next, hooks ) {
+ hooks.stop = function( gotoEnd ) {
+ equal( gotoEnd, true, "Stopped with gotoEnd" );
+ start();
+ };
+ });
+
+ foo.stop( false, true );
});
- foo.stop( false, true );
-});
+} // if ( jQuery.fn.stop ) \ No newline at end of file