Files
vue-tui/packages/runtime-tests/integration/components/transform.test.tsx
T
Yunfei He 562b07b60e test: port Ink component tests (38 tests)
Distributes across text, static, transform, newline-spacer,
error-handling, and prop-reset test files.

Tests requiring features not yet in vue-tui are marked test.todo:
- <Transform> inside <Text> (paint pass limitation)
- multi-line transform (transform nodes not yoga carriers)
- text/box nesting validation (no runtime validation yet)
- complex Static rerender patterns (Ink-specific API)

Also fixes wrap="hard" to use wordWrap:false so text breaks at exact
character boundaries rather than word boundaries, matching Ink behavior.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 22:01:10 +08:00

51 lines
1.8 KiB
TypeScript

import { defineComponent } from "vue";
import { expect, test } from "vite-plus/test";
import { render } from "@vue-tui/testing";
import { Text, Transform } from "@vue-tui/runtime";
test("Transform uppercases descendant text", async () => {
const { lastFrame } = await render(() => (
<Transform transform={(line: string) => line.toUpperCase()}>
<Text>abc</Text>
</Transform>
));
expect(lastFrame()).toContain("ABC");
});
// --- Ink transform tests ---
// NOTE: Tests that use <Transform> inside <Text> (i.e. a transform node as a
// child of a text node) are marked todo. vue-tui's renderTextWithInlineStyles
// only handles text-leaf and virtual-text children; transform nodes nested
// inside a text node are not supported in the current paint pass.
test.todo("transform children — <Transform> inside <Text> not supported in paint pass");
test.todo("squash multiple text nodes — <Transform> inside <Text> not supported in paint pass");
test.todo(
"transform with multiple lines — transform nodes are not yoga carriers; root yoga height does not account for multi-line text under a transform node",
);
test.todo(
"squash multiple nested text nodes — <Transform> inside <Text> not supported in paint pass",
);
test.todo("squash empty <Text> nodes — <Transform> inside <Text> not supported in paint pass");
test("<Transform> with undefined children", async () => {
const { lastFrame } = await render(
defineComponent(() => () => <Transform transform={(s: string) => s} />),
{ columns: 100 },
);
expect(lastFrame()).toBe("");
});
test("<Transform> with null children", async () => {
const { lastFrame } = await render(
defineComponent(() => () => <Transform transform={(s: string) => s} />),
{ columns: 100 },
);
expect(lastFrame()).toBe("");
});