UNPKG

yarn-spinner-runner-ts

Version:

TypeScript parser, compiler, and runtime for Yarn Spinner 3.x with React adapter [NPM package](https://www.npmjs.com/package/yarn-spinner-runner-ts)

35 lines (29 loc) 802 B
import { test } from "node:test"; import { strictEqual } from "node:assert"; import { parseYarn, compile, YarnRunner } from "../index.js"; test("basic dialogue with options", () => { const dialogue = ` title: Start --- Narrator: Hi -> Opt A Narrator: A chosen -> Opt B Narrator: B chosen === `; const doc = parseYarn(dialogue); const ir = compile(doc); const runner = new YarnRunner(ir, { startAt: "Start" }); const r1 = runner.currentResult!; strictEqual(r1.type, "text"); runner.advance(); const r2 = runner.currentResult!; strictEqual(r2.type, "options"); runner.advance(0); const r3 = runner.currentResult!; strictEqual(r3.type, "text"); if (r3.type === "text") { strictEqual(r3.text.includes("A chosen"), true); } });