Add semantic pin 1 locations to PCB components - #684
Conversation
| test("maps every rotation-compatible pin 1 location pair", () => { | ||
| for (const cycle of rotationCycles) { | ||
| for (let fromIndex = 0; fromIndex < cycle.length; fromIndex++) { | ||
| for (let toIndex = 0; toIndex < cycle.length; toIndex++) { | ||
| const expectedRotation = | ||
| ((toIndex - fromIndex + cycle.length) % cycle.length) * 90 | ||
|
|
||
| expect( | ||
| getRotationBetweenPcbPin1Locations( | ||
| cycle[fromIndex], | ||
| cycle[toIndex], | ||
| ), | ||
| ).toBe(expectedRotation) | ||
| } | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| test("returns null when pin 1 locations differ by reflection", () => { | ||
| for (const from of rotationCycles[0]) { | ||
| for (const to of rotationCycles[1]) { | ||
| expect(getRotationBetweenPcbPin1Locations(from, to)).toBeNull() | ||
| expect(getRotationBetweenPcbPin1Locations(to, from)).toBeNull() | ||
| } | ||
| } | ||
| }) |
There was a problem hiding this comment.
A *.test.ts file may have AT MOST one test(...). This new file pcb_pin1_location.test.ts contains two test(...) calls (at lines 22 and 40). These should be split into separate numbered files, e.g. pcb_pin1_location1.test.ts and pcb_pin1_location2.test.ts.
Spotted by Graphite (based on custom rule: Custom rule)
Is this helpful? React 👍 or 👎 to let us know.
| test("pcb_component allows semantic pin 1 locations", () => { | ||
| const parsed = pcb_component.parse({ | ||
| ...baseComponent, | ||
| pin1_location: "leftside_top", | ||
| supplier_pin1_location_map: { | ||
| jlcpcb: "topside_left", | ||
| pcbway: "rightside_bottom", | ||
| }, | ||
| }) | ||
|
|
||
| expect(parsed.pin1_location).toBe("leftside_top") | ||
| expect(parsed.supplier_pin1_location_map).toEqual({ | ||
| jlcpcb: "topside_left", | ||
| pcbway: "rightside_bottom", | ||
| }) | ||
| }) | ||
|
|
||
| test("pcb_component rejects invalid semantic pin 1 locations", () => { | ||
| expect(() => | ||
| pcb_component.parse({ | ||
| ...baseComponent, | ||
| pin1_location: "top_left", | ||
| }), | ||
| ).toThrowError() | ||
|
|
||
| expect(() => | ||
| pcb_component.parse({ | ||
| ...baseComponent, | ||
| supplier_pin1_location_map: { jlcpcb: "top_left" }, | ||
| }), | ||
| ).toThrowError() | ||
| }) |
There was a problem hiding this comment.
This file now contains multiple test(...) calls. The rule states that a *.test.ts file may have AT MOST one test(...). Two new tests were added here ('pcb_component allows semantic pin 1 locations' at line 178 and 'pcb_component rejects invalid semantic pin 1 locations' at line 195), on top of the existing tests already in the file. These new tests should be split into separate, numbered files, e.g. pcb_component_position_mode1.test.ts, pcb_component_position_mode2.test.ts, etc.
Spotted by Graphite (based on custom rule: Custom rule)
Is this helpful? React 👍 or 👎 to let us know.
|
Thank you for your contribution! 🎉 PR Rating: ⭐⭐⭐ Track your contributions and see the leaderboard at: tscircuit Contribution Tracker |
Summary
PcbPin1Locationsemantic orientation typepcb_component.pin1_locationfor the rendered footprintpcb_component.supplier_pin1_location_mapkeyed by supplier so multiple assembly providers can coexistgetRotationBetweenPcbPin1Locationsfor deriving transient quarter-turn corrections while rejecting reflected topologyBoth values describe unrotated, top-view footprints. Rotation offsets remain derived export data and are not persisted.
Testing
bun testbun run buildbun run lint:zodbun run check-snake-casegit diff --check