Fake transport that also captures the native command-menu registration.
()
| 5 | |
| 6 | /** Fake transport that also captures the native command-menu registration. */ |
| 7 | function 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 | |
| 23 | const allow = { telegram: { allowedUsers: ['u1'] } }; |
| 24 | const flush = () => new Promise(r => setTimeout(r, 0)); |
no test coverage detected