Files
vue-tui/packages/runtime-tests/integration/focus/raw-mode-swap.test.tsx
T
Yunfei He 5e54e5742d refactor: replace ref() with shallowRef() in all test files
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>
2026-05-25 23:28:06 +08:00

31 lines
904 B
TypeScript

import { defineComponent, nextTick, shallowRef } from "vue";
import { expect, test } from "vite-plus/test";
import { render } from "@vue-tui/testing";
import { Text, useFocus } from "@vue-tui/runtime";
test("swapping focusable components never disables raw mode", async () => {
const showA = shallowRef(true);
const Item = defineComponent(() => {
useFocus();
return () => <Text>x</Text>;
});
const Root = defineComponent(() => {
return () => (showA.value ? <Item key="a" /> : <Item key="b" />);
});
const { terminal, unmount } = await render(Root);
expect(terminal.rawMode.current).toBe(true);
const historyBefore = terminal.rawMode.history.length;
showA.value = false;
await nextTick();
expect(terminal.rawMode.current).toBe(true);
const swapHistory = terminal.rawMode.history.slice(historyBefore);
expect(swapHistory).not.toContain(false);
unmount();
});