mirror of
https://github.com/KuekHaoYang/KVideo.git
synced 2026-08-17 09:43:43 +08:00
24 lines
829 B
TypeScript
24 lines
829 B
TypeScript
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('<p>更新 至 12集</p><br><div>下一段 & 片段</div>'),
|
|
'更新 至 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(' <p> 内容 </p>\n\n\n'), '内容');
|
|
});
|