rsxjs
Version:
Resilience Extensions for JS.
22 lines (18 loc) • 492 B
JavaScript
/**
* @file tests/coroutine/test-co.js
* @copyright 2018-present Karim Alibhai. All rights reserved.
*/
import { test } from "../../helpers";
import { co } from "../../../";
test("co: regular routine", async (t) => {
let state = 0;
const e = await t.throwsAsync(
co(function* () {
state += yield Promise.resolve(1);
state += yield Promise.resolve(2);
yield Promise.reject(new Error("blah"));
})
);
t.is(state, 3);
t.is(String(e), "Error: blah");
});