import { describe, expect, it } from 'vitest'; import { ObjectId } from 'mongodb'; import { renderEmail } from '../src/mailer.js'; import { buildEmail } from '../src/messages.js'; import type { NotificationDoc } from '../src/types.js'; const notif: NotificationDoc = { _id: new ObjectId(), userId: 'u1', content: '🔥 Incendio en Ourense:', geo: { type: 'Point', coordinates: [-7.86, 42.34] }, type: 'web', when: new Date('2026-07-12T18:30:00Z'), sealed: 'fire-xyz', }; describe('renderEmail with ported new-fire templates', () => { it('renders es html + text with the message and links', () => { const content = buildEmail(notif, 'es', 'Ana', { rootUrl: 'https://fuegos.comunes.org/' }); const { html, text } = renderEmail('new-fire', content); expect(html).toContain('Ana'); expect(html).toContain('Incendio en Ourense'); expect(html).toContain('https://fuegos.comunes.org/fire/fire-xyz'); // juice should inline styles (style attribute present on elements) expect(html).toMatch(/style=/); expect(text).toContain('Ana'); expect(text).toContain('https://fuegos.comunes.org/fire/fire-xyz'); }); it('renders en template', () => { const content = buildEmail(notif, 'en', 'Bob', { rootUrl: 'https://fires.comunes.org/' }); const { html } = renderEmail('new-fire', content); expect(html).toContain('Bob'); expect(html).toContain('fires.comunes.org/fire/fire-xyz'); }); });