/** * Unit tests for emailProcessor.htmlToText. * * Regression: when a template ships without a body_text, sendTemplateEmail * used `htmlBody.replace(/<[^>]*>/g, '')` to derive the plain-text fallback. * That regex strips angle-bracket tags but leaves the *contents* of Hello'; const out = htmlToText(html); expect(out).toBe('Hello'); expect(out).not.toMatch(/margin/); expect(out).not.toMatch(/color/); }); it('strips Hi'; expect(htmlToText(html)).toBe('Hi'); }); it('converts
tags to newlines', () => { expect(htmlToText('a
b
c
d')).toBe('a\nb\nc\nd'); }); it('keeps a paragraph break between adjacent

tags', () => { expect(htmlToText('

one

two

')).toBe('one\n\ntwo'); }); it('decodes the common HTML entities', () => { expect(htmlToText('Tom & Jerry <3 "hi"')) .toBe('Tom & Jerry <3 "hi"'); }); it('handles a fully-wrapped email body without leaking CSS rules', () => { // Shape mirrors what wrapEmailHtml() produces: a

Galerie erfolgreich erstellt

Liebe(r) Natalie,

`; const out = htmlToText(wrapped); expect(out).toContain('Galerie erfolgreich erstellt'); expect(out).toContain('Liebe(r) Natalie'); expect(out).not.toMatch(/margin/); expect(out).not.toMatch(/font-family/); expect(out).not.toMatch(/background-color/); expect(out).not.toMatch(/\.button/); }); });