package.json, tsconfig, eslint, генерация типов из OpenAPI-спеки, модули config/redact/errors/money/sanitize/cache с тестами и обезличенные фикстуры живых ответов API openrusrouter.ru. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
929 B
TypeScript
21 lines
929 B
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { cleanText } from "../src/sanitize.js";
|
|
|
|
test("убирает управляющие, bidi и zero-width символы", () => {
|
|
assert.equal(cleanText("a\u0000b\u0007c\u009Fd\u007Fe"), "abcde");
|
|
assert.equal(cleanText("safe\u202Etxt.exe\u202C"), "safetxt.exe");
|
|
assert.equal(cleanText("x\u2066y\u2069z\u200Bw\uFEFF"), "xyzw");
|
|
});
|
|
|
|
test("схлопывает пробелы и переводы строк", () => {
|
|
assert.equal(cleanText(" a \t b\r\n\r\n\n c "), "a b\nc");
|
|
});
|
|
|
|
test("обрезает по max с многоточием, не рвёт суррогатные пары", () => {
|
|
assert.equal(cleanText("abcdef", 4), "abc…");
|
|
assert.equal(cleanText("abcd", 4), "abcd");
|
|
assert.equal(cleanText("😀😀😀😀😀", 3), "😀😀…");
|
|
assert.equal(Array.from(cleanText("x".repeat(1000))).length, 500);
|
|
});
|