Files
vue-tui/packages/runtime-tests/integration/lifecycle/sigint.test.tsx
T
Yunfei He a7f7d9957d feat(runtime-tests): integration test suite
21 test files covering components, composables, focus, lifecycle,
and scheduler through the public render() API.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 18:13:53 +08:00

26 lines
879 B
TypeScript

import { defineComponent } from "vue";
import { expect, test } from "vite-plus/test";
import { render } from "@vue-tui/testing";
import { Text } from "@vue-tui/runtime";
test("exitOnCtrlC registers a SIGINT handler that unmount removes", async () => {
const before = process.listenerCount("SIGINT");
const App = defineComponent(() => () => <Text>x</Text>);
const { unmount } = await render(App, { exitOnCtrlC: true });
expect(process.listenerCount("SIGINT")).toBe(before + 1);
unmount();
expect(process.listenerCount("SIGINT")).toBe(before);
});
test("exitOnCtrlC=false registers no SIGINT handler", async () => {
const before = process.listenerCount("SIGINT");
const App = defineComponent(() => () => <Text>x</Text>);
const { unmount } = await render(App, { exitOnCtrlC: false });
expect(process.listenerCount("SIGINT")).toBe(before);
unmount();
});