返回 DeepSeek-Reasonix
types.test.ts
根目录 / workers / crash-report / src / registry / types.test.ts
1 import { describe, expect, it } from "vitest";
2 import type { PackageRow } from "./types";
3 import { toPackageDTO } from "./types";
4
5 const row: PackageRow = {
6 id: 1,
7 kind: "skill",
8 scope_handle: "publisher",
9 name: "demo",
10 slug: "publisher/demo",
11 summary: "",
12 description: "",
13 source: "https://github.com/o/r/tree/main/skills/demo",
14 install_kind: "auto",
15 homepage: "",
16 repo_url: "https://github.com/o/r",
17 tags: "tool,coding",
18 latest_version: "1.0.0",
19 install_count: 0,
20 star_count: 0,
21 verified: 0,
22 status: "active",
23 publisher_id: 1,
24 created_at: "2026-07-22T00:00:00.000Z",
25 updated_at: "2026-07-22T00:00:00.000Z",
26 };
27
28 describe("toPackageDTO", () => {
29 it("normalizes legacy auto and mismatched rows to the declared kind", () => {
30 expect(toPackageDTO(row).installKind).toBe("skill");
31 expect(toPackageDTO({ ...row, install_kind: "mcp" }).installKind).toBe("skill");
32 expect(toPackageDTO({ ...row, kind: "mcp", install_kind: "mcp" }).installKind).toBe("mcp");
33 expect(toPackageDTO({ ...row, kind: "plugin", install_kind: "plugin" }).installKind).toBe("plugin");
34 });
35 });
36
36 lines TYPESCRIPT