forked from flowhub/the-graph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasics.js
55 lines (47 loc) · 1.18 KB
/
basics.js
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
55
const { render } = require("enzyme");
const fbpGraph = require("fbp-graph");
const TheGraph = require("../index.js");
const parseFBP = fbpString =>
new Promise((resolve, reject) =>
fbpGraph.graph.loadFBP(
fbpString,
(err, graph) =>
err instanceof fbpGraph.Graph
? resolve(err)
: err ? reject(err) : resolve(graph)
)
);
const dummyComponent = {
inports: [
{
name: "in",
type: "all"
}
],
outports: [
{
name: "out",
type: "all"
}
]
};
const name = "'42' -> CONFIG foo(Foo) OUT -> IN bar(Bar)";
const library = { Foo: dummyComponent, Bar: dummyComponent };
describe("Basics", function() {
describe("loading a simple graph", function() {
let rendered;
beforeAll(async () => {
const graph = await parseFBP(name);
rendered = render(TheGraph.App({ graph, library }));
});
it("should render 2 nodes", () => {
expect(rendered.find(".node")).toHaveLength(2);
});
it("should render 1 edge", () => {
expect(rendered.find(".edge")).toHaveLength(1);
});
it("should render 1 IIP", () => {
expect(rendered.find(".iip")).toHaveLength(1);
});
});
});