5e54e5742d
AGENTS.md requires shallowRef by default. All test state uses reassignment (not mutation), so shallowRef is correct. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { nextTick, shallowRef } from "vue";
|
|
import { expect, test } from "vite-plus/test";
|
|
import { render } from "../src/index.ts";
|
|
import { Text } from "@vue-tui/runtime";
|
|
|
|
test("lastFrame captures rendered output", async () => {
|
|
const { lastFrame } = await render(() => <Text>hello</Text>);
|
|
expect(lastFrame()).toContain("hello");
|
|
});
|
|
|
|
test("frames accumulate on reactive updates", async () => {
|
|
const message = shallowRef("first");
|
|
const { lastFrame, frames } = await render(() => <Text>{message.value}</Text>);
|
|
const initialCount = frames.length;
|
|
expect(lastFrame()).toContain("first");
|
|
|
|
message.value = "second";
|
|
await nextTick();
|
|
expect(lastFrame()).toContain("second");
|
|
expect(frames.length).toBeGreaterThan(initialCount);
|
|
});
|
|
|
|
test("render with custom columns", async () => {
|
|
const { lastFrame } = await render(() => <Text>hello</Text>, { columns: 20 });
|
|
expect(lastFrame()).toContain("hello");
|
|
});
|
|
|
|
test("lastFrame trims trailing whitespace", async () => {
|
|
const { lastFrame } = await render(() => <Text>hi</Text>);
|
|
const frame = lastFrame()!;
|
|
for (const line of frame.split("\n")) {
|
|
expect(line).toBe(line.trimEnd());
|
|
}
|
|
});
|
|
|
|
test("auto cleanup — no manual unmount needed", async () => {
|
|
const { lastFrame } = await render(() => <Text>auto</Text>);
|
|
expect(lastFrame()).toContain("auto");
|
|
});
|