d5c3f39871
Round-2 test-only locks tightening lax `.toContain()` to exact equality, mirroring
Ink's `t.is` assertions (all behaviors already at parity):
- cursor-helpers: buildCursorSuffix/buildReturnToBottom/buildReturnToBottomPrefix/
buildCursorOnlySequence exact full output + show/hide cursor constant literals.
- render-to-string: column "Line 1\nLine 2", paddingLeft " Padded", a byte-exact
single-border 20-wide frame, and byte-exact gap wrap ("A B\n\nC") + column ("A\n\nB")
(the trimLines live tests can't catch trailing-space regressions).
- text: OSC-8 link exact bytes; a new RIS/ESC-c strip test (the existing test only
covered the ESC#8 leg).
- box-in-text validation: the exact "Text string \"…\" must be rendered inside <Text>
component" message via anchored regex (catches extra prefix/suffix, not just substring).
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { defineComponent } from "vue";
|
||
import { expect, test } from "vite-plus/test";
|
||
import { render } from "@vue-tui/testing";
|
||
import { Box, Text } from "@vue-tui/runtime";
|
||
|
||
test("<Box> inside <Text> throws an error", async () => {
|
||
const App = defineComponent(() => () => (
|
||
<Text>
|
||
<Box />
|
||
</Text>
|
||
));
|
||
|
||
await expect(render(App)).rejects.toThrow("can’t be nested inside <Text>");
|
||
});
|
||
|
||
test("fail when text nodes are not within <Text> component (mixed)", async () => {
|
||
const App = defineComponent(() => () => (
|
||
<Box>
|
||
Hello
|
||
<Text>World</Text>
|
||
</Box>
|
||
));
|
||
// Lock the EXACT message including the quoted offending string. Ink components.tsx.
|
||
// Anchored regex (not a substring) so extra prefix/suffix text would fail too.
|
||
await expect(render(App)).rejects.toThrow(
|
||
/^Text string "Hello" must be rendered inside <Text> component$/,
|
||
);
|
||
});
|
||
|
||
test("fail when text node is not within <Text> component (full)", async () => {
|
||
const App = defineComponent(() => () => <Box>Hello World</Box>);
|
||
// Lock the EXACT message: the whole offending string is quoted. Ink components.tsx.
|
||
// Anchored regex (not a substring) so extra prefix/suffix text would fail too.
|
||
await expect(render(App)).rejects.toThrow(
|
||
/^Text string "Hello World" must be rendered inside <Text> component$/,
|
||
);
|
||
});
|