Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Add a failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed May 18, 2016
1 parent 7abc63c commit 19b48e2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,29 @@ describe("Task cancelation upward propagation (non-branching chains)", () => {
assertCanceledWith(descendantResults, reason);
});
});

it("should cancel upward until it reaches a resolved promise", () => {
const reason = { some: "reason" };

const root = Task.resolve(5);
const generation1 = root.then(() => delay(100));
const generation2 = generation1.then();

const rootResults = getHandlerResultsStore(root, "root");
const generation1Results = getHandlerResultsStore(generation1, "generation1");
const generation2Results = getHandlerResultsStore(generation2, "generation2");

generation2.cancel(reason);

// This fails because generation1 isn't resolved by the time generation2.cancel() is called, since
// `() => delay(100)` only happens after a microtask. That seems bad and error-prone. Is there anything we can do?

return delay(150).then(() => {
assertFulfilledWith(rootResults, 5);
assertFulfilledWith(generation1Results, undefined);
assertCanceledWith(generation2Results, reason);
})
});
});

function getHandlerResultsStore(promise, label) {
Expand Down

0 comments on commit 19b48e2

Please sign in to comment.