import { describe, expect, it } from 'vitest';
import { htmlToPlainText } from '../html-to-text';
describe('htmlToPlainText', () => {
it('preserves line breaks from
within a paragraph', () => {
expect(htmlToPlainText('
Line 1.
Line 2.
Line 1.
Line 2.
Paragraph 2.
', { paragraphSpacing: true }) ).toBe('Line 1.\nLine 2.\n\nParagraph 2.'); }); it('without paragraphSpacing, separates paragraphs with a single newline', () => { expect(htmlToPlainText('A
B
')).toBe('A\nB'); }); it('renders links as text when the text equals the href', () => { expect( htmlToPlainText('') ).toBe('alice@example.com'); }); it('renders links as "textVisit our site
')).toBe( 'Visit our siteHello world
')).toBe('Hello world'); }); it('caps consecutive blank lines at one', () => { expect(htmlToPlainText('A
B
', { paragraphSpacing: true })).toBe( 'A\n\nB' ); }); it('returns an empty string for empty or whitespace-only HTML', () => { expect(htmlToPlainText('')).toBe(''); expect(htmlToPlainText('')).toBe(''); }); it('handles nested lists as separate lines', () => { expect(htmlToPlainText('