test(companion): cover cancel wait snapshot updates
This commit is contained in:
@@ -420,6 +420,27 @@ describe('CompanionRuntimeClient', () => {
|
||||
expect(client.cancelPendingEventWaits()).toBe(0);
|
||||
});
|
||||
|
||||
it('cancelPendingEventWaits updates pending work snapshot immediately', async () => {
|
||||
const client = new CompanionRuntimeClient({
|
||||
url: 'ws://127.0.0.1:1',
|
||||
});
|
||||
const pendingWait = client.waitForEvent('agent.stream', { timeoutMs: 10_000 }).catch(() => undefined);
|
||||
|
||||
expect(client.getPendingWorkSnapshot()).toEqual({
|
||||
pendingRequestCount: 0,
|
||||
pendingEventWaitCount: 1,
|
||||
hasPendingWork: true,
|
||||
});
|
||||
|
||||
expect(client.cancelPendingEventWaits('snapshot cancel')).toBe(1);
|
||||
expect(client.getPendingWorkSnapshot()).toEqual({
|
||||
pendingRequestCount: 0,
|
||||
pendingEventWaitCount: 0,
|
||||
hasPendingWork: false,
|
||||
});
|
||||
await pendingWait;
|
||||
});
|
||||
|
||||
it('waitForEvent rejects immediately on disconnect', async () => {
|
||||
const client = new CompanionRuntimeClient({
|
||||
url: 'ws://127.0.0.1:1',
|
||||
|
||||
Reference in New Issue
Block a user