-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnearest-box2.test.ts
54 lines (52 loc) · 1.02 KB
/
nearest-box2.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { expect, test } from "bun:test"
import { findNearestPointsBetweenBoxSets } from "../src/nearest-box"
const reproData = {
goalBoxesA: [
{
type: "rect",
layers: ["top"],
center: {
x: -10,
y: -5,
},
width: 0.1,
height: 1,
connectedTo: ["pcb_port_0"],
},
{
center: {
x: -10,
y: -5.5,
layer: "top",
pcb_port_id: "pcb_port_0",
},
width: 0.01,
height: 0.01,
connectedTo: ["pcb_port_0"],
layers: ["top"],
type: "rect",
},
],
goalBoxesB: [
{
center: {
x: -8,
y: -4.5,
layer: "top",
pcb_port_id: "pcb_port_2",
},
width: 0.01,
height: 0.01,
connectedTo: ["pcb_port_2"],
layers: ["top"],
type: "rect",
},
],
}
test("nearest-box2", () => {
const { pointA, pointB, distance } = findNearestPointsBetweenBoxSets(
reproData.goalBoxesA,
reproData.goalBoxesB,
)
expect(distance).toBeCloseTo(1.94, 1)
})