Skip to content

Commit 68e65e8

Browse files
committed
(test) Rename fixture and update snapshots.
1 parent 2896aa7 commit 68e65e8

5 files changed

Lines changed: 426 additions & 48882 deletions

File tree

stories/fixture-001.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

stories/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { storiesOf } from '@kadira/storybook'
33
import { GraphLayouter } from '../src'
44
import fac from './fac.json'
55
import facHighlighted from './facHighlighted.json'
6-
import fixture001 from './fixture-001.json'
6+
import fixture001 from './multipleInputToOutput.json'
77

88
storiesOf('kgraph', module)
99
.add('factorial', () => (

stories/multipleInputToOutput.json

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
{
2+
"id": "root",
3+
"children": [
4+
{
5+
"id": "#cj64v13mt0002baluv27c5a65",
6+
"labels": [
7+
{
8+
"text": "#cj64v13mt0002baluv27c5a65"
9+
}
10+
],
11+
"children": [
12+
{
13+
"id": "#cj64v13n20004baludxnz4a34",
14+
"labels": [
15+
{
16+
"text": "cc"
17+
}
18+
],
19+
"children": [
20+
{
21+
"id": "#cj64v13n00003baluprcvy7ut",
22+
"labels": [
23+
{
24+
"text": "a"
25+
}
26+
],
27+
"children": [],
28+
"ports": [
29+
{
30+
"id": "#cj64v13n00003baluprcvy7ut_in_in",
31+
"meta": {
32+
"type": "number",
33+
"name": {
34+
"port": "in",
35+
"kind": "input",
36+
"type": "number",
37+
"node": "#cj64v13n00003baluprcvy7ut"
38+
}
39+
}
40+
},
41+
{
42+
"id": "#cj64v13n00003baluprcvy7ut_out_out",
43+
"meta": {
44+
"type": "number",
45+
"name": {
46+
"port": "out",
47+
"kind": "output",
48+
"type": "number",
49+
"node": "#cj64v13n00003baluprcvy7ut"
50+
}
51+
}
52+
}
53+
],
54+
"edges": [],
55+
"meta": {}
56+
}
57+
],
58+
"ports": [
59+
{
60+
"id": "#cj64v13n20004baludxnz4a34_in_in",
61+
"meta": {
62+
"type": "string",
63+
"name": {
64+
"port": "in",
65+
"kind": "input",
66+
"type": "string",
67+
"node": "#cj64v13n20004baludxnz4a34"
68+
}
69+
}
70+
},
71+
{
72+
"id": "#cj64v13n20004baludxnz4a34_outA_out",
73+
"meta": {
74+
"type": "string",
75+
"name": {
76+
"port": "outA",
77+
"kind": "output",
78+
"type": "string",
79+
"node": "#cj64v13n20004baludxnz4a34"
80+
}
81+
}
82+
},
83+
{
84+
"id": "#cj64v13n20004baludxnz4a34_outB_out",
85+
"meta": {
86+
"type": "string",
87+
"name": {
88+
"port": "outB",
89+
"kind": "output",
90+
"type": "string",
91+
"node": "#cj64v13n20004baludxnz4a34"
92+
}
93+
}
94+
},
95+
{
96+
"id": "#cj64v13n20004baludxnz4a34_outC_out",
97+
"meta": {
98+
"type": "string",
99+
"name": {
100+
"port": "outC",
101+
"kind": "output",
102+
"type": "string",
103+
"node": "#cj64v13n20004baludxnz4a34"
104+
}
105+
}
106+
}
107+
],
108+
"edges": [
109+
{
110+
"id": "#cj64v13n20004baludxnz4a34#cj64v13n00003baluprcvy7ut",
111+
"source": "#cj64v13n20004baludxnz4a34",
112+
"sourcePort": "#cj64v13n20004baludxnz4a34_in_in",
113+
"target": "#cj64v13n00003baluprcvy7ut",
114+
"targetPort": "#cj64v13n00003baluprcvy7ut_in_in",
115+
"meta": {
116+
"sourceType": "string",
117+
"targetType": "number",
118+
"sourcePort": {
119+
"type": "generic",
120+
"node": "#cj64v13n20004baludxnz4a34",
121+
"port": "in"
122+
},
123+
"targetPort": {
124+
"type": "generic",
125+
"node": "#cj64v13n00003baluprcvy7ut",
126+
"port": "in"
127+
},
128+
"layer": "dataflow"
129+
}
130+
},
131+
{
132+
"id": "#cj64v13n00003baluprcvy7ut#cj64v13n20004baludxnz4a34",
133+
"source": "#cj64v13n00003baluprcvy7ut",
134+
"sourcePort": "#cj64v13n00003baluprcvy7ut_out_out",
135+
"target": "#cj64v13n20004baludxnz4a34",
136+
"targetPort": "#cj64v13n20004baludxnz4a34_outC_out",
137+
"meta": {
138+
"sourceType": "number",
139+
"targetType": "string",
140+
"sourcePort": {
141+
"type": "generic",
142+
"node": "#cj64v13n00003baluprcvy7ut",
143+
"port": "out"
144+
},
145+
"targetPort": {
146+
"type": "generic",
147+
"node": "#cj64v13n20004baludxnz4a34",
148+
"port": "outC"
149+
},
150+
"layer": "dataflow"
151+
}
152+
}
153+
],
154+
"meta": {}
155+
}
156+
],
157+
"ports": [],
158+
"edges": [
159+
{
160+
"id": "#cj64v13n20004baludxnz4a34#cj64v13n20004baludxnz4a34",
161+
"source": "#cj64v13n20004baludxnz4a34",
162+
"sourcePort": "#cj64v13n20004baludxnz4a34_in_in",
163+
"target": "#cj64v13n20004baludxnz4a34",
164+
"targetPort": "#cj64v13n20004baludxnz4a34_outA_out",
165+
"meta": {
166+
"sourceType": "string",
167+
"targetType": "string",
168+
"sourcePort": {
169+
"type": "generic",
170+
"node": "#cj64v13n20004baludxnz4a34",
171+
"port": "in"
172+
},
173+
"targetPort": {
174+
"type": "generic",
175+
"node": "#cj64v13n20004baludxnz4a34",
176+
"port": "outA"
177+
},
178+
"layer": "dataflow"
179+
}
180+
},
181+
{
182+
"id": "#cj64v13n20004baludxnz4a34#cj64v13n20004baludxnz4a34",
183+
"source": "#cj64v13n20004baludxnz4a34",
184+
"sourcePort": "#cj64v13n20004baludxnz4a34_in_in",
185+
"target": "#cj64v13n20004baludxnz4a34",
186+
"targetPort": "#cj64v13n20004baludxnz4a34_outB_out",
187+
"meta": {
188+
"sourceType": "string",
189+
"targetType": "string",
190+
"sourcePort": {
191+
"type": "generic",
192+
"node": "#cj64v13n20004baludxnz4a34",
193+
"port": "in"
194+
},
195+
"targetPort": {
196+
"type": "generic",
197+
"node": "#cj64v13n20004baludxnz4a34",
198+
"port": "outB"
199+
},
200+
"layer": "dataflow"
201+
}
202+
}
203+
],
204+
"meta": {
205+
"version": "0.4.0-pre.41"
206+
}
207+
}
208+
],
209+
"edges": []
210+
}

test/Graph.test.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import renderer from 'react-test-renderer'
44
import { Graph, layout } from '../src'
55
import fac from '../stories/fac.json'
66
import facHighlighted from '../stories/facHighlighted.json'
7+
import multipleInputToOutput from '../stories/multipleInputToOutput.json'
78

89
function fakeCalculateSize (text, options) {
910
return {
@@ -12,20 +13,19 @@ function fakeCalculateSize (text, options) {
1213
}
1314
}
1415

15-
test('factorial graph', () => {
16-
return layout(fac, fakeCalculateSize).then((graph) => {
17-
const tree = renderer.create(
18-
<Graph graph={graph} />
19-
).toJSON()
20-
expect(tree).toMatchSnapshot()
21-
})
16+
async function renderGraphToJson (graph) {
17+
const layoutedGraph = await layout(graph, fakeCalculateSize)
18+
return renderer.create(<Graph graph={layoutedGraph} />).toJSON()
19+
}
20+
21+
test('factorial graph', async () => {
22+
expect(await renderGraphToJson(fac)).toMatchSnapshot()
23+
})
24+
25+
test('factorial with highlighted nodes', async () => {
26+
expect(await renderGraphToJson(facHighlighted)).toMatchSnapshot()
2227
})
2328

24-
test('factorial with highlighted nodes', () => {
25-
return layout(facHighlighted, fakeCalculateSize).then((graph) => {
26-
const tree = renderer.create(
27-
<Graph graph={graph} />
28-
).toJSON()
29-
expect(tree).toMatchSnapshot()
30-
})
29+
test('multiple input ports to one output port', async () => {
30+
expect(await renderGraphToJson(multipleInputToOutput)).toMatchSnapshot()
3131
})

0 commit comments

Comments
 (0)