Skip to content

Commit

Permalink
add isCancelled() regression tests (petkaantonov#1239)
Browse files Browse the repository at this point in the history
* add isCancelled() regression tests

* PR feedback
  • Loading branch information
finnigantime authored and petkaantonov committed Jan 2, 2017
1 parent d020e49 commit d9a3a62
Showing 1 changed file with 16 additions and 2 deletions.
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

0 comments on commit d9a3a62

Please sign in to comment.