-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #227 from tscircuit/bnds
fix bounds calculation not updating center of pcb component
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tests/components/normal-components/chip-cad-position-in-group.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { test, expect } from "bun:test" | ||
import { getTestFixture } from "tests/fixtures/get-test-fixture" | ||
|
||
test("chip CAD component position inside offset group", () => { | ||
const { project } = getTestFixture() | ||
|
||
project.add( | ||
<board width="10mm" height="10mm"> | ||
<group pcbX={5} pcbY={3}> | ||
<chip | ||
name="U1" | ||
footprint="soic8" | ||
cadModel={{ | ||
stlUrl: "https://example.com/chip.stl", | ||
}} | ||
/> | ||
</group> | ||
</board>, | ||
) | ||
|
||
project.render() | ||
|
||
const cadComponent = project.db.cad_component.list()[0] | ||
const pcbComponent = project.db.pcb_component.list()[0] | ||
|
||
expect(cadComponent).toBeDefined() | ||
expect(pcbComponent).toBeDefined() | ||
|
||
expect(pcbComponent.center.x).toBeCloseTo(5, 1) | ||
// The CAD component position should include the group's offset | ||
expect(cadComponent.position.x).toBeCloseTo(5, 1) | ||
expect(cadComponent.position.y).toBeCloseTo(3, 1) | ||
expect(cadComponent.position.z).toBeCloseTo(0.7, 1) // Default board thickness/2 | ||
}) |