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

Function fakeTransport

test/bot-gateway.test.ts:6–20  ·  view source on GitHub ↗

A fake transport that captures sends and lets the test inject inbound messages.

(platform: 'telegram' | 'discord' = 'telegram')

Source from the content-addressed store, hash-verified

4
5/** A fake transport that captures sends and lets the test inject inbound messages. */
6function fakeTransport(platform: 'telegram' | 'discord' = 'telegram') {
7 let onMsg: (m: Incoming) => void = () => {};
8 const sent: Array<{ chatId: string; text: string; buttons?: Button[][] }> = [];
9 let n = 0;
10 const t: Transport = {
11 platform, maxLen: 4000, minEditIntervalMs: 0,
12 start: async (cb) => { onMsg = cb; },
13 stop: async () => {},
14 send: async (chatId, text, buttons) => { sent.push({ chatId, text, buttons }); return { id: `m${++n}` } as MessageRef; },
15 edit: async () => {},
16 ackCallback: async () => {},
17 };
18 const inject = (m: Partial<Incoming>) => onMsg({ platform, chatId: 'c1', userId: 'u1', text: '', ...m } as Incoming);
19 return { t, sent, inject };
20}
21
22const allowAll = { telegram: { allowedUsers: ['u1'] }, discord: { allowedUsers: ['u1'] } };
23const flush = () => new Promise(r => setTimeout(r, 0));

Callers 1

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected