import { describe, expect, it } from 'vitest'; import { extractText, plainExcerpt } from './extractText'; describe('extractText', () => { it('returns empty string for null/undefined/empty', () => { expect(extractText(null)).toBe(''); expect(extractText(undefined)).toBe(''); expect(extractText('')).toBe(''); }); it('strips tags and preserves visible text', () => { expect(extractText('
Hello world
')).toBe('Hello world'); }); it('collapses whitespace within and between blocks', () => { expect(extractText('One
Two
')).toBe('OneTwo'); expect(extractText('foo bar
')).toBe('foo bar'); }); // XSS-shaped inputs: extractText must NOT execute, render, or expose the // payload as HTML. It is only required to return *some* string. The fact // that it exists is documented as a non-sanitiser; these tests prevent // silent regressions where the function might somehow leak a tag. describe('XSS-shaped input — never re-emits markup, even though this is not a sanitiser', () => { it('drops '); expect(out).not.toContain(''); }); it('drops