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.0 KB
Raw Blame
import { describe, expect, it } from "vite-plus/test";
import { TASK_SHORT_ID_PATTERN } from "../../../apps/api/src/search/task-short-id";

function parse(query: string) {
  const match = query.match(TASK_SHORT_ID_PATTERN);
  return match ? { slug: match[1], number: match[2] } : null;
}

describe("TASK_SHORT_ID_PATTERN", () => {
  it("matches an ASCII project key", () => {
    expect(parse("DEP-23")).toEqual({ slug: "DEP", number: "23" });
    expect(parse("S2-7")).toEqual({ slug: "S2", number: "7" });
    expect(parse("123-1")).toEqual({ slug: "123", number: "1" });
  });

  it("matches keys generated from non-Latin project names", () => {
    expect(parse("ПА-23")).toEqual({ slug: "ПА", number: "23" });
    expect(parse("测试项-1")).toEqual({ slug: "测试项", number: "1" });
    expect(parse("ΑΒΓ-9")).toEqual({ slug: "ΑΒΓ", number: "9" });
  });

  it("still requires a nonempty project key and a trailing number", () => {
    expect(parse("DEP-")).toBeNull();
    expect(parse("DEP")).toBeNull();
    expect(parse("-23")).toBeNull();
  });
});