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>
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { defineComponent, nextTick, shallowRef } from "vue";
|
|
import { expect, test } from "vite-plus/test";
|
|
import { render } from "@vue-tui/testing";
|
|
import { Text } from "@vue-tui/runtime";
|
|
|
|
test("waitUntilRenderFlush resolves after frame is written", async () => {
|
|
const App = defineComponent(() => () => <Text>hello</Text>);
|
|
const result = await render(App);
|
|
await result.waitUntilRenderFlush();
|
|
expect(result.lastFrame()).toContain("hello");
|
|
});
|
|
|
|
test("waitUntilRenderFlush waits for pending state updates", async () => {
|
|
const msg = shallowRef("before");
|
|
const App = defineComponent(() => {
|
|
return () => <Text>{msg.value}</Text>;
|
|
});
|
|
|
|
const result = await render(App);
|
|
expect(result.lastFrame()).toContain("before");
|
|
|
|
msg.value = "after";
|
|
await nextTick();
|
|
await nextTick();
|
|
await result.waitUntilRenderFlush();
|
|
expect(result.lastFrame()).toContain("after");
|
|
});
|
|
|
|
test("waitUntilRenderFlush can be called multiple times", async () => {
|
|
const App = defineComponent(() => () => <Text>stable</Text>);
|
|
const result = await render(App);
|
|
|
|
await result.waitUntilRenderFlush();
|
|
await result.waitUntilRenderFlush();
|
|
expect(result.lastFrame()).toContain("stable");
|
|
});
|