Permalink
Browse files

add isCancelled() regression tests (#1239)

* add isCancelled() regression tests

* PR feedback
1 parent d020e49 commit d9a3a626de8af6bc6f8e20f24bca04a3b82fb1b4 @finnigantime finnigantime committed with Jan 2, 2017
Showing with 16 additions and 2 deletions.
  1. +16 −2 test/mocha/cancel.js
View
@@ -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) {
@@ -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();

0 comments on commit d9a3a62

Please sign in to comment.