import test from 'node:test';
import assert from 'node:assert/strict';
import { htmlToText } from '@/lib/utils/html';
test('htmlToText removes markup, decodes entities, and preserves meaningful breaks', () => {
assert.equal(
htmlToText('
更新 至 12集
下一段 & 片段
'),
'更新 至 12集\n\n下一段 & 片段',
);
});
test('htmlToText decodes numeric entities and leaves invalid or unknown entities unchanged', () => {
assert.equal(
htmlToText('一二 🎬 &unknown; '),
'一二 🎬 &unknown; ',
);
});
test('htmlToText normalizes empty and whitespace-only input', () => {
assert.equal(htmlToText(null), '');
assert.equal(htmlToText(''), '');
assert.equal(htmlToText(' 内容
\n\n\n'), '内容');
});