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
@@ -131,6 +131,25 @@ describe('platform clients integration', () => {
expect(client.eventSubscriptionCount).toBe(0);
});
it('platform pendingEventWaitCount tracks waitForAnyEvent lifecycle', async () => {
if (!LISTEN_ALLOWED) {
return;
}
const runtime = createRuntime();
const client = new IOSCompanionClient({ runtime, nodeId: 'ios-wait-count-e2e' });
expect(client.pendingEventWaitCount).toBe(0);
const awaited = expect(
client.waitForAnyEvent(['agent.stream'], { timeoutMs: 10_000 }),
).rejects.toThrow('Event subscriptions cleared');
expect(client.pendingEventWaitCount).toBe(1);
client.clearEventSubscriptions();
await awaited;
expect(client.pendingEventWaitCount).toBe(0);
});
it('platform connected reflects runtime connection lifecycle', async () => {
if (!LISTEN_ALLOWED) {
return;