From d9a3a626de8af6bc6f8e20f24bca04a3b82fb1b4 Mon Sep 17 00:00:00 2001 From: Pat Finnigan Date: Mon, 2 Jan 2017 03:17:03 -0800 Subject: [PATCH] add isCancelled() regression tests (#1239) * add isCancelled() regression tests * PR feedback --- test/mocha/cancel.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/mocha/cancel.js b/test/mocha/cancel.js index b00352a3f..54448868d 100644 --- a/test/mocha/cancel.js +++ b/test/mocha/cancel.js @@ -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();