feat(companion): return clearEventSubscriptions result counts
This commit is contained in:
@@ -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;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user