mirror of
https://github.com/hectorqin/reader.git
synced 2026-11-10 21:11:08 +08:00
Add reliable reading progress, verified backup and restore, reading tools, offline downloads, source quality checks, personal credential status, OPDS serving and verified WebDAV backup uploads.
13 lines
766 B
TypeScript
13 lines
766 B
TypeScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { chapterQuality, requireChapterContent } from '../src/publications/chapter-quality.ts';
|
|
|
|
test('quality counts visible Unicode characters, ignores markup and rejects empty chapters', () => {
|
|
assert.equal(chapterQuality(' 中文 😀 \n', 'text/plain').characters, 3);
|
|
assert.equal(chapterQuality('<p>中 文 & 😀</p><script>evil()</script>', 'text/html').characters, 4);
|
|
for (const body of [' ', '\u200b\u2060', '<p> </p>', '<script>evil()</script>']) {
|
|
assert.throws(() => requireChapterContent(body, 'text/html'), { code: 'EMPTY_CHAPTER' });
|
|
}
|
|
assert.equal(requireChapterContent('<img src="data:image/png;base64,abcd" />', 'text/html').images, 1);
|
|
});
|