22import type { Bot } from "grammy" ;
33import { afterEach , beforeEach , describe , expect , it , vi } from "vitest" ;
44import { createTelegramDraftStream } from "./draft-stream.js" ;
5- import type { TelegramInputRichMessage } from "./rich-message.js" ;
5+ import { buildTelegramRichMarkdown , type TelegramInputRichMessage } from "./rich-message.js" ;
66
77type TelegramDraftStreamParams = Parameters < typeof createTelegramDraftStream > [ 0 ] ;
88
@@ -308,7 +308,7 @@ describe("createTelegramDraftStream", () => {
308308 expect ( api . raw . sendRichMessageDraft ) . toHaveBeenCalledWith ( {
309309 chat_id : 123 ,
310310 draft_id : expect . any ( Number ) ,
311- rich_message : { html : markdownToTelegramRichHtml ( "Hello" ) } ,
311+ rich_message : buildTelegramRichMarkdown ( "Hello" ) ,
312312 message_thread_id : 42 ,
313313 } ) ;
314314 expect ( api . raw . sendRichMessage ) . not . toHaveBeenCalled ( ) ;
@@ -347,11 +347,11 @@ describe("createTelegramDraftStream", () => {
347347 expect ( api . raw . sendRichMessageDraft ) . toHaveBeenCalledWith ( {
348348 chat_id : 123 ,
349349 draft_id : expect . any ( Number ) ,
350- rich_message : { html : markdownToTelegramRichHtml ( "Hello" ) } ,
350+ rich_message : buildTelegramRichMarkdown ( "Hello" ) ,
351351 } ) ;
352352 expect ( api . raw . sendRichMessage ) . toHaveBeenCalledWith ( {
353353 chat_id : 123 ,
354- rich_message : { html : markdownToTelegramRichHtml ( "Hello" ) } ,
354+ rich_message : buildTelegramRichMarkdown ( "Hello" ) ,
355355 } ) ;
356356 } ) ;
357357
@@ -373,7 +373,7 @@ describe("createTelegramDraftStream", () => {
373373 expect ( api . raw . sendRichMessageDraft ) . toHaveBeenCalledTimes ( 1 ) ;
374374 expect ( api . raw . sendRichMessage ) . toHaveBeenCalledWith ( {
375375 chat_id : 123 ,
376- rich_message : { html : markdownToTelegramRichHtml ( "Hello" ) } ,
376+ rich_message : buildTelegramRichMarkdown ( "Hello" ) ,
377377 } ) ;
378378 expect ( warn . mock . calls [ 0 ] ?. [ 0 ] ) . toContain ( "falling back to preview message" ) ;
379379 } ) ;
@@ -386,7 +386,7 @@ describe("createTelegramDraftStream", () => {
386386 await stream . flush ( ) ;
387387
388388 expect ( api . raw . sendRichMessageDraft ) . not . toHaveBeenCalled ( ) ;
389- expectRichSend ( api , "Hello" , { message_thread_id : 99 } ) ;
389+ expect ( api . sendMessage ) . toHaveBeenCalledWith ( 123 , "Hello" , { message_thread_id : 99 } ) ;
390390 } ) ;
391391
392392 it ( "deletes message preview on clear after finalization" , async ( ) => {
0 commit comments