diff --git a/src/fn/solderjumper.ts b/src/fn/solderjumper.ts index af1b7d20..0123e0eb 100644 --- a/src/fn/solderjumper.ts +++ b/src/fn/solderjumper.ts @@ -20,13 +20,13 @@ import { length } from "circuit-json" * solderjumper({ num_pins: 3, pw: 2.0, ph: 1.0 }) // custom pad size */ export const solderjumper = (params: { - num_pins: 2 | 3 + num_pins?: 2 | 3 bridged?: string p?: number pw?: number ph?: number }) => { - const { num_pins, bridged, p = 2.54, pw = 1.5, ph = 1.5 } = params + const { num_pins = 2, bridged, p = 2.54, pw = 1.5, ph = 1.5 } = params const padSpacing = length.parse(p) const padWidth = length.parse(pw) const padHeight = length.parse(ph) diff --git a/tests/solderjumper-bare-string.test.ts b/tests/solderjumper-bare-string.test.ts new file mode 100644 index 00000000..591a2e30 --- /dev/null +++ b/tests/solderjumper-bare-string.test.ts @@ -0,0 +1,22 @@ +import { test, expect } from "bun:test" +import { fp } from "../src" + +test("solderjumper bare string defaults to 2 pins and emits finite geometry (#784)", () => { + const circuitJson = fp.string("solderjumper").circuitJson() + + const smtpads = circuitJson.filter((e) => e.type === "pcb_smtpad") + expect(smtpads.length).toBe(2) + + const courtyard = circuitJson.find((e) => e.type === "pcb_courtyard_rect") as any + expect(courtyard).toBeDefined() + expect(Number.isFinite(courtyard.width)).toBe(true) + expect(Number.isFinite(courtyard.height)).toBe(true) + expect(Number.isFinite(courtyard.center.x)).toBe(true) + expect(Number.isFinite(courtyard.center.y)).toBe(true) + + const text = circuitJson.find((e) => e.type === "pcb_silkscreen_text") as any + if (text) { + expect(Number.isFinite(text.anchor_position.x)).toBe(true) + expect(Number.isFinite(text.anchor_position.y)).toBe(true) + } +})