test: dedupe plugin bundle discovery suites

This commit is contained in:
Peter Steinberger
2026-03-28 06:02:38 +00:00
parent 69b54cbb1f
commit 89bb2cf03e
18 changed files with 789 additions and 438 deletions

View File

@@ -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", () => {