-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfixtures.ts
More file actions
54 lines (48 loc) · 1.41 KB
/
fixtures.ts
File metadata and controls
54 lines (48 loc) · 1.41 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
51
52
53
54
import nullthrows from "nullthrows";
import CCStore from ".";
import { CCComponentStore } from "./component";
import { CCConnectionStore } from "./connection";
import * as intrinsics from "./intrinsics/definitions";
import { CCNodeStore } from "./node";
export function createStoreFixture(): CCStore {
const store = new CCStore();
store.mount();
const rootComponent = CCComponentStore.create({
name: "Root",
});
store.components.register(rootComponent);
const sampleNode1 = CCNodeStore.create({
parentComponentId: rootComponent.id,
componentId: intrinsics.and.component.id,
position: { x: -100, y: 0 },
});
store.nodes.register(sampleNode1);
const sampleNode2 = CCNodeStore.create({
parentComponentId: rootComponent.id,
componentId: intrinsics.not.component.id,
position: { x: 100, y: 0 },
});
store.nodes.register(sampleNode2);
const fromNodePin = nullthrows(
store.nodePins
.getManyByNodeId(sampleNode1.id)
.find(
(nodePin) => nodePin.componentPinId === intrinsics.and.outputPin.Out.id,
),
);
const toNodePin = nullthrows(
store.nodePins
.getManyByNodeId(sampleNode2.id)
.find(
(nodePin) => nodePin.componentPinId === intrinsics.not.inputPin.In.id,
),
);
const sampleConnection = CCConnectionStore.create({
parentComponentId: rootComponent.id,
from: fromNodePin.id,
to: toNodePin.id,
bentPortion: 0.5,
});
store.connections.register(sampleConnection);
return store;
}