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
7 changes: 3 additions & 4 deletions src/fn/diode.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { AnySoupElement } from "circuit-json"
import { passive, type PassiveDef } from "src/helpers/passive-fn"

export const diode = (parameters: {
tht: boolean
p: number
}): { circuitJson: AnySoupElement[]; parameters: PassiveDef } => {
export const diode = (
parameters: PassiveDef,
): { circuitJson: AnySoupElement[]; parameters: PassiveDef } => {
return { circuitJson: passive(parameters), parameters }
}
7 changes: 6 additions & 1 deletion src/footprinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,12 @@ export const footprinter = (): Footprinter & {
} else {
target[prop] = true
target.fn = prop
if (prop === "res" || prop === "cap") {
if (
prop === "res" ||
prop === "cap" ||
prop === "led" ||
prop === "diode"
) {
if (v) {
if (typeof v === "string" && v.includes("_metric")) {
target.metric = v.split("_metric")[0]
Expand Down
11 changes: 11 additions & 0 deletions tests/led-diode-string1.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { test, expect } from "bun:test"
import { fp } from "../src/footprinter"

// Regression test for issue #562:
// fp.string("led0402") should work the same way as fp.string("res0402").

test("led0402 via string parser", () => {
expect(() => fp.string("led0402").circuitJson()).not.toThrow()
const soup = fp.string("led0402").circuitJson()
expect(soup.length).toBeGreaterThan(0)
})
9 changes: 9 additions & 0 deletions tests/led-diode-string2.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { test, expect } from "bun:test"
import { fp } from "../src/footprinter"

// Regression test for issue #562:
// fp.string("led0603") should work the same way as fp.string("res0603").

test("led0603 via string parser", () => {
expect(() => fp.string("led0603").circuitJson()).not.toThrow()
})
9 changes: 9 additions & 0 deletions tests/led-diode-string3.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { test, expect } from "bun:test"
import { fp } from "../src/footprinter"

// Regression test for issue #562:
// fp.string("led0805") should work the same way as fp.string("res0805").

test("led0805 via string parser", () => {
expect(() => fp.string("led0805").circuitJson()).not.toThrow()
})
11 changes: 11 additions & 0 deletions tests/led-diode-string4.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { test, expect } from "bun:test"
import { fp } from "../src/footprinter"

// Regression test for issue #562:
// fp.string("diode0402") should work the same way as fp.string("res0402").

test("diode0402 via string parser", () => {
expect(() => fp.string("diode0402").circuitJson()).not.toThrow()
const soup = fp.string("diode0402").circuitJson()
expect(soup.length).toBeGreaterThan(0)
})
9 changes: 9 additions & 0 deletions tests/led-diode-string5.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { test, expect } from "bun:test"
import { fp } from "../src/footprinter"

// Regression test for issue #562:
// fp.string("diode0603") should work the same way as fp.string("cap0603").

test("diode0603 via string parser", () => {
expect(() => fp.string("diode0603").circuitJson()).not.toThrow()
})
9 changes: 9 additions & 0 deletions tests/led-diode-string6.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { test, expect } from "bun:test"
import { fp } from "../src/footprinter"

// Regression test for issue #562:
// fp.string("diode1206") should work the same way as fp.string("res1206").

test("diode1206 via string parser", () => {
expect(() => fp.string("diode1206").circuitJson()).not.toThrow()
})
12 changes: 12 additions & 0 deletions tests/led-diode-string7.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { test, expect } from "bun:test"
import { fp } from "../src/footprinter"

// Regression test for issue #562:
// led0402 should produce the same footprint structure as res0402.

test("led0402 matches res0402 dimensions", () => {
const ledSoup = fp.string("led0402").circuitJson()
const resSoup = fp.string("res0402").circuitJson()
// Both should produce the same number of elements (pads + silkscreen)
expect(ledSoup.length).toBe(resSoup.length)
})
11 changes: 11 additions & 0 deletions tests/led-diode-string8.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { test, expect } from "bun:test"
import { fp } from "../src/footprinter"

// Regression test for issue #562:
// diode0603 should produce the same footprint structure as cap0603.

test("diode0603 matches cap0603 dimensions", () => {
const diodeSoup = fp.string("diode0603").circuitJson()
const capSoup = fp.string("cap0603").circuitJson()
expect(diodeSoup.length).toBe(capSoup.length)
})
Loading