Skip to content

Commit 55c2484

Browse files
committed
test: show_as_schematic_box should be added to the circuit_json of schematic_group
1 parent e6b7213 commit 55c2484

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

lib/components/primitive-components/Group/Group.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,7 @@ export class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
949949
height: 0,
950950
schematic_component_ids: [],
951951
source_group_id: this.source_group_id!,
952+
show_as_schematic_box: props.showAsSchematicBox ?? false,
952953
})
953954
this.schematic_group_id = schematic_group.schematic_group_id
954955

Lines changed: 25 additions & 0 deletions
Loading
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { expect, test } from "bun:test"
2+
import { getTestFixture } from "tests/fixtures/get-test-fixture"
3+
4+
test("group schematic box", () => {
5+
const { circuit } = getTestFixture()
6+
circuit.add(
7+
<board routingDisabled>
8+
<group name="G1" showAsSchematicBox>
9+
<resistor name="R1" resistance="1k" footprint="0402" />
10+
<capacitor name="C1" capacitance="1uF" footprint="0402" />
11+
</group>
12+
</board>,
13+
)
14+
15+
circuit.render()
16+
17+
const schematic_group = circuit.db.schematic_group
18+
.list()
19+
.filter((g) => g.name === "G1")
20+
expect(schematic_group).toMatchInlineSnapshot(`
21+
[
22+
{
23+
"center": {
24+
"x": 0,
25+
"y": 0,
26+
},
27+
"height": 0,
28+
"is_subcircuit": undefined,
29+
"name": "G1",
30+
"schematic_component_ids": [],
31+
"schematic_group_id": "schematic_group_0",
32+
"show_as_schematic_box": true,
33+
"source_group_id": "source_group_0",
34+
"subcircuit_id": null,
35+
"type": "schematic_group",
36+
"width": 0,
37+
},
38+
]
39+
`)
40+
41+
expect(circuit).toMatchSchematicSnapshot(import.meta.path)
42+
})

0 commit comments

Comments
 (0)