Skip to content

Commit 25d465c

Browse files
added snapshot
1 parent a38fcf5 commit 25d465c

File tree

8 files changed

+23
-3
lines changed

8 files changed

+23
-3
lines changed

bun.lockb

40.2 KB
Binary file not shown.

bunfig.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[test]
2+
preload = ["./tests/fixtures/preload.ts"]

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@tscircuit/log-soup": "^1.0.2",
1818
"@types/bun": "^1.2.8",
1919
"@types/debug": "^4.1.12",
20+
"bun-match-svg": "^0.0.11",
2021
"circuit-json": "^0.0.153",
2122
"debug": "^4.3.5",
2223
"tsup": "^8.2.3"
@@ -27,6 +28,7 @@
2728
},
2829
"dependencies": {
2930
"@tscircuit/math-utils": "^0.0.16",
30-
"circuit-json-to-connectivity-map": "^0.0.20"
31+
"circuit-json-to-connectivity-map": "^0.0.20",
32+
"circuit-to-svg": "^0.0.115"
3133
}
3234
}

tests/assets/via-too-close-to-trace.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@
684684
"route_type": "wire",
685685
"x": 1.9,
686686
"y": -0.6,
687-
"width": 0.4,
687+
"width": 0.15,
688688
"layer": "bottom"
689689
},
690690
{

tests/fixtures/preload.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "bun-match-svg"

tests/lib/check-each-pcb-trace-non-overlapping/vias-in-trace-margin.test.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { expect, test, describe } from "bun:test"
22
import { checkEachPcbTraceNonOverlapping } from "lib/check-each-pcb-trace-non-overlapping/check-each-pcb-trace-non-overlapping"
33
import circuitJson from "../../assets/via-too-close-to-trace.json"
4+
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
45

56
describe("PCB vias in non-overlapping trace checks", () => {
6-
test("non-overlapping functionality should include vias as collidable objects", () => {
7+
test("non-overlapping functionality should include vias as collidable objects", async () => {
78
const errors = checkEachPcbTraceNonOverlapping(circuitJson as any)
89

910
expect(errors).toMatchInlineSnapshot(`
@@ -25,5 +26,7 @@ describe("PCB vias in non-overlapping trace checks", () => {
2526
]
2627
`)
2728
expect(errors.length).toBeGreaterThan(0)
29+
const svg = convertCircuitJsonToPcbSvg(circuitJson as any)
30+
await expect(svg).toMatchSvgSnapshot(import.meta.path)
2831
})
2932
})

tests/svg.test.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { expect, test } from "bun:test"
2+
3+
const testSvg = `<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
4+
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
5+
</svg>`
6+
7+
test("svg snapshot example", async () => {
8+
// First run will create the snapshot
9+
// Subsequent runs will compare against the saved snapshot
10+
await expect(testSvg).toMatchSvgSnapshot(import.meta.path)
11+
})

0 commit comments

Comments
 (0)