Files
vue-tui/packages/runtime-tests/integration/scheduler-throttle.test.tsx
T
Yunfei He 8565f41827 feat: add time-based render throttle (~30fps) matching Ink
Add leading+trailing throttle to the commit scheduler in production mode.
In debug/test mode (immediate: true), commits fire without delay to
preserve test determinism. Adjusted the non-debug static test to account
for the throttle timer.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 00:55:02 +08:00

25 lines
767 B
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("rapid mutations in debug mode produce immediate frames (no throttle)", async () => {
const count = shallowRef(0);
const App = defineComponent(() => {
return () => <Text>{String(count.value)}</Text>;
});
const { frames } = await render(App);
const before = frames.length;
// Each mutation + tick should produce a frame in debug mode
for (let i = 1; i <= 5; i++) {
count.value = i;
await nextTick();
await nextTick();
}
// In debug mode (used by testing), each mutation produces a frame
expect(frames.length - before).toBe(5);
});