diff options
author | Oleg Gaidarenko <markelog@gmail.com> | 2015-08-16 06:45:28 +0300 |
---|---|---|
committer | Oleg Gaidarenko <markelog@gmail.com> | 2015-08-16 09:02:01 +0300 |
commit | b930d14ce64937e9478405eee2828d4da091d2cb (patch) | |
tree | 7966c17b5b66e02af5cfa485d3e6a565ef077645 /test/unit/queue.js | |
parent | 9d820fbde6d89bc7a06e2704be61cf6c0b4d6e3c (diff) | |
download | jquery-b930d14ce64937e9478405eee2828d4da091d2cb.tar.gz jquery-b930d14ce64937e9478405eee2828d4da091d2cb.zip |
Tests: partially use new qunit interface
http://qunitjs.com/upgrade-guide-2.x/
For most of the boring work was used
https://github.com/apsdehal/qunit-migrate package
However, it can't update local qunit helpers, plus in some places
old QUnit.asyncTest signature is still used
Fixes gh-2540
Diffstat (limited to 'test/unit/queue.js')
-rw-r--r-- | test/unit/queue.js | 180 |
1 files changed, 90 insertions, 90 deletions
diff --git a/test/unit/queue.js b/test/unit/queue.js index 761f17b17..42192f3d3 100644 --- a/test/unit/queue.js +++ b/test/unit/queue.js @@ -1,155 +1,155 @@ -module( "queue", { teardown: moduleTeardown }); +QUnit.module( "queue", { teardown: moduleTeardown }); -test( "queue() with other types", function() { - expect( 14 ); +QUnit.test( "queue() with other types", function( assert ) { + assert.expect( 14 ); - stop(); + QUnit.stop(); var $div = jQuery({}), counter = 0; $div.promise( "foo" ).done(function() { - equal( counter, 0, "Deferred for collection with no queue is automatically resolved" ); + assert.equal( counter, 0, "Deferred for collection with no queue is automatically resolved" ); }); $div .queue("foo",function(){ - equal( ++counter, 1, "Dequeuing" ); + assert.equal( ++counter, 1, "Dequeuing" ); jQuery.dequeue(this,"foo"); }) .queue("foo",function(){ - equal( ++counter, 2, "Dequeuing" ); + assert.equal( ++counter, 2, "Dequeuing" ); jQuery(this).dequeue("foo"); }) .queue("foo",function(){ - equal( ++counter, 3, "Dequeuing" ); + assert.equal( ++counter, 3, "Dequeuing" ); }) .queue("foo",function(){ - equal( ++counter, 4, "Dequeuing" ); + assert.equal( ++counter, 4, "Dequeuing" ); }); $div.promise("foo").done(function() { - equal( counter, 4, "Testing previous call to dequeue in deferred" ); - start(); + assert.equal( counter, 4, "Testing previous call to dequeue in deferred" ); + QUnit.start(); }); - equal( $div.queue("foo").length, 4, "Testing queue length" ); + assert.equal( $div.queue("foo").length, 4, "Testing queue length" ); - equal( $div.queue("foo", undefined).queue("foo").length, 4, ".queue('name',undefined) does nothing but is chainable (#5571)"); + assert.equal( $div.queue("foo", undefined).queue("foo").length, 4, ".queue('name',undefined) does nothing but is chainable (#5571)"); $div.dequeue("foo"); - equal( counter, 3, "Testing previous call to dequeue" ); - equal( $div.queue("foo").length, 1, "Testing queue length" ); + assert.equal( counter, 3, "Testing previous call to dequeue" ); + assert.equal( $div.queue("foo").length, 1, "Testing queue length" ); $div.dequeue("foo"); - equal( counter, 4, "Testing previous call to dequeue" ); - equal( $div.queue("foo").length, 0, "Testing queue length" ); + assert.equal( counter, 4, "Testing previous call to dequeue" ); + assert.equal( $div.queue("foo").length, 0, "Testing queue length" ); $div.dequeue("foo"); - equal( counter, 4, "Testing previous call to dequeue" ); - equal( $div.queue("foo").length, 0, "Testing queue length" ); + assert.equal( counter, 4, "Testing previous call to dequeue" ); + assert.equal( $div.queue("foo").length, 0, "Testing queue length" ); }); -test("queue(name) passes in the next item in the queue as a parameter", function() { - expect(2); +QUnit.test("queue(name) passes in the next item in the queue as a parameter", function( assert ) { + assert.expect(2); var div = jQuery({}), counter = 0; div.queue("foo", function(next) { - equal(++counter, 1, "Dequeueing"); + assert.equal(++counter, 1, "Dequeueing"); next(); }).queue("foo", function(next) { - equal(++counter, 2, "Next was called"); + assert.equal(++counter, 2, "Next was called"); next(); }).queue("bar", function() { - equal(++counter, 3, "Other queues are not triggered by next()"); + assert.equal(++counter, 3, "Other queues are not triggered by next()"); }); div.dequeue("foo"); }); -test("queue() passes in the next item in the queue as a parameter to fx queues", function() { - expect(3); - stop(); +QUnit.test("queue() passes in the next item in the queue as a parameter to fx queues", function( assert ) { + assert.expect(3); + QUnit.stop(); var div = jQuery({}), counter = 0; div.queue(function(next) { - equal(++counter, 1, "Dequeueing"); + assert.equal(++counter, 1, "Dequeueing"); setTimeout(function() { next(); }, 500); }).queue(function(next) { - equal(++counter, 2, "Next was called"); + assert.equal(++counter, 2, "Next was called"); next(); }).queue("bar", function() { - equal(++counter, 3, "Other queues are not triggered by next()"); + assert.equal(++counter, 3, "Other queues are not triggered by next()"); }); jQuery.when( div.promise("fx"), div ).done(function() { - equal(counter, 2, "Deferreds resolved"); - start(); + assert.equal(counter, 2, "Deferreds resolved"); + QUnit.start(); }); }); -test("callbacks keep their place in the queue", function() { - expect(5); - stop(); +QUnit.test("callbacks keep their place in the queue", function( assert ) { + assert.expect(5); + QUnit.stop(); var div = jQuery("<div>"), counter = 0; div.queue(function( next ) { - equal( ++counter, 1, "Queue/callback order: first called" ); + assert.equal( ++counter, 1, "Queue/callback order: first called" ); setTimeout( next, 200 ); }).delay( 100 ).queue(function( next ) { - equal( ++counter, 2, "Queue/callback order: second called" ); + assert.equal( ++counter, 2, "Queue/callback order: second called" ); jQuery( this ).delay( 100 ).queue(function( next ) { - equal( ++counter, 4, "Queue/callback order: fourth called" ); + assert.equal( ++counter, 4, "Queue/callback order: fourth called" ); next(); }); next(); }).queue(function( next ) { - equal( ++counter, 3, "Queue/callback order: third called" ); + assert.equal( ++counter, 3, "Queue/callback order: third called" ); next(); }); div.promise("fx").done(function() { - equal(counter, 4, "Deferreds resolved"); - start(); + assert.equal(counter, 4, "Deferreds resolved"); + QUnit.start(); }); }); -test( "jQuery.queue should return array while manipulating the queue", function() { - expect( 1 ); +QUnit.test( "jQuery.queue should return array while manipulating the queue", function( assert ) { + assert.expect( 1 ); var div = document.createElement("div"); - ok( jQuery.isArray( jQuery.queue( div, "fx", jQuery.noop ) ), "jQuery.queue should return an array while manipulating the queue" ); + assert.ok( jQuery.isArray( jQuery.queue( div, "fx", jQuery.noop ) ), "jQuery.queue should return an array while manipulating the queue" ); }); -test("delay()", function() { - expect(2); - stop(); +QUnit.test("delay()", function( assert ) { + assert.expect(2); + QUnit.stop(); var foo = jQuery({}), run = 0; foo.delay(100).queue(function(){ run = 1; - ok( true, "The function was dequeued." ); - start(); + assert.ok( true, "The function was dequeued." ); + QUnit.start(); }); - equal( run, 0, "The delay delayed the next function from running." ); + assert.equal( run, 0, "The delay delayed the next function from running." ); }); -test("clearQueue(name) clears the queue", function() { - expect(2); +QUnit.test("clearQueue(name) clears the queue", function( assert ) { + assert.expect(2); - stop(); + QUnit.stop(); var div = jQuery({}), counter = 0; @@ -163,17 +163,17 @@ test("clearQueue(name) clears the queue", function() { }); div.promise("foo").done(function() { - ok( true, "dequeue resolves the deferred" ); - start(); + assert.ok( true, "dequeue resolves the deferred" ); + QUnit.start(); }); div.dequeue("foo"); - equal(counter, 1, "the queue was cleared"); + assert.equal(counter, 1, "the queue was cleared"); }); -test("clearQueue() clears the fx queue", function() { - expect(1); +QUnit.test("clearQueue() clears the fx queue", function( assert ) { + assert.expect(1); var div = jQuery({}), counter = 0; @@ -186,51 +186,51 @@ test("clearQueue() clears the fx queue", function() { counter++; }); - equal(counter, 1, "the queue was cleared"); + assert.equal(counter, 1, "the queue was cleared"); div.removeData(); }); -asyncTest( "fn.promise() - called when fx queue is empty", 3, function() { +QUnit.asyncTest( "fn.promise() - called when fx queue is empty", 3, function( assert ) { var foo = jQuery( "#foo" ).clone().addBack(), promised = false; foo.queue( function( next ) { // called twice! - ok( !promised, "Promised hasn't been called" ); + assert.ok( !promised, "Promised hasn't been called" ); setTimeout( next, 10 ); }); foo.promise().done( function() { - ok( promised = true, "Promised" ); - start(); + assert.ok( promised = true, "Promised" ); + QUnit.start(); }); }); -asyncTest( "fn.promise( \"queue\" ) - called whenever last queue function is dequeued", 5, function() { +QUnit.asyncTest( "fn.promise( \"queue\" ) - called whenever last queue function is dequeued", 5, function( assert ) { var foo = jQuery( "#foo" ), test; foo.promise( "queue" ).done( function() { - strictEqual( test, undefined, "called immediately when queue was already empty" ); + assert.strictEqual( test, undefined, "called immediately when queue was already empty" ); }); test = 1; foo.queue( "queue", function( next ) { - strictEqual( test++, 1, "step one" ); + assert.strictEqual( test++, 1, "step one" ); setTimeout( next, 0 ); }).queue( "queue", function( next ) { - strictEqual( test++, 2, "step two" ); + assert.strictEqual( test++, 2, "step two" ); setTimeout( function() { next(); - strictEqual( test++, 4, "step four" ); - start(); + assert.strictEqual( test++, 4, "step four" ); + QUnit.start(); }, 10 ); }).promise( "queue" ).done( function() { - strictEqual( test++, 3, "step three" ); + assert.strictEqual( test++, 3, "step three" ); }); foo.dequeue( "queue" ); }); -asyncTest( "fn.promise( \"queue\" ) - waits for animation to complete before resolving", 2, function() { +QUnit.asyncTest( "fn.promise( \"queue\" ) - waits for animation to complete before resolving", 2, function( assert ) { var foo = jQuery( "#foo" ), test = 1; @@ -240,44 +240,44 @@ asyncTest( "fn.promise( \"queue\" ) - waits for animation to complete before res duration: 1, queue: "queue", complete: function() { - strictEqual( test++, 1, "step one" ); + assert.strictEqual( test++, 1, "step one" ); } }).dequeue( "queue" ); foo.promise( "queue" ).done( function() { - strictEqual( test++, 2, "step two" ); - start(); + assert.strictEqual( test++, 2, "step two" ); + QUnit.start(); }); }); -test( ".promise(obj)", function() { - expect(2); +QUnit.test( ".promise(obj)", function( assert ) { + assert.expect(2); var obj = {}, promise = jQuery( "#foo" ).promise( "promise", obj ); - ok( jQuery.isFunction( promise.promise ), ".promise(type, obj) returns a promise" ); - strictEqual( promise, obj, ".promise(type, obj) returns obj" ); + assert.ok( jQuery.isFunction( promise.promise ), ".promise(type, obj) returns a promise" ); + assert.strictEqual( promise, obj, ".promise(type, obj) returns obj" ); }); if ( jQuery.fn.stop ) { - test("delay() can be stopped", function() { - expect( 3 ); - stop(); + QUnit.test("delay() can be stopped", function( assert ) { + assert.expect( 3 ); + QUnit.stop(); var done = {}; jQuery({}) .queue( "alternate", function( next ) { done.alt1 = true; - ok( true, "This first function was dequeued" ); + assert.ok( true, "This first function was dequeued" ); next(); }) .delay( 1000, "alternate" ) .queue( "alternate", function() { done.alt2 = true; - ok( true, "The function was dequeued immediately, the delay was stopped" ); + assert.ok( true, "The function was dequeued immediately, the delay was stopped" ); }) .dequeue( "alternate" ) @@ -288,33 +288,33 @@ if ( jQuery.fn.stop ) { .delay( 1 ) .queue(function() { done.default1 = true; - ok( false, "This queue should never run" ); + assert.ok( false, "This queue should never run" ); }) // stop( clearQueue ) should clear the queue .stop( true, false ); - deepEqual( done, { alt1: true, alt2: true }, "Queue ran the proper functions" ); + assert.deepEqual( done, { alt1: true, alt2: true }, "Queue ran the proper functions" ); setTimeout(function() { - start(); + QUnit.start(); }, 1500 ); }); - asyncTest( "queue stop hooks", 2, function() { + QUnit.asyncTest( "queue stop hooks", 2, function( assert ) { var foo = jQuery( "#foo" ); foo.queue( function( next, hooks ) { hooks.stop = function( gotoEnd ) { - equal( !!gotoEnd, false, "Stopped without gotoEnd" ); + assert.equal( !!gotoEnd, false, "Stopped without gotoEnd" ); }; }); foo.stop(); foo.queue( function( next, hooks ) { hooks.stop = function( gotoEnd ) { - equal( gotoEnd, true, "Stopped with gotoEnd" ); - start(); + assert.equal( gotoEnd, true, "Stopped with gotoEnd" ); + QUnit.start(); }; }); |