Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/fn/solderjumper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions tests/solderjumper-bare-string.test.ts
Original file line number Diff line number Diff line change
@@ -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)
}
})
Loading