test(companion): cover pending event wait count lifecycle

This commit is contained in:
William Valentin
2026-02-16 20:53:27 -08:00
parent 21a57c88b9
commit 7e556c5815
3 changed files with 34 additions and 0 deletions
+3
View File
@@ -528,10 +528,12 @@ describe('CompanionRuntimeClient', () => {
const client = new CompanionRuntimeClient({
url: 'ws://127.0.0.1:1',
});
expect(client.pendingEventWaitCount).toBe(0);
const awaited = client.waitForAnyEvent<{ active?: boolean; token?: string }>(
['agent.typing', 'agent.stream'],
{ timeoutMs: 2000 },
);
expect(client.pendingEventWaitCount).toBe(1);
(client as unknown as { handleMessage: (raw: string) => void }).handleMessage(
JSON.stringify({
@@ -545,6 +547,7 @@ describe('CompanionRuntimeClient', () => {
event: 'agent.typing',
data: { active: true },
});
expect(client.pendingEventWaitCount).toBe(0);
});
it('waitForAnyEvent supports per-event predicate filtering', async () => {