2026-05-26 01:04:16 +08:00
|
|
|
|
import { defineComponent } from "vue";
|
2026-05-26 13:37:39 +08:00
|
|
|
|
import { expect, test } from "vite-plus/test";
|
2026-05-26 01:04:16 +08:00
|
|
|
|
import { render } from "@vue-tui/testing";
|
|
|
|
|
|
import { Box, Text } from "@vue-tui/runtime";
|
|
|
|
|
|
|
2026-05-26 13:37:39 +08:00
|
|
|
|
test("<Box> inside <Text> throws an error", async () => {
|
|
|
|
|
|
const App = defineComponent(() => () => (
|
|
|
|
|
|
<Text>
|
|
|
|
|
|
<Box />
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
));
|
2026-05-26 01:04:16 +08:00
|
|
|
|
|
2026-05-26 13:37:39 +08:00
|
|
|
|
await expect(render(App)).rejects.toThrow("can’t be nested inside <Text>");
|
2026-05-26 01:04:16 +08:00
|
|
|
|
});
|
2026-05-28 10:04:54 +08:00
|
|
|
|
|
|
|
|
|
|
test("fail when text nodes are not within <Text> component (mixed)", async () => {
|
|
|
|
|
|
const App = defineComponent(() => () => (
|
|
|
|
|
|
<Box>
|
|
|
|
|
|
Hello
|
|
|
|
|
|
<Text>World</Text>
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
));
|
|
|
|
|
|
await expect(render(App)).rejects.toThrow("must be rendered inside <Text>");
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test("fail when text node is not within <Text> component (full)", async () => {
|
|
|
|
|
|
const App = defineComponent(() => () => <Box>Hello World</Box>);
|
|
|
|
|
|
await expect(render(App)).rejects.toThrow("must be rendered inside <Text>");
|
|
|
|
|
|
});
|