feat(companion): add clearEventSubscriptions helper
This commit is contained in:
@@ -196,6 +196,28 @@ describe('CompanionRuntimeClient', () => {
|
||||
expect(streamHandler).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('clears all event subscriptions', () => {
|
||||
const client = new CompanionRuntimeClient({
|
||||
url: 'ws://127.0.0.1:1',
|
||||
});
|
||||
const handlerA = vi.fn();
|
||||
const handlerB = vi.fn();
|
||||
client.subscribeEvents(handlerA);
|
||||
client.subscribeEvent('agent.stream', handlerB);
|
||||
client.clearEventSubscriptions();
|
||||
|
||||
(client as unknown as { handleMessage: (raw: string) => void }).handleMessage(
|
||||
JSON.stringify({
|
||||
id: 50,
|
||||
event: 'agent.stream',
|
||||
data: { token: 'cleared' },
|
||||
}),
|
||||
);
|
||||
|
||||
expect(handlerA).not.toHaveBeenCalled();
|
||||
expect(handlerB).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('waitForEvent resolves using optional predicate filter', async () => {
|
||||
const client = new CompanionRuntimeClient({
|
||||
url: 'ws://127.0.0.1:1',
|
||||
|
||||
Reference in New Issue
Block a user