Skip to content

Commit aa5bfe4

Browse files
authored
add more test (#2065)
1 parent 26a99db commit aa5bfe4

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { expect, test } from "bun:test"
2+
import { getTestFixture } from "tests/fixtures/get-test-fixture"
3+
4+
const circuit1 = (
5+
<board width="50mm" height="50mm">
6+
<group pcbX={0} pcbY={0}>
7+
<silkscreencircle radius="0.25mm" />
8+
<silkscreentext text="Anchor Top Center" anchorAlignment="center" />
9+
</group>
10+
11+
<group pcbX={0} pcbY={0}>
12+
<silkscreencircle radius="0.25mm" />
13+
<silkscreentext text="Anchor Center" anchorAlignment="center" />
14+
</group>
15+
16+
<group pcbX={0} pcbY={0}>
17+
<silkscreencircle radius="0.25mm" />
18+
<silkscreentext text="Anchor Bottom Center" anchorAlignment="center" />
19+
</group>
20+
</board>
21+
)
22+
23+
const circuit2 = (
24+
<board width="50mm" height="50mm">
25+
<group pcbX={0} pcbY={0}>
26+
<silkscreencircle radius="0.25mm" />
27+
<silkscreentext text="Anchor Top Center" anchorAlignment="top_center" />
28+
</group>
29+
30+
<group pcbX={0} pcbY={0}>
31+
<silkscreencircle radius="0.25mm" />
32+
<silkscreentext text="Anchor Center" anchorAlignment="center" />
33+
</group>
34+
35+
<group pcbX={0} pcbY={0}>
36+
<silkscreencircle radius="0.25mm" />
37+
<silkscreentext
38+
text="Anchor Bottom Center"
39+
anchorAlignment="bottom_center"
40+
/>
41+
</group>
42+
</board>
43+
)
44+
45+
test("SilkscreenText anchorAlignment", async () => {
46+
const { circuit: firstCircuit } = getTestFixture()
47+
firstCircuit.add(circuit1)
48+
firstCircuit.render()
49+
50+
const firstCircuitJson = firstCircuit.getCircuitJson()
51+
const firstTextAlignments = firstCircuitJson
52+
.filter((elm) => elm.type === "pcb_silkscreen_text")
53+
.map((elm: any) => elm.anchor_alignment)
54+
55+
expect(firstTextAlignments).toEqual(["center", "center", "center"])
56+
expect(firstCircuit).toMatchPcbSnapshot(`${import.meta.path}-circuit1`)
57+
58+
const { circuit: secondCircuit } = getTestFixture()
59+
secondCircuit.add(circuit2)
60+
secondCircuit.render()
61+
62+
const secondCircuitJson = secondCircuit.getCircuitJson()
63+
const secondTextAlignments = secondCircuitJson
64+
.filter((elm) => elm.type === "pcb_silkscreen_text")
65+
.map((elm: any) => elm.anchor_alignment)
66+
67+
expect(secondTextAlignments).toEqual([
68+
"top_center",
69+
"center",
70+
"bottom_center",
71+
])
72+
expect(secondCircuit).toMatchPcbSnapshot(`${import.meta.path}-circuit2`)
73+
})

0 commit comments

Comments
 (0)