rsxjs
Version:
Resilience Extensions for JS.
24 lines (18 loc) • 487 B
JavaScript
/**
* @file tests/coroutine/test-cancel-defer.js
* @copyright 2018-present Karim Alibhai. All rights reserved.
*/
import { test } from "../../helpers";
import { spy } from "sinon";
import { co } from "../../../";
test("co: cancel + defer", async (t) => {
const fn = spy(() => {});
const e = co(function* (d) {
d(fn);
yield 1;
yield Promise.reject(new Error("blah"));
});
t.is(await e.cancel(), false);
t.is(await e, undefined);
t.true(fn.calledOnce);
});