( counts: readonly number[], target: number, timeoutMs: number, )
| 268 | }); |
| 269 | |
| 270 | async function waitForCount( |
| 271 | counts: readonly number[], |
| 272 | target: number, |
| 273 | timeoutMs: number, |
| 274 | ): Promise<void> { |
| 275 | const deadline = Date.now() + timeoutMs; |
| 276 | while (Date.now() < deadline) { |
| 277 | if (counts.includes(target)) return; |
| 278 | await new Promise((res) => { |
| 279 | setTimeout(res, 10); |
| 280 | }); |
| 281 | } |
| 282 | throw new Error(`count ${String(target)} not observed; got ${JSON.stringify(counts)}`); |
| 283 | } |
| 284 | |
| 285 | describe('WS gateway connection-count observer', () => { |
| 286 | it('reports size 1 after a connect and size 0 after the last disconnect', async () => { |
no test coverage detected