MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / fakeTransport

Function fakeTransport

test/bot-artifact.test.ts:5–19  ·  view source on GitHub ↗
(withPhoto = true)

Source from the content-addressed store, hash-verified

3import type { Transport, Incoming, MessageRef, Button, AgentRunner, TurnSink, ArtifactCard } from '../src/bot/types.ts';
4
5function fakeTransport(withPhoto = true) {
6 let onMsg: (m: Incoming) => void = () => {};
7 const sent: Array<{ text: string; buttons?: Button[][] }> = [];
8 const photos: Array<{ path: string; caption?: string; buttons?: Button[][] }> = [];
9 const t: Transport = {
10 platform: 'telegram', maxLen: 4000, minEditIntervalMs: 0,
11 start: async (cb) => { onMsg = cb; }, stop: async () => {},
12 send: async (_c, text, buttons) => { sent.push({ text, buttons }); return { id: 'm' } as MessageRef; },
13 edit: async () => {},
14 ackCallback: async () => {},
15 ...(withPhoto ? { sendPhoto: async (_c: string, path: string, caption?: string, buttons?: Button[][]) => { photos.push({ path, caption, buttons }); return { id: 'p' } as MessageRef; } } : {}),
16 };
17 const inject = (m: Partial<Incoming>) => onMsg({ platform: 'telegram', chatId: 'c1', userId: 'u1', text: '', ...m } as Incoming);
18 return { t, sent, photos, inject };
19}
20
21const allow = { telegram: { allowedUsers: ['u1'] } };
22const flush = async () => { for (let i = 0; i < 4; i++) await new Promise(r => setTimeout(r, 0)); };

Callers 1

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected