Personal Telegram developer console for GitHub

test: require Telegram bot token to fail closed

davoodmehraban89 committed Oct 2, 2026 at 22:47 UTC 1b4f6d723e0d4bd7a267ebcfc739b1f3f665c31a
1 file changed +9
test/telegram.test.js
+9
@@ -2,6 +2,15 @@ import test from 'node:test';
2 import assert from 'node:assert/strict';
3 import { TelegramClient } from '../src/telegram.js';
4
5 +test('TelegramClient fails closed when TELEGRAM_BOT_TOKEN is missing', async () => {
6 + const client = new TelegramClient('');
7 +
8 + await assert.rejects(
9 + () => client.sendMessage(1, 'hello'),
10 + /TELEGRAM_BOT_TOKEN is not configured/i
11 + );
12 +});
13 +
14 test('TelegramClient rejects HTTP-level Telegram API failures', async () => {
15 const client = new TelegramClient('token', {
16 fetch: async () => new Response(JSON.stringify({ ok: false, description: 'Bad Request' }), {