feat(companion): return clearEventSubscriptions result counts

This commit is contained in:
William Valentin
2026-02-16 22:26:23 -08:00
parent 06bdb27f70
commit ffc7c4e9b3
7 changed files with 49 additions and 13 deletions
+9 -2
View File
@@ -267,7 +267,7 @@ describe('CompanionRuntimeClient', () => {
const handlerB = vi.fn();
client.subscribeEvents(handlerA);
client.subscribeEvent('agent.stream', handlerB);
client.clearEventSubscriptions();
const clearResult = client.clearEventSubscriptions();
(client as unknown as { handleMessage: (raw: string) => void }).handleMessage(
JSON.stringify({
@@ -279,6 +279,10 @@ describe('CompanionRuntimeClient', () => {
expect(handlerA).not.toHaveBeenCalled();
expect(handlerB).not.toHaveBeenCalled();
expect(clearResult).toEqual({
clearedSubscriptions: 2,
cancelledWaits: 0,
});
});
it('dispose clears subscriptions and is safe to call repeatedly', () => {
@@ -385,7 +389,10 @@ describe('CompanionRuntimeClient', () => {
const awaited = expect(
client.waitForEvent('agent.stream', { timeoutMs: 10_000 }),
).rejects.toThrow('Event subscriptions cleared');
client.clearEventSubscriptions();
expect(client.clearEventSubscriptions()).toEqual({
clearedSubscriptions: 1,
cancelledWaits: 1,
});
await awaited;
});