2026-06-20 10:55:56 +08:00
|
|
|
import { SECTIONS, type Section, TOOLS, toolSection } from "@snapotter/shared";
|
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
|
|
|
|
|
|
describe("toolSection", () => {
|
|
|
|
|
it("maps non-document modalities directly", () => {
|
|
|
|
|
expect(toolSection({ modality: "image", acceptedInputs: [".png"] })).toBe("image");
|
|
|
|
|
expect(toolSection({ modality: "video", acceptedInputs: [".mp4"] })).toBe("video");
|
|
|
|
|
expect(toolSection({ modality: "audio", acceptedInputs: [".mp3"] })).toBe("audio");
|
|
|
|
|
expect(toolSection({ modality: "file", acceptedInputs: [".csv"] })).toBe("files");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("splits document modality by .pdf input", () => {
|
|
|
|
|
expect(toolSection({ modality: "document", acceptedInputs: [".pdf"] })).toBe("pdf");
|
|
|
|
|
expect(toolSection({ modality: "document", acceptedInputs: [".docx", ".odt"] })).toBe("files");
|
|
|
|
|
});
|
|
|
|
|
|
2026-06-29 11:01:25 +08:00
|
|
|
it("partitions the catalog into exactly 29 PDF and 23 Files tools", () => {
|
2026-06-20 10:55:56 +08:00
|
|
|
const bySection = (s: Section) =>
|
|
|
|
|
TOOLS.filter((t) => toolSection(t) === s)
|
|
|
|
|
.map((t) => t.id)
|
|
|
|
|
.sort();
|
2026-07-21 16:48:48 +08:00
|
|
|
expect(TOOLS.filter((t) => toolSection(t) === "image")).toHaveLength(107);
|
2026-06-28 18:57:53 +08:00
|
|
|
expect(TOOLS.filter((t) => toolSection(t) === "video")).toHaveLength(57);
|
|
|
|
|
expect(TOOLS.filter((t) => toolSection(t) === "audio")).toHaveLength(27);
|
2026-06-29 11:01:25 +08:00
|
|
|
expect(bySection("pdf")).toHaveLength(29);
|
2026-06-28 18:57:53 +08:00
|
|
|
expect(bySection("files")).toHaveLength(23);
|
2026-06-29 11:01:25 +08:00
|
|
|
expect(bySection("pdf")).toContain("sign-pdf");
|
2026-06-20 10:55:56 +08:00
|
|
|
expect(bySection("pdf")).toContain("merge-pdf");
|
|
|
|
|
expect(bySection("pdf")).toContain("ocr-pdf");
|
|
|
|
|
expect(bySection("files")).toContain("word-to-pdf");
|
|
|
|
|
expect(bySection("files")).toContain("convert-spreadsheet");
|
|
|
|
|
expect(bySection("files")).toContain("csv-json");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("exposes 5 ordered sections", () => {
|
|
|
|
|
expect(SECTIONS.map((s) => s.id)).toEqual(["image", "video", "audio", "pdf", "files"]);
|
|
|
|
|
});
|
|
|
|
|
});
|