Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add isCancelled() regression tests #1239

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions test/mocha/cancel.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ describe("Cancellation", function() {
});
});

specify("Can be used for breaking chains early", function() {
specify("can be used for breaking chains early", function() {
var called = false;
var p = Promise.resolve(1)
.then(function(data) {
Expand Down Expand Up @@ -709,7 +709,21 @@ describe("Cancellation", function() {
req.cancel();
var resolve;
return new Promise(function(_, __, onCancel) {resolve = arguments[0]});
})
});

specify("isCancelled() synchronously returns true after calling cancel() on pending promise", function() {
var promise = new Promise(function () {});
promise.cancel();
assert(promise.isCancelled());
});

specify("isCancelled() synchronously returns true after calling cancel() on promise created from .then()", function() {
var promise = new Promise(function () {});
var thenPromise = promise.then();
thenPromise.cancel();
assert(thenPromise.isCancelled());
});

specify("gh-166", function() {
var f1 = false, f2 = false, f3 = false, f4 = false;
var a = Promise.resolve();
Expand Down