-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathget-connections-with-nodes-prefers-box-distance.test.ts
More file actions
50 lines (46 loc) · 1.28 KB
/
get-connections-with-nodes-prefers-box-distance.test.ts
File metadata and controls
50 lines (46 loc) · 1.28 KB
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
import { expect, test } from "bun:test"
import { getConnectionsWithNodes } from "lib/solvers/PortPointPathingSolver/getConnectionsWithNodes"
import type { SimpleRouteJson } from "lib/types"
import type { InputNodeWithPortPoints } from "lib/solvers/PortPointPathingSolver/PortPointPathingSolver"
test("getConnectionsWithNodes prefers node box distance over center distance", () => {
const simpleRouteJson: SimpleRouteJson = {
layerCount: 2,
minTraceWidth: 0.2,
minViaDiameter: 0.4,
obstacles: [],
connections: [
{
name: "conn-1",
pointsToConnect: [
{ x: 2.1, y: 0, layer: "top" },
{ x: 0, y: 0, layer: "top" },
],
},
],
}
const inputNodes: InputNodeWithPortPoints[] = [
{
capacityMeshNodeId: "A",
center: { x: 0, y: 0 },
width: 1,
height: 1,
availableZ: [0, 1],
portPoints: [],
_containsTarget: true,
},
{
capacityMeshNodeId: "B",
center: { x: 5, y: 0 },
width: 6,
height: 2,
availableZ: [0, 1],
portPoints: [],
_containsTarget: true,
},
]
const { unshuffledConnectionsWithResults } = getConnectionsWithNodes(
simpleRouteJson,
inputNodes,
)
expect(unshuffledConnectionsWithResults[0].nodeIds[0]).toBe("B")
})