import { describe, expect, it } from 'vitest'; import { BOT_BUTTON_ID, botInfoPopup } from './nativedialogs'; describe('botInfoPopup', () => { it('inlines the bot handle and adds an open-bot button', () => { const p = botInfoPopup('Title', 'Open the bot {bot} to play.', 'erudit_bot', 'OK'); expect(p.title).toBe('Title'); expect(p.message).toBe('Open the bot @erudit_bot to play.'); expect(p.buttons).toEqual([ { id: BOT_BUTTON_ID, text: '@erudit_bot' }, { id: 'ok', text: 'OK' }, ]); }); it('drops the token and the open-bot button when no username is known', () => { const p = botInfoPopup('Title', 'Open the bot {bot} to play.', '', 'OK'); expect(p.message).toBe('Open the bot to play.'); expect(p.buttons).toEqual([{ id: 'ok', text: 'OK' }]); }); it('preserves newlines in the message', () => { const p = botInfoPopup('Hi', 'Welcome!\n\nUse {bot} now.', 'b', 'OK'); expect(p.message).toBe('Welcome!\n\nUse @b now.'); }); });