mirror of
https://github.com/openclaw/clawhub.git
synced 2026-08-14 00:47:57 +00:00
- Enhanced AGENTS.md with clearer project structure and development commands. - Updated CHANGELOG.md to reflect recent fixes and additions. - Improved formatting in CONTRIBUTING.md for better readability. - Adjusted package.json and configuration files for consistent command structure. - Refined README.md and VISION.md for clarity and organization. - Standardized code formatting in various TypeScript files for consistency. These changes aim to enhance documentation clarity and maintainability across the repository.
71 lines
1.9 KiB
TypeScript
71 lines
1.9 KiB
TypeScript
/* @vitest-environment node */
|
|
import { describe, expect, it } from "vitest";
|
|
import { __test } from "./httpApi";
|
|
|
|
describe("httpApi", () => {
|
|
it("parses publish payload", () => {
|
|
const parsed = __test.parsePublishBody({
|
|
slug: "cool-skill",
|
|
displayName: "Cool Skill",
|
|
version: "1.2.3",
|
|
changelog: "stuff",
|
|
tags: ["latest", "beta"],
|
|
files: [
|
|
{
|
|
path: "SKILL.md",
|
|
size: 5,
|
|
storageId: "fakeStorageId",
|
|
sha256: "abcd",
|
|
contentType: "text/markdown",
|
|
},
|
|
],
|
|
});
|
|
expect(parsed.slug).toBe("cool-skill");
|
|
expect(parsed.tags).toEqual(["latest", "beta"]);
|
|
expect(parsed.files[0]?.path).toBe("SKILL.md");
|
|
});
|
|
|
|
it("normalizes optional fields in publish payload", () => {
|
|
const parsed = __test.parsePublishBody({
|
|
slug: "cool-skill",
|
|
displayName: "Cool Skill",
|
|
version: "1.2.3",
|
|
changelog: "",
|
|
tags: [],
|
|
forkOf: { slug: "base-skill" },
|
|
files: [
|
|
{
|
|
path: "SKILL.md",
|
|
size: 5,
|
|
storageId: "fakeStorageId",
|
|
sha256: "abcd",
|
|
contentType: "text/markdown",
|
|
},
|
|
],
|
|
});
|
|
expect(parsed.tags).toBeUndefined();
|
|
expect(parsed.source).toBeUndefined();
|
|
expect(parsed.forkOf).toEqual({ slug: "base-skill", version: undefined });
|
|
});
|
|
|
|
it("rejects invalid publish payloads", () => {
|
|
expect(() => __test.parsePublishBody(null)).toThrow(/Publish payload/i);
|
|
expect(() =>
|
|
__test.parsePublishBody({
|
|
slug: "x",
|
|
displayName: "X",
|
|
version: "1.0.0",
|
|
changelog: "c",
|
|
files: [],
|
|
}),
|
|
).toThrow(/files required/i);
|
|
});
|
|
|
|
it("parses optional numbers", () => {
|
|
expect(__test.toOptionalNumber(null)).toBeUndefined();
|
|
expect(__test.toOptionalNumber("")).toBeUndefined();
|
|
expect(__test.toOptionalNumber("10")).toBe(10);
|
|
expect(__test.toOptionalNumber("nope")).toBeUndefined();
|
|
});
|
|
});
|