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

Function fakeTransport

test/bot-commands.test.ts:7–21  ·  view source on GitHub ↗

Fake transport that also captures the native command-menu registration.

()

Source from the content-addressed store, hash-verified

5
6/** Fake transport that also captures the native command-menu registration. */
7function fakeTransport() {
8 let onMsg: (m: Incoming) => void = () => {};
9 const sent: Array<{ text: string; buttons?: Button[][] }> = [];
10 let menu: { command: string; description: string }[] | null = null;
11 const t: Transport = {
12 platform: 'telegram', maxLen: 4000, minEditIntervalMs: 0,
13 start: async (cb) => { onMsg = cb; },
14 stop: async () => {},
15 send: async (_c, text, buttons) => { sent.push({ text, buttons }); return { id: 'm' } as MessageRef; },
16 edit: async () => {},
17 setCommands: async (c) => { menu = c; },
18 };
19 const inject = (text: string) => onMsg({ platform: 'telegram', chatId: 'c1', userId: 'u1', text } as Incoming);
20 return { t, sent, inject, get menu() { return menu; } };
21}
22
23const allow = { telegram: { allowedUsers: ['u1'] } };
24const flush = () => new Promise(r => setTimeout(r, 0));

Callers 1

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected