import { describe, it, expect } from 'vitest'; import { buildQuoteHeader, formatQuoteSender } from '../quote-header'; describe('quote header', () => { it('renders Name escaped in the reply line', () => { const h = buildQuoteHeader({ mode: 'reply', email: { from: { name: 'Alice', email: 'a@b.com' }, receivedAt: '2026-04-27T10:00:00Z' }, timeFormat: '24h', unknownLabel: 'Unknown', }); expect(h.wrapInBlockquote).toBe(true); expect(h.html).toMatch(/^
On .+, Alice <a@b\.com> wrote:
<\/div>$/); expect(h.text).toMatch(/Alice wrote:\n$/); }); it('uses localized labels', () => { const h = buildQuoteHeader({ mode: 'forward', email: { from: { email: 'a@b.com' }, subject: 'S' }, timeFormat: '24h', unknownLabel: 'Unbekannt', labels: { replyLine: 'Am {date} schrieb {from}:', forwardedSeparator: '---------- Weitergeleitete Nachricht ----------', fromLabel: 'Von', dateLabel: 'Datum', subjectLabel: 'Betreff', }, }); expect(h.wrapInBlockquote).toBe(false); expect(h.html).toContain('Weitergeleitete Nachricht'); expect(h.html).toContain('Von: a@b.com
Datum:
Betreff: S'); }); it('collapses the date when unknown', () => { const h = buildQuoteHeader({ mode: 'reply', email: { from: { email: 'a@b.com' } }, timeFormat: '24h', unknownLabel: 'U' }); expect(h.html).toBe('
a@b.com wrote:
'); expect(formatQuoteSender(undefined, 'U')).toBe('U'); }); });