import { defineComponent, shallowRef } from "vue"; import { expect, test } from "vite-plus/test"; import { render } from "@vue-tui/testing"; import { Box, Text, useInput } from "@vue-tui/runtime"; test("counter responds to + and - keys", async () => { const Counter = defineComponent(() => { const count = shallowRef(0); useInput((input) => { if (input === "+") count.value++; if (input === "-") count.value--; }); return () => ( Count: {count.value} ); }); const { lastFrame, stdin } = await render(Counter); expect(lastFrame()).toContain("Count: 0"); await stdin.write("+"); expect(lastFrame()).toContain("Count: 1"); await stdin.write("+"); await stdin.write("+"); expect(lastFrame()).toContain("Count: 3"); await stdin.write("-"); expect(lastFrame()).toContain("Count: 2"); });