16 lines
584 B
TypeScript
16 lines
584 B
TypeScript
import type { ChannelClient } from "./telegram.ts";
|
|
|
|
/** Мок Telegram-канала: запоминает сообщения; `failing = true` — имитирует недоступность. */
|
|
export function mockChannel(): ChannelClient & { sent: { chatId: string; text: string }[]; failing: boolean } {
|
|
const sent: { chatId: string; text: string }[] = [];
|
|
const m = {
|
|
sent,
|
|
failing: false,
|
|
async sendMessage(chatId: string, text: string) {
|
|
if (m.failing) throw new Error("mock channel down");
|
|
sent.push({ chatId, text });
|
|
},
|
|
};
|
|
return m;
|
|
}
|