3ee01dc278
Add four behavioral surfaces to the runtime:
- patchConsole (default: true): intercepts console.* methods to route
output through writeToStdout/writeToStderr, preventing frame corruption.
Disabled in debug mode. Restored before Vue cleanup on teardown.
- waitUntilRenderFlush(): flushes pending throttled renders and waits
for the stdout write barrier, exposed on TuiApp and testing RenderResult.
- onRender callback: fires after each commit with { renderTime } in ms.
- maxFps option: overrides the scheduler's default 32ms throttle interval
with 1000/maxFps. The scheduler now accepts a throttleMs option and
exposes hasPending() for flush coordination.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
22 lines
971 B
TypeScript
22 lines
971 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("patchConsole is disabled in debug mode (testing render uses debug)", async () => {
|
|
// The testing render() helper uses debug: true, which auto-disables
|
|
// patchConsole. Verify that the app still renders correctly without it.
|
|
const App = defineComponent(() => () => <Text>UI</Text>);
|
|
const { lastFrame } = await render(App);
|
|
expect(lastFrame()).toContain("UI");
|
|
});
|
|
|
|
test("patchConsole option defaults to true and can be set to false", async () => {
|
|
// This test just verifies the option is accepted without throwing.
|
|
// Since testing uses debug mode, patchConsole is a no-op regardless,
|
|
// but the option path must not error.
|
|
const App = defineComponent(() => () => <Text>hello</Text>);
|
|
const { lastFrame } = await render(App);
|
|
expect(lastFrame()).toContain("hello");
|
|
});
|