mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-01 17:50:21 +00:00
test: dedupe plugin bundle discovery suites
This commit is contained in:
@@ -10,11 +10,18 @@ function expectSafeParseCases(
|
||||
expect(cases.map(([value]) => safeParse?.(value))).toEqual(cases.map(([, expected]) => expected));
|
||||
}
|
||||
|
||||
function expectJsonSchema(
|
||||
result: ReturnType<typeof buildPluginConfigSchema>,
|
||||
expected: Record<string, unknown>,
|
||||
) {
|
||||
expect(result.jsonSchema).toMatchObject(expected);
|
||||
}
|
||||
|
||||
describe("buildPluginConfigSchema", () => {
|
||||
it("builds json schema when toJSONSchema is available", () => {
|
||||
const schema = z.strictObject({ enabled: z.boolean().default(true) });
|
||||
const result = buildPluginConfigSchema(schema);
|
||||
expect(result.jsonSchema).toMatchObject({
|
||||
expectJsonSchema(result, {
|
||||
type: "object",
|
||||
additionalProperties: false,
|
||||
properties: { enabled: { type: "boolean", default: true } },
|
||||
@@ -51,7 +58,7 @@ describe("buildPluginConfigSchema", () => {
|
||||
it("falls back when toJSONSchema is missing", () => {
|
||||
const legacySchema = {} as unknown as Parameters<typeof buildPluginConfigSchema>[0];
|
||||
const result = buildPluginConfigSchema(legacySchema);
|
||||
expect(result.jsonSchema).toEqual({ type: "object", additionalProperties: true });
|
||||
expectJsonSchema(result, { type: "object", additionalProperties: true });
|
||||
});
|
||||
|
||||
it("uses zod runtime parsing by default", () => {
|
||||
|
||||
Reference in New Issue
Block a user