Skip to content

Instantly share code, notes, and snippets.

@dpchamps
Created April 12, 2020 21:41
Show Gist options
  • Save dpchamps/7ef4739b5674e6713c51f9d1f22a95e3 to your computer and use it in GitHub Desktop.
Save dpchamps/7ef4739b5674e6713c51f9d1f22a95e3 to your computer and use it in GitHub Desktop.
it("Should preserve boundaries after the program has run", async () => {
const boundary = createBoundary();
const handler: Handler = {
*[DefaultEffectHandler](_, resume) {
return yield resume("it works!");
}
};
function* root() {
yield boundary.withContext();
return yield "complete";
}
const programResult = await runProgram(withHandler(handler, root()));
expect(programResult).toBe("complete");
const result = await boundary.into(function*() {
return yield performEffect({ type: "anything at all" });
})();
expect(result).toBe("it works!");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment