test: extend typing idle coverage

This commit is contained in:
Peter Steinberger
2026-01-06 03:31:35 +00:00
parent 97afd3a388
commit 5946f4c341
2 changed files with 78 additions and 0 deletions

View File

@@ -30,4 +30,25 @@ describe("typing controller", () => {
vi.advanceTimersByTime(2_000);
expect(onReplyStart).toHaveBeenCalledTimes(4);
});
it("keeps typing until both idle and run completion are set", async () => {
vi.useFakeTimers();
const onReplyStart = vi.fn(async () => {});
const typing = createTypingController({
onReplyStart,
typingIntervalSeconds: 1,
typingTtlMs: 30_000,
});
await typing.startTypingLoop();
expect(onReplyStart).toHaveBeenCalledTimes(1);
typing.markDispatchIdle();
vi.advanceTimersByTime(2_000);
expect(onReplyStart).toHaveBeenCalledTimes(3);
typing.markRunComplete();
vi.advanceTimersByTime(2_000);
expect(onReplyStart).toHaveBeenCalledTimes(3);
});
});