Files
ThothII/backend/test/tht-runner.test.ts
T

15 lines
723 B
TypeScript

import { test, expect } from "vitest";
import { ThtRunner } from "../src/tht/tht-runner.js";
test("sessionNew parses id from JSON", async () => {
const r = new ThtRunner({ thtBin: "tht", harnessDir: "/h", configPath: "config/tht.yaml" });
r.run = async () => ({ code: 0, stdout: '{"id":"2026-06-27-100000-x"}', stderr: "" });
expect(await r.sessionNew({ question: "q" })).toEqual({ id: "2026-06-27-100000-x" });
});
test("run with exit != 0 propagates error with stderr", async () => {
const r = new ThtRunner({ thtBin: "tht", harnessDir: "/h", configPath: "config/tht.yaml" });
r.run = async () => ({ code: 1, stdout: "", stderr: "ERRORE: boom" });
await expect(r.sessionList()).rejects.toThrow(/boom/);
});