|
| 1 | +import { expect, test } from "bun:test" |
| 2 | +import { convertCircuitJsonToTscircuit } from "lib" |
| 3 | + |
| 4 | +test("test7 support courtyards", async () => { |
| 5 | + const tscircuit = convertCircuitJsonToTscircuit(circuitJson as any, { |
| 6 | + componentName: "Test7Component", |
| 7 | + }) |
| 8 | + |
| 9 | + expect(tscircuit).toMatchInlineSnapshot(` |
| 10 | + "import { type ChipProps } from "tscircuit" |
| 11 | + export const Test7Component = (props: ChipProps) => ( |
| 12 | + <chip |
| 13 | + footprint={<footprint> |
| 14 | + <smtpad portHints={["1"]} pcbX="-1mm" pcbY="0mm" width="0.6mm" height="0.8mm" shape="rect" /> |
| 15 | + <smtpad portHints={["2"]} pcbX="1mm" pcbY="0mm" width="0.6mm" height="0.8mm" shape="rect" /> |
| 16 | + <courtyardrect pcbX="0mm" pcbY="0mm" width="3mm" height="2mm" layer="top" /> |
| 17 | + <courtyardrect pcbX="0mm" pcbY="0mm" width="3.5mm" height="2.5mm" layer="bottom" /> |
| 18 | + </footprint>} |
| 19 | + {...props} |
| 20 | + /> |
| 21 | + )" |
| 22 | + `) |
| 23 | +}) |
| 24 | + |
| 25 | +const circuitJson = [ |
| 26 | + { |
| 27 | + type: "source_component", |
| 28 | + source_component_id: "generic_0", |
| 29 | + supplier_part_numbers: {}, |
| 30 | + }, |
| 31 | + { |
| 32 | + type: "schematic_component", |
| 33 | + schematic_component_id: "schematic_generic_component_0", |
| 34 | + source_component_id: "generic_0", |
| 35 | + center: { x: 0, y: 0 }, |
| 36 | + rotation: 0, |
| 37 | + size: { width: 0, height: 0 }, |
| 38 | + }, |
| 39 | + { |
| 40 | + type: "pcb_component", |
| 41 | + source_component_id: "generic_0", |
| 42 | + pcb_component_id: "pcb_generic_component_0", |
| 43 | + layer: "top", |
| 44 | + center: { x: 0, y: 0 }, |
| 45 | + rotation: 0, |
| 46 | + width: 1, |
| 47 | + height: 1, |
| 48 | + }, |
| 49 | + { |
| 50 | + type: "pcb_smtpad", |
| 51 | + pcb_smtpad_id: "pad1", |
| 52 | + shape: "rect", |
| 53 | + x: -1, |
| 54 | + y: 0, |
| 55 | + width: 0.6, |
| 56 | + height: 0.8, |
| 57 | + layer: "top", |
| 58 | + pcb_component_id: "pcb_generic_component_0", |
| 59 | + pcb_port_id: "port1", |
| 60 | + port_hints: ["1"], |
| 61 | + }, |
| 62 | + { |
| 63 | + type: "pcb_smtpad", |
| 64 | + pcb_smtpad_id: "pad2", |
| 65 | + shape: "rect", |
| 66 | + x: 1, |
| 67 | + y: 0, |
| 68 | + width: 0.6, |
| 69 | + height: 0.8, |
| 70 | + layer: "top", |
| 71 | + pcb_component_id: "pcb_generic_component_0", |
| 72 | + pcb_port_id: "port2", |
| 73 | + port_hints: ["2"], |
| 74 | + }, |
| 75 | + { |
| 76 | + type: "pcb_courtyard_rect", |
| 77 | + pcb_courtyard_rect_id: "courtyard1", |
| 78 | + center: { x: 0, y: 0 }, |
| 79 | + width: 3, |
| 80 | + height: 2, |
| 81 | + layer: "top", |
| 82 | + stroke_width: 0.1, |
| 83 | + pcb_component_id: "pcb_generic_component_0", |
| 84 | + }, |
| 85 | + { |
| 86 | + type: "pcb_courtyard_rect", |
| 87 | + pcb_courtyard_rect_id: "courtyard2", |
| 88 | + center: { x: 0, y: 0 }, |
| 89 | + width: 3.5, |
| 90 | + height: 2.5, |
| 91 | + layer: "bottom", |
| 92 | + stroke_width: 0.1, |
| 93 | + pcb_component_id: "pcb_generic_component_0", |
| 94 | + }, |
| 95 | +] |
0 commit comments