24 lines
869 B
JavaScript
24 lines
869 B
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { slugify } from "../dist/slug.js";
|
|
|
|
test("preserves Unicode letters and numbers", () => {
|
|
assert.equal(slugify("多喝水减肥效果"), "多喝水减肥效果");
|
|
assert.equal(slugify("减肥 Plan 2026"), "减肥-plan-2026");
|
|
});
|
|
|
|
test("normalizes punctuation and Latin accents", () => {
|
|
assert.equal(slugify(" Café — healthy choices! "), "cafe-healthy-choices");
|
|
});
|
|
|
|
test("uses the fallback when no letters or numbers remain", () => {
|
|
assert.equal(slugify("🎉 !!!"), "chatgpt-share");
|
|
assert.equal(slugify("🎉", "capture"), "capture");
|
|
});
|
|
|
|
test("limits slugs to 80 Unicode code points without a trailing separator", () => {
|
|
assert.equal(slugify(`${"界".repeat(79)} hello`), "界".repeat(79));
|
|
assert.equal(Array.from(slugify("界".repeat(100))).length, 80);
|
|
});
|