c8c2c4a32d
Regression tests for behaviors the audit found correct-but-unpinned, so the suite is a strict superset of Ink: - A07: two <Static> regions both render (the additive divergence) - B04: Static render-prop index = absolute index across appends; container vertical padding adds blank rows to the static frame - B11: lazy raw-mode acquire/release under rawMode:'auto' (the path the 'always' default masks) - B19: child useCursor unmount emits the cursor-hide escape (stream-level) - B20: animation interval 0/negative clamps to 1ms (normalizeInterval unit) and advances without busy-hang - B21/B28: INK_SCREEN_READER env auto-detection + useIsScreenReaderEnabled true-path (env tests isolated in a *.sequential file per the global-state rule) - B29: renderToString serves useCursor/usePaste/useTerminalSize/useAnimation/ useBoxMetrics as inert no-ops (don't throw) - B30: dedicated columnGap/rowGap props + their removal-reset Test-only; no production changes. Codex-reviewed for non-vacuousness, Ink correctness, and process-global isolation. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
35 lines
1.5 KiB
TypeScript
35 lines
1.5 KiB
TypeScript
import { defineComponent } from "vue";
|
|
import { expect, test } from "vite-plus/test";
|
|
import { render } from "@vue-tui/testing";
|
|
import { Text, renderToString, useIsScreenReaderEnabled } from "@vue-tui/runtime";
|
|
|
|
// NOTE: tests that auto-detect SR via the process-GLOBAL env var
|
|
// `INK_SCREEN_READER` live in use-screen-reader-env.sequential.test.tsx (the
|
|
// repo's process-global convention). The tests below never mutate that global.
|
|
|
|
test("useIsScreenReaderEnabled returns false by default", async () => {
|
|
let result = false;
|
|
const App = defineComponent(() => {
|
|
result = useIsScreenReaderEnabled();
|
|
return () => <Text>sr test</Text>;
|
|
});
|
|
await render(App);
|
|
expect(result).toBe(false);
|
|
});
|
|
|
|
// B28: the existing test only covers the `false` default. When SR IS enabled,
|
|
// useIsScreenReaderEnabled() must return `true`. It reads ctx.isScreenReaderEnabled
|
|
// (useIsScreenReaderEnabled.ts:8), which renderToString seeds from the
|
|
// isScreenReaderEnabled option (render-to-string.ts:61-64,179).
|
|
test("useIsScreenReaderEnabled returns true when SR is enabled (renderToString option)", () => {
|
|
let result: boolean | undefined;
|
|
const App = defineComponent(() => {
|
|
result = useIsScreenReaderEnabled();
|
|
return () => <Text>sr enabled</Text>;
|
|
});
|
|
const output = renderToString(App, { isScreenReaderEnabled: true });
|
|
// Composable observed the enabled flag, and the SR text still rendered.
|
|
expect(result).toBe(true);
|
|
expect(output).toBe("sr enabled");
|
|
});
|