MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / waitFor

Function waitFor

packages/server/test/prompt.e2e.test.ts:246–260  ·  view source on GitHub ↗
(
  received: Record<string, unknown>[],
  pred: (f: Record<string, unknown>) => boolean,
  timeoutMs = 2000,
)

Source from the content-addressed store, hash-verified

244}
245
246async function waitFor(
247 received: Record<string, unknown>[],
248 pred: (f: Record<string, unknown>) => boolean,
249 timeoutMs = 2000,
250): Promise<Record<string, unknown>> {
251 const start = Date.now();
252 while (Date.now() - start < timeoutMs) {
253 const hit = received.find(pred);
254 if (hit !== undefined) return hit;
255 await new Promise((r) => setTimeout(r, 10));
256 }
257 throw new Error(
258 `waitFor timed out; received: ${received.map((f) => f['type']).join(', ')}`,
259 );
260}
261
262describe('POST /api/v1/sessions/{sid}/prompts — submit validation (W7.2 / Chain 4)', () => {
263 it('rejects an empty content array with 40001', async () => {

Callers 2

openSubscriberFunction · 0.70
prompt.e2e.test.tsFile · 0.70

Calls 1

nowMethod · 0.65

Tested by

no test coverage detected