tests pass

This commit is contained in:
Eason Goodale
2025-04-19 18:49:29 -07:00
parent 0d6a98f9af
commit 35148c2ba9
14 changed files with 783 additions and 6 deletions

View File

@@ -0,0 +1,28 @@
import React from "react";
import { render } from "ink-testing-library";
import stripAnsi from "strip-ansi";
export function renderTui(ui) {
const { stdin, lastFrame, unmount, cleanup } = render(ui, {
exitOnCtrlC: false,
});
// Some libraries assume these methods exist on TTY streams; add noops.
if (stdin && typeof stdin.ref !== "function") {
// @ts-ignore
stdin.ref = () => {};
}
if (stdin && typeof stdin.unref !== "function") {
// @ts-ignore
stdin.unref = () => {};
}
const lastFrameStripped = () => stripAnsi(lastFrame() ?? "");
async function flush() {
// wait one tick for Ink to process
await new Promise((resolve) => setTimeout(resolve, 0));
}
return { stdin, lastFrame, lastFrameStripped, unmount, cleanup, flush };
}