imrishabh18/corne-keyboard

The code defines and renders two surface-mount chip components with SMT pads, silkscreen outlines, and 3D CAD models (OBJ and STEP) for PCB assembly.

Version
2.0.21
License
unset
Stars
1

scripts/panel-primitives.test.tsx

import { expect, test } from "bun:test"
import { Circuit } from "@tscircuit/core"

test("panel-owned holes and cutouts retain global coordinates without adding a board", async () => {
  const c = new Circuit()
  c.add(
    <panel layoutMode="grid" row={1} col={2} boardGap={6} edgePadding={7}>
      <board width={20} height={10} routingDisabled />
      <board width={20} height={10} routingDisabled />
      <hole pcbX={-24} pcbY={0} diameter={0.6} />
      <cutout shape="polygon" points={[{x:-24,y:2},{x:-23,y:2},{x:-23,y:4},{x:-24,y:4}]} />
    </panel>,
  )
  await c.renderUntilSettled()
  const j = c.getCircuitJson()
  expect(j.filter(e => e.type === "pcb_board")).toHaveLength(2)
  expect(j.find(e => e.type === "pcb_hole")).toMatchObject({x:-24,y:0,hole_diameter:0.6})
  expect(j.find(e => e.type === "pcb_cutout")).toMatchObject({shape:"polygon",points:[{x:-24,y:2},{x:-23,y:2},{x:-23,y:4},{x:-24,y:4}]})
  expect(j.find(e => e.type === "pcb_panel")).toMatchObject({width:60,height:24})
})