Files
vue-tui/packages/testing/tests/streams.test.ts
T
Yunfei He 71c517b79f feat(testing): test harness for @vue-tui/runtime
Provides render() for integration testing — async with auto-flush,
trimmed frames, fake terminal with resize(), stdin.write() with
auto-flush, and auto-cleanup via afterEach.

Exports: render, cleanup, RenderResult, RenderOptions, Terminal

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 18:13:47 +08:00

24 lines
716 B
TypeScript

import { expect, test } from "vite-plus/test";
import { makeFakeStdin, makeFakeWritable } from "../src/streams.ts";
test("fake stdout reports columns/rows and isTTY", () => {
const s = makeFakeWritable({ columns: 50, rows: 10 });
expect(s.columns).toBe(50);
expect(s.rows).toBe(10);
expect(s.isTTY).toBe(true);
});
test("fake stdin supports setRawMode and emits data", () => {
const { stream: s, rawMode } = makeFakeStdin();
expect(s.isTTY).toBe(true);
let observed = "";
s.on("data", (c) => {
observed += c.toString();
});
s.setRawMode(true);
expect(rawMode.current).toBe(true);
expect(rawMode.history).toEqual([true]);
s.emit("data", "hello");
expect(observed).toBe("hello");
});