1ffb847a65
Closes remaining test gaps between vue-tui and Ink: Features: - Add synchronized output (BSU/ESU) via DEC private mode 2026 - Add clear() API to TuiApp for erasing rendered output Bug fixes: - Cancel scheduler trailing timer on teardown (prevents stale commits) - Guard teardown writes against ended/destroyed streams - Reorder teardown to cancel timer before final commit Tests (64 new, 2 skipped for known feature gaps): - 7 BSU/ESU shouldSynchronize tests - 5 borderBackgroundColor tests - 13 component edge cases (empty text, number child, OSC hyperlink wrap-width, bare-text-in-Box validation, transform multi-line, leading whitespace, link escape closing) - 13 text-width/CJK tests (alignment, truncation, overlay edge cases) - 4 throttle + unmount edge cases - 10 waitUntilRenderFlush write-callback-level tests + 1 clear() test - 3 exit re-entrance tests - 5 PTY #450 regression tests + 4 inline #450 tests Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { EventEmitter } from "node:events";
|
|
import { test, expect } from "vite-plus/test";
|
|
import isInCi from "is-in-ci";
|
|
import { bsu, esu, shouldSynchronize } from "../../../runtime/src/io/write-synchronized.ts";
|
|
|
|
const createStream = ({ tty = false } = {}) => {
|
|
const stream = new EventEmitter() as unknown as NodeJS.WriteStream;
|
|
if (tty) {
|
|
stream.isTTY = true;
|
|
}
|
|
return stream;
|
|
};
|
|
|
|
test("bsu is the expected synchronized update sequence", () => {
|
|
expect(bsu).toBe("\x1b[?2026h");
|
|
});
|
|
|
|
test("esu is the expected synchronized update sequence", () => {
|
|
expect(esu).toBe("\x1b[?2026l");
|
|
});
|
|
|
|
test("shouldSynchronize returns true for interactive TTY stream", () => {
|
|
const stream = createStream({ tty: true });
|
|
expect(shouldSynchronize(stream, true)).toBe(true);
|
|
});
|
|
|
|
test("shouldSynchronize returns false for non-interactive TTY stream", () => {
|
|
const stream = createStream({ tty: true });
|
|
expect(shouldSynchronize(stream, false)).toBe(false);
|
|
});
|
|
|
|
test("shouldSynchronize returns false for non-TTY stream", () => {
|
|
const stream = createStream({ tty: false });
|
|
expect(shouldSynchronize(stream, true)).toBe(false);
|
|
});
|
|
|
|
test("shouldSynchronize uses CI detection when interactive is not specified", () => {
|
|
const ttyStream = createStream({ tty: true });
|
|
if (isInCi) {
|
|
expect(shouldSynchronize(ttyStream)).toBe(false);
|
|
} else {
|
|
expect(shouldSynchronize(ttyStream)).toBe(true);
|
|
}
|
|
});
|
|
|
|
test("shouldSynchronize returns false for non-TTY stream when interactive is not specified", () => {
|
|
const stream = createStream({ tty: false });
|
|
expect(shouldSynchronize(stream)).toBe(false);
|
|
});
|