Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

1.3 KB
Raw Blame
import { describe, expect, it } from "vite-plus/test";
import { toSlug } from "../../../apps/api/src/column/to-slug";

describe("toSlug", () => {
  it("slugifies Latin names", () => {
    expect(toSlug("To Do")).toBe("to-do");
    expect(toSlug("  In Progress!  ")).toBe("in-progress");
  });

  it("keeps non-Latin scripts instead of producing an empty slug", () => {
    expect(toSlug("тест")).toBe("тест");
    expect(toSlug("В работе")).toBe("в-работе");
    expect(toSlug("测试")).toBe("测试");
    expect(toSlug("قيد التنفيذ")).toBe("قيد-التنفيذ");
  });

  it("mixes scripts and numbers", () => {
    expect(toSlug("Спринт 2")).toBe("спринт-2");
  });

  it("folds full-width characters via NFKC normalization", () => {
    expect(toSlug("ABC")).toBe("abc");
  });

  it("keeps combining marks attached to their base letters", () => {
    expect(toSlug("İzmir")).toBe("i̇zmir");
    expect(toSlug("हिन्दी")).toBe("हिन्दी");
  });

  it("returns an empty slug for names with no letters or numbers", () => {
    expect(toSlug("!!!")).toBe("");
    expect(toSlug("- - -")).toBe("");
  });

  it("returns an empty slug for names made only of combining marks", () => {
    expect(toSlug("́́")).toBe("");
    expect(toSlug(" ̇ ")).toBe("");
  });
});