2026-05-25 23:28:06 +08:00
|
|
|
import { defineComponent, shallowRef } from "vue";
|
2026-05-24 18:13:53 +08:00
|
|
|
import { expect, test } from "vite-plus/test";
|
|
|
|
|
import { render } from "@vue-tui/testing";
|
|
|
|
|
import { Box, Text, useInput } from "@vue-tui/runtime";
|
|
|
|
|
|
|
|
|
|
test("README quickstart code runs to a Count: 0 frame", async () => {
|
|
|
|
|
const Counter = defineComponent(() => {
|
2026-05-25 23:28:06 +08:00
|
|
|
const count = shallowRef(0);
|
2026-05-24 18:13:53 +08:00
|
|
|
useInput((input) => {
|
|
|
|
|
if (input === "+") count.value++;
|
|
|
|
|
if (input === "-") count.value--;
|
|
|
|
|
});
|
|
|
|
|
return () => (
|
|
|
|
|
<Box>
|
|
|
|
|
<Text>Count: {count.value}</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const { lastFrame } = await render(Counter);
|
|
|
|
|
expect(lastFrame()).toContain("Count: 0");
|
|
|
|
|
});
|