diff options
author | louisremi <louisremi@louisremi-laptop.(none)> | 2011-04-12 11:29:25 +0200 |
---|---|---|
committer | louisremi <louisremi@louisremi-laptop.(none)> | 2011-04-12 11:29:25 +0200 |
commit | a5604aedb74ec39624b21229a5c8542c793b0382 (patch) | |
tree | 9fa541ff92d96a8979af260a31f2d75492e696fd /test/unit/queue.js | |
parent | 8547b34f9265ed2d2b5380b1db5dfcaf97d96d5a (diff) | |
parent | 312df0441b16981dd697d74fcbc1e1f212b47b7e (diff) | |
download | jquery-a5604aedb74ec39624b21229a5c8542c793b0382.tar.gz jquery-a5604aedb74ec39624b21229a5c8542c793b0382.zip |
merge with master and resolve more conflicts
Diffstat (limited to 'test/unit/queue.js')
-rw-r--r-- | test/unit/queue.js | 111 |
1 files changed, 106 insertions, 5 deletions
diff --git a/test/unit/queue.js b/test/unit/queue.js index 34f61f826..9b612ce37 100644 --- a/test/unit/queue.js +++ b/test/unit/queue.js @@ -1,10 +1,17 @@ module("queue", { teardown: moduleTeardown }); test("queue() with other types",function() { - expect(9); + expect(11); var counter = 0; - var $div = jQuery({}); + stop(); + + var $div = jQuery({}), + defer; + + $div.promise("foo").done(function() { + equals( counter, 0, "Deferred for collection with no queue is automatically resolved" ); + }); $div .queue("foo",function(){ @@ -22,6 +29,11 @@ test("queue() with other types",function() { equals( ++counter, 4, "Dequeuing" ); }); + defer = $div.promise("foo").done(function() { + equals( counter, 4, "Testing previous call to dequeue in deferred" ); + start(); + }); + equals( $div.queue("foo").length, 4, "Testing queue length" ); $div.dequeue("foo"); @@ -74,7 +86,7 @@ test("queue(name) passes in the next item in the queue as a parameter", function }); test("queue() passes in the next item in the queue as a parameter to fx queues", function() { - expect(2); + expect(3); stop(); var div = jQuery({}); @@ -87,11 +99,15 @@ test("queue() passes in the next item in the queue as a parameter to fx queues", }).queue(function(next) { equals(++counter, 2, "Next was called"); next(); - start(); }).queue("bar", function() { equals(++counter, 3, "Other queues are not triggered by next()") }); + jQuery.when( div.promise("fx"), div ).done(function() { + equals(counter, 2, "Deferreds resolved"); + start(); + }); + }); test("delay()", function() { @@ -110,7 +126,9 @@ test("delay()", function() { }); test("clearQueue(name) clears the queue", function() { - expect(1); + expect(2); + + stop() var div = jQuery({}); var counter = 0; @@ -123,6 +141,11 @@ test("clearQueue(name) clears the queue", function() { counter++; }); + div.promise("foo").done(function() { + ok( true, "dequeue resolves the deferred" ); + start(); + }); + div.dequeue("foo"); equals(counter, 1, "the queue was cleared"); @@ -146,3 +169,81 @@ test("clearQueue() clears the fx queue", function() { div.removeData(); }); + +test("_mark() and _unmark()", function() { + expect(1); + + var div = {}, + $div = jQuery( div ); + + stop(); + + jQuery._mark( div, "foo" ); + jQuery._mark( div, "foo" ); + jQuery._unmark( div, "foo" ); + jQuery._unmark( div, "foo" ); + + $div.promise( "foo" ).done(function() { + ok( true, "No more marks" ); + start(); + }); +}); + +test("_mark() and _unmark() default to 'fx'", function() { + expect(1); + + var div = {}, + $div = jQuery( div ); + + stop(); + + jQuery._mark( div ); + jQuery._mark( div ); + jQuery._unmark( div, "fx" ); + jQuery._unmark( div ); + + $div.promise().done(function() { + ok( true, "No more marks" ); + start(); + }); +}); + +test("promise()", function() { + expect(1); + + stop(); + + var objects = []; + + jQuery.each( [{}, {}], function( i, div ) { + var $div = jQuery( div ); + $div.queue(function( next ) { + setTimeout( function() { + if ( i ) { + next(); + setTimeout( function() { + jQuery._unmark( div ); + }, 20 ); + } else { + jQuery._unmark( div ); + setTimeout( function() { + next(); + }, 20 ); + } + }, 50 ); + }).queue(function( next ) { + next(); + }); + jQuery._mark( div ); + objects.push( $div ); + }); + + jQuery.when.apply( jQuery, objects ).done(function() { + ok( true, "Deferred resolved" ); + start(); + }); + + jQuery.each( objects, function() { + this.dequeue(); + }); +});
\ No newline at end of file |