Problem
Project has vitest run configured but zero test files. CLAUDE.md recommends adding coverage when extending telegram-client.js or message-sync-service.js by mocking MTProto responses.
Proposed solution
Add unit tests starting with the most critical modules:
-
telegram-client.test.js — mock gramjs client.sendText/client.sendFile, verify:
sendTextMessage passes correct params (noWebpage, replyTo, parse mode)
sendFileMessage passes correct params
- Input validation (empty text, missing file)
normalizeChannelId handling
-
mcp-server.test.js — test MCP tool handlers with mocked telegramClient:
- Schema validation (zod schemas reject invalid input)
- Handlers pass correct options to client methods
- Response format
-
cli.test.js — test CLI option parsing:
--no-preview maps to noPreview: true
--parse-mode normalization
--topic / --reply-to parsing
Notes
- Use vitest
- Mock MTProto layer (gramjs) — no real Telegram calls
- Name files
<module>.test.js in project root or tests/ directory
- Consider dependency injection or module mocking for
TelegramClient
See also: #10 (added --no-preview without tests)
Problem
Project has
vitest runconfigured but zero test files. CLAUDE.md recommends adding coverage when extendingtelegram-client.jsormessage-sync-service.jsby mocking MTProto responses.Proposed solution
Add unit tests starting with the most critical modules:
telegram-client.test.js — mock gramjs
client.sendText/client.sendFile, verify:sendTextMessagepasses correct params (noWebpage,replyTo, parse mode)sendFileMessagepasses correct paramsnormalizeChannelIdhandlingmcp-server.test.js — test MCP tool handlers with mocked
telegramClient:cli.test.js — test CLI option parsing:
--no-previewmaps tonoPreview: true--parse-modenormalization--topic/--reply-toparsingNotes
<module>.test.jsin project root ortests/directoryTelegramClientSee also: #10 (added
--no-previewwithout tests)