Commit 926895ac authored by Romain Courteaud's avatar Romain Courteaud 🐙

more queue tests

parent 77df9da7
......@@ -2416,6 +2416,8 @@ describe("`RSVP.Queue`", function () {
it('should `cancel` pending success `thenable`', function (done) {
var thenable_cancel_called = false,
thenable_ongoing = false,
later_success_thenable_called = false,
later_error_thenable_called = false,
queue = new RSVP.Queue()
.push(function () {
return new Promise(
......@@ -2425,7 +2427,63 @@ describe("`RSVP.Queue`", function () {
function () {
thenable_cancel_called = true;
});
}),
})
.push(
// Should be skipped
function () {later_success_thenable_called = true;},
function () {later_error_thenable_called = true;}
),
result = 'MARKER1',
error = 'MARKER2';
queue.then(function(e) {
result = e;
});
queue.fail(function(e) {
error = e;
});
setTimeout(function() {
assert.equal(queue.isRejected, undefined);
assert.equal(queue.isFulfilled, undefined);
assert.equal(thenable_ongoing, true);
queue.cancel();
assert.equal(thenable_cancel_called, true);
setTimeout(function() {
assert.equal(queue.isRejected, true);
assert.equal(queue.isFulfilled, undefined);
assert(queue.rejectedReason instanceof RSVP.CancellationError);
assert.equal(result, 'MARKER1');
assert(error instanceof RSVP.CancellationError);
assert.equal(later_success_thenable_called, false);
assert.equal(later_error_thenable_called, false);
done();
}, 20);
}, 20);
});
it('should `cancel` pending error `thenable`', function (done) {
var thenable_cancel_called = false,
thenable_ongoing = false,
later_success_thenable_called = false,
later_error_thenable_called = false,
queue = new RSVP.Queue()
.push(function () {
return RSVP.reject(1);
})
.push(undefined, function () {
return new Promise(
function () {
thenable_ongoing = true;
},
function () {
thenable_cancel_called = true;
});
})
.push(
// Should be skipped
function () {later_success_thenable_called = true;},
function () {later_error_thenable_called = true;}
),
result = 'MARKER1',
error = 'MARKER2';
queue.then(function(e) {
......@@ -2447,6 +2505,8 @@ describe("`RSVP.Queue`", function () {
assert(queue.rejectedReason instanceof RSVP.CancellationError);
assert.equal(result, 'MARKER1');
assert(error instanceof RSVP.CancellationError);
assert.equal(later_success_thenable_called, false);
assert.equal(later_error_thenable_called, false);
done();
}, 20);
}, 20);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment