feat: add PDIP and SPDIP as separate footprint functions#561
feat: add PDIP and SPDIP as separate footprint functions#561iprevail-io wants to merge 3 commits intotscircuit:mainfrom
Conversation
PDIP (Plastic DIP) and SPDIP (Shrink Plastic DIP) are standard DIP package variants. This adds string normalization so footprint strings like "pdip8" and "spdip28" resolve correctly to the existing DIP implementation. Closes tscircuit#371 Closes tscircuit#180
| import { test, expect } from "bun:test" | ||
| import { convertCircuitJsonToPcbSvg } from "circuit-to-svg" | ||
| import { fp } from "../src/footprinter" | ||
| import type { AnyCircuitElement } from "circuit-json" | ||
|
|
||
| test("pdip8 resolves to dip8", () => { | ||
| const pdipJson = fp.string("pdip8").json() | ||
| const dipJson = fp.string("dip8").json() | ||
| expect(pdipJson).toEqual(dipJson) | ||
| }) | ||
|
|
||
| test("PDIP8 case-insensitive", () => { | ||
| const uppercaseJson = fp.string("PDIP8").json() | ||
| const lowercaseJson = fp.string("pdip8").json() | ||
| expect(uppercaseJson).toEqual(lowercaseJson) | ||
| }) | ||
|
|
||
| test("pdip8 generates 8 plated holes", () => { | ||
| const circuitJson = fp.string("pdip8").circuitJson() as AnyCircuitElement[] | ||
| const platedHoles = circuitJson.filter( | ||
| (el) => el.type === "pcb_plated_hole", | ||
| ) | ||
| expect(platedHoles.length).toBe(8) | ||
| }) | ||
|
|
||
| test("pdip8 svg snapshot", () => { | ||
| const circuitJson = fp.string("pdip8").circuitJson() as AnyCircuitElement[] | ||
| const svgContent = convertCircuitJsonToPcbSvg(circuitJson) | ||
| expect(svgContent).toMatchSvgSnapshot(import.meta.path, "pdip8") | ||
| }) | ||
|
|
||
| test("spdip28 resolves to dip28", () => { | ||
| const spdipJson = fp.string("spdip28").json() | ||
| const dipJson = fp.string("dip28").json() | ||
| expect(spdipJson).toEqual(dipJson) | ||
| }) | ||
|
|
||
| test("spdip28 generates 28 plated holes", () => { | ||
| const circuitJson = fp.string("spdip28").circuitJson() as AnyCircuitElement[] | ||
| const platedHoles = circuitJson.filter( | ||
| (el) => el.type === "pcb_plated_hole", | ||
| ) | ||
| expect(platedHoles.length).toBe(28) | ||
| }) |
There was a problem hiding this comment.
This test file contains 6 test() functions (lines 6, 12, 18, 26, 32, and 38), which violates the rule that a *.test.ts file may have AT MOST one test(...). After the first test, the user should split into multiple numbered files. To fix this, split the tests into separate files like pdip1.test.ts, pdip2.test.ts, pdip3.test.ts, pdip4.test.ts, pdip5.test.ts, and pdip6.test.ts, with each file containing only one test() function.
Spotted by Graphite (based on custom rule: Custom rule)
Is this helpful? React 👍 or 👎 to let us know.
seveibar
left a comment
There was a problem hiding this comment.
Pdio and spdip arent aliases afaik
|
Ie they are separate fns |
PDIP (Plastic DIP) and SPDIP (Shrink Plastic DIP) are standard DIP package variants. Implemented as separate functions in src/fn/ that delegate to the existing DIP implementation with appropriate defaults: - PDIP: 2.54mm pitch, 300mil row width (standard DIP dimensions) - SPDIP: 1.778mm pitch, 300mil row width (shrink pitch variant) Closes tscircuit#371 Closes tscircuit#180
|
Updated — PDIP and SPDIP are now implemented as separate footprint functions (src/fn/pdip.ts and src/fn/spdip.ts) instead of regex aliases. Each has its own definition using extendDipDef(), matching the existing pattern (e.g. sop8, ms012). Added type definitions in footprinter.ts and tests for both variants. |
/claim #371
Summary
normalizeDefinition()sopdip8→dip8andspdip28→dip28Changes
src/footprinter.ts: Two regex rules innormalizeDefinition()tests/pdip.test.ts: 6 new tests (alias resolution, case insensitivity, pad count verification, SVG snapshot)Test plan
pdip8resolves to same params asdip8PDIP8=pdip8)pdip8generates exactly 8 plated holesspdip28resolves to same params asdip28spdip28generates exactly 28 plated holes