diff --git a/src/fn/fpc.ts b/src/fn/fpc.ts index 692426f5..afa994d4 100644 --- a/src/fn/fpc.ts +++ b/src/fn/fpc.ts @@ -11,7 +11,7 @@ import { base_def } from "../helpers/zod/base_def" export const fpc_def = base_def.extend({ fn: z.literal("fpc"), - num_pins: z.coerce.number().int().min(2), + num_pins: z.coerce.number().int().min(2).default(12), p: length.default("0.5mm").describe("contact pad pitch"), pw: length.default("0.3mm").describe("contact pad width"), pl: length.default("1.25mm").describe("contact pad length"), diff --git a/tests/fpc-bare-string.test.ts b/tests/fpc-bare-string.test.ts new file mode 100644 index 00000000..78605a44 --- /dev/null +++ b/tests/fpc-bare-string.test.ts @@ -0,0 +1,18 @@ +import { test, expect } from "bun:test" +import { fp } from "../src" + +test("fpc bare string defaults to 12 pins without throwing (#786)", () => { + const circuitJson = fp.string("fpc").circuitJson() + + const smtpads = circuitJson.filter((e) => e.type === "pcb_smtpad") + // 12 contact pads + 2 mounting pads = 14 pads + expect(smtpads.length).toBe(14) +}) + +test("fpc with explicit pin count parses correctly", () => { + const circuitJson = fp.string("fpc6").circuitJson() + + const smtpads = circuitJson.filter((e) => e.type === "pcb_smtpad") + // 6 contact pads + 2 mounting pads = 8 pads + expect(smtpads.length).toBe(8) +})