@pie-lib/graphing-solution-set 2.16.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +1 -0
- package/CHANGELOG.md +16 -0
- package/LICENSE.md +5 -0
- package/NEXT.CHANGELOG.json +1 -0
- package/lib/__tests__/graph-with-controls.test.js +191 -0
- package/lib/__tests__/graph.test.js +290 -0
- package/lib/__tests__/grid.test.js +40 -0
- package/lib/__tests__/labels.test.js +59 -0
- package/lib/__tests__/mark-label.test.js +154 -0
- package/lib/__tests__/toggle-bar.test.js +54 -0
- package/lib/__tests__/tool-menu.test.js +43 -0
- package/lib/__tests__/undo-redo.test.js +42 -0
- package/lib/__tests__/use-debounce.test.js +28 -0
- package/lib/__tests__/utils.js +72 -0
- package/lib/__tests__/utils.test.js +133 -0
- package/lib/axis/__tests__/arrow.test.js +68 -0
- package/lib/axis/__tests__/axes.test.js +214 -0
- package/lib/axis/arrow.js +115 -0
- package/lib/axis/axes.js +415 -0
- package/lib/axis/index.js +26 -0
- package/lib/bg.js +139 -0
- package/lib/container/actions.js +24 -0
- package/lib/container/index.js +166 -0
- package/lib/container/marks.js +27 -0
- package/lib/container/middleware.js +25 -0
- package/lib/container/reducer.js +25 -0
- package/lib/coordinates-label.js +109 -0
- package/lib/graph-with-controls.js +372 -0
- package/lib/graph.js +419 -0
- package/lib/grid-setup.js +462 -0
- package/lib/grid.js +176 -0
- package/lib/index.js +51 -0
- package/lib/labels.js +299 -0
- package/lib/mark-label.js +208 -0
- package/lib/toggle-bar.js +336 -0
- package/lib/tool-menu.js +325 -0
- package/lib/tools/index.js +29 -0
- package/lib/tools/line/__tests__/component.test.js +56 -0
- package/lib/tools/line/component.js +106 -0
- package/lib/tools/line/index.js +16 -0
- package/lib/tools/polygon/__tests__/component.test.js +245 -0
- package/lib/tools/polygon/__tests__/index.test.js +95 -0
- package/lib/tools/polygon/__tests__/line.test.js +43 -0
- package/lib/tools/polygon/__tests__/polygon.test.js +73 -0
- package/lib/tools/polygon/component.js +457 -0
- package/lib/tools/polygon/index.js +106 -0
- package/lib/tools/polygon/line.js +151 -0
- package/lib/tools/polygon/polygon.js +171 -0
- package/lib/tools/shared/__tests__/arrow-head.test.js +62 -0
- package/lib/tools/shared/arrow-head.js +75 -0
- package/lib/tools/shared/line/__tests__/index.test.js +291 -0
- package/lib/tools/shared/line/__tests__/line-path.test.js +78 -0
- package/lib/tools/shared/line/__tests__/with-root-edge.test.js +122 -0
- package/lib/tools/shared/line/index.js +637 -0
- package/lib/tools/shared/line/line-path.js +145 -0
- package/lib/tools/shared/line/with-root-edge.js +155 -0
- package/lib/tools/shared/point/__tests__/arrow-point.test.js +137 -0
- package/lib/tools/shared/point/__tests__/base-point.test.js +134 -0
- package/lib/tools/shared/point/arrow-point.js +113 -0
- package/lib/tools/shared/point/arrow.js +96 -0
- package/lib/tools/shared/point/base-point.js +151 -0
- package/lib/tools/shared/point/index.js +94 -0
- package/lib/tools/shared/styles.js +49 -0
- package/lib/tools/shared/types.js +19 -0
- package/lib/undo-redo.js +107 -0
- package/lib/use-debounce.js +32 -0
- package/lib/utils.js +314 -0
- package/package.json +50 -0
- package/src/__tests__/__snapshots__/graph-with-controls.test.jsx.snap +114 -0
- package/src/__tests__/__snapshots__/graph.test.jsx.snap +213 -0
- package/src/__tests__/__snapshots__/grid.test.jsx.snap +54 -0
- package/src/__tests__/__snapshots__/labels.test.jsx.snap +30 -0
- package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +37 -0
- package/src/__tests__/__snapshots__/toggle-bar.test.jsx.snap +7 -0
- package/src/__tests__/__snapshots__/tool-menu.test.jsx.snap +35 -0
- package/src/__tests__/__snapshots__/undo-redo.test.jsx.snap +15 -0
- package/src/__tests__/graph-with-controls.test.jsx +131 -0
- package/src/__tests__/graph.test.jsx +230 -0
- package/src/__tests__/grid.test.jsx +20 -0
- package/src/__tests__/labels.test.jsx +38 -0
- package/src/__tests__/mark-label.test.jsx +68 -0
- package/src/__tests__/toggle-bar.test.jsx +36 -0
- package/src/__tests__/tool-menu.test.jsx +29 -0
- package/src/__tests__/undo-redo.test.jsx +25 -0
- package/src/__tests__/use-debounce.test.js +21 -0
- package/src/__tests__/utils.js +38 -0
- package/src/__tests__/utils.test.js +151 -0
- package/src/axis/__tests__/__snapshots__/arrow.test.jsx.snap +33 -0
- package/src/axis/__tests__/__snapshots__/axes.test.jsx.snap +122 -0
- package/src/axis/__tests__/arrow.test.jsx +39 -0
- package/src/axis/__tests__/axes.test.jsx +220 -0
- package/src/axis/arrow.jsx +62 -0
- package/src/axis/axes.jsx +307 -0
- package/src/axis/index.js +2 -0
- package/src/bg.jsx +96 -0
- package/src/container/actions.js +8 -0
- package/src/container/index.jsx +86 -0
- package/src/container/marks.js +14 -0
- package/src/container/middleware.js +7 -0
- package/src/container/reducer.js +5 -0
- package/src/coordinates-label.jsx +73 -0
- package/src/graph-with-controls.jsx +263 -0
- package/src/graph.jsx +334 -0
- package/src/grid-setup.jsx +427 -0
- package/src/grid.jsx +135 -0
- package/src/index.js +7 -0
- package/src/labels.jsx +214 -0
- package/src/mark-label.jsx +136 -0
- package/src/toggle-bar.jsx +242 -0
- package/src/tool-menu.jsx +294 -0
- package/src/tools/index.js +8 -0
- package/src/tools/line/__tests__/__snapshots__/component.test.jsx.snap +20 -0
- package/src/tools/line/__tests__/component.test.jsx +36 -0
- package/src/tools/line/component.jsx +77 -0
- package/src/tools/line/index.js +4 -0
- package/src/tools/polygon/__tests__/__snapshots__/component.test.jsx.snap +94 -0
- package/src/tools/polygon/__tests__/__snapshots__/line.test.jsx.snap +44 -0
- package/src/tools/polygon/__tests__/__snapshots__/polygon.test.jsx.snap +53 -0
- package/src/tools/polygon/__tests__/component.test.jsx +214 -0
- package/src/tools/polygon/__tests__/index.test.js +65 -0
- package/src/tools/polygon/__tests__/line.test.jsx +25 -0
- package/src/tools/polygon/__tests__/polygon.test.jsx +44 -0
- package/src/tools/polygon/component.jsx +336 -0
- package/src/tools/polygon/index.js +52 -0
- package/src/tools/polygon/line.jsx +78 -0
- package/src/tools/polygon/polygon.jsx +101 -0
- package/src/tools/shared/__tests__/__snapshots__/arrow-head.test.jsx.snap +32 -0
- package/src/tools/shared/__tests__/arrow-head.test.jsx +34 -0
- package/src/tools/shared/arrow-head.jsx +46 -0
- package/src/tools/shared/line/__tests__/__snapshots__/index.test.jsx.snap +360 -0
- package/src/tools/shared/line/__tests__/__snapshots__/line-path.test.jsx.snap +57 -0
- package/src/tools/shared/line/__tests__/__snapshots__/with-root-edge.test.jsx.snap +63 -0
- package/src/tools/shared/line/__tests__/index.test.jsx +247 -0
- package/src/tools/shared/line/__tests__/line-path.test.jsx +53 -0
- package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +73 -0
- package/src/tools/shared/line/index.jsx +473 -0
- package/src/tools/shared/line/line-path.jsx +88 -0
- package/src/tools/shared/line/with-root-edge.jsx +97 -0
- package/src/tools/shared/point/__tests__/__snapshots__/arrow-point.test.jsx.snap +55 -0
- package/src/tools/shared/point/__tests__/__snapshots__/base-point.test.jsx.snap +43 -0
- package/src/tools/shared/point/__tests__/arrow-point.test.jsx +87 -0
- package/src/tools/shared/point/__tests__/base-point.test.jsx +84 -0
- package/src/tools/shared/point/arrow-point.jsx +60 -0
- package/src/tools/shared/point/arrow.jsx +40 -0
- package/src/tools/shared/point/base-point.jsx +86 -0
- package/src/tools/shared/point/index.jsx +60 -0
- package/src/tools/shared/styles.js +20 -0
- package/src/tools/shared/types.js +8 -0
- package/src/undo-redo.jsx +47 -0
- package/src/use-debounce.js +13 -0
- package/src/utils.js +234 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Graph snapshot renders 1`] = `
|
|
4
|
+
<WithStyles(Root)
|
|
5
|
+
disabledLabels={false}
|
|
6
|
+
disabledTitle={false}
|
|
7
|
+
graphProps={
|
|
8
|
+
Object {
|
|
9
|
+
"domain": Object {
|
|
10
|
+
"max": 1,
|
|
11
|
+
"min": 0,
|
|
12
|
+
"step": 1,
|
|
13
|
+
},
|
|
14
|
+
"getRootNode": [Function],
|
|
15
|
+
"range": Object {
|
|
16
|
+
"max": 1,
|
|
17
|
+
"min": 0,
|
|
18
|
+
"step": 1,
|
|
19
|
+
},
|
|
20
|
+
"scale": Object {
|
|
21
|
+
"x": [Function],
|
|
22
|
+
"y": [Function],
|
|
23
|
+
},
|
|
24
|
+
"size": Object {
|
|
25
|
+
"height": 400,
|
|
26
|
+
"width": 400,
|
|
27
|
+
},
|
|
28
|
+
"snap": Object {
|
|
29
|
+
"x": [Function],
|
|
30
|
+
"y": [Function],
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
labelsPlaceholders={Object {}}
|
|
35
|
+
mathMlOptions={Object {}}
|
|
36
|
+
rootRef={[Function]}
|
|
37
|
+
>
|
|
38
|
+
<g>
|
|
39
|
+
<WithStyles(Grid)
|
|
40
|
+
graphProps={
|
|
41
|
+
Object {
|
|
42
|
+
"domain": Object {
|
|
43
|
+
"max": 1,
|
|
44
|
+
"min": 0,
|
|
45
|
+
"step": 1,
|
|
46
|
+
},
|
|
47
|
+
"getRootNode": [Function],
|
|
48
|
+
"range": Object {
|
|
49
|
+
"max": 1,
|
|
50
|
+
"min": 0,
|
|
51
|
+
"step": 1,
|
|
52
|
+
},
|
|
53
|
+
"scale": Object {
|
|
54
|
+
"x": [Function],
|
|
55
|
+
"y": [Function],
|
|
56
|
+
},
|
|
57
|
+
"size": Object {
|
|
58
|
+
"height": 400,
|
|
59
|
+
"width": 400,
|
|
60
|
+
},
|
|
61
|
+
"snap": Object {
|
|
62
|
+
"x": [Function],
|
|
63
|
+
"y": [Function],
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/>
|
|
68
|
+
<Axes
|
|
69
|
+
graphProps={
|
|
70
|
+
Object {
|
|
71
|
+
"domain": Object {
|
|
72
|
+
"max": 1,
|
|
73
|
+
"min": 0,
|
|
74
|
+
"step": 1,
|
|
75
|
+
},
|
|
76
|
+
"getRootNode": [Function],
|
|
77
|
+
"range": Object {
|
|
78
|
+
"max": 1,
|
|
79
|
+
"min": 0,
|
|
80
|
+
"step": 1,
|
|
81
|
+
},
|
|
82
|
+
"scale": Object {
|
|
83
|
+
"x": [Function],
|
|
84
|
+
"y": [Function],
|
|
85
|
+
},
|
|
86
|
+
"size": Object {
|
|
87
|
+
"height": 400,
|
|
88
|
+
"width": 400,
|
|
89
|
+
},
|
|
90
|
+
"snap": Object {
|
|
91
|
+
"x": [Function],
|
|
92
|
+
"y": [Function],
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
includeArrows={
|
|
97
|
+
Object {
|
|
98
|
+
"down": true,
|
|
99
|
+
"left": true,
|
|
100
|
+
"right": true,
|
|
101
|
+
"up": true,
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/>
|
|
105
|
+
<Bg
|
|
106
|
+
graphProps={
|
|
107
|
+
Object {
|
|
108
|
+
"domain": Object {
|
|
109
|
+
"max": 1,
|
|
110
|
+
"min": 0,
|
|
111
|
+
"step": 1,
|
|
112
|
+
},
|
|
113
|
+
"getRootNode": [Function],
|
|
114
|
+
"range": Object {
|
|
115
|
+
"max": 1,
|
|
116
|
+
"min": 0,
|
|
117
|
+
"step": 1,
|
|
118
|
+
},
|
|
119
|
+
"scale": Object {
|
|
120
|
+
"x": [Function],
|
|
121
|
+
"y": [Function],
|
|
122
|
+
},
|
|
123
|
+
"size": Object {
|
|
124
|
+
"height": 400,
|
|
125
|
+
"width": 400,
|
|
126
|
+
},
|
|
127
|
+
"snap": Object {
|
|
128
|
+
"x": [Function],
|
|
129
|
+
"y": [Function],
|
|
130
|
+
},
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
height={400}
|
|
134
|
+
onClick={[Function]}
|
|
135
|
+
width={400}
|
|
136
|
+
/>
|
|
137
|
+
<mask
|
|
138
|
+
id="graph-1618"
|
|
139
|
+
>
|
|
140
|
+
<rect
|
|
141
|
+
fill="white"
|
|
142
|
+
height={446}
|
|
143
|
+
width={446}
|
|
144
|
+
x={-23}
|
|
145
|
+
y={-23}
|
|
146
|
+
/>
|
|
147
|
+
|
|
148
|
+
</mask>
|
|
149
|
+
<g
|
|
150
|
+
id="marks"
|
|
151
|
+
mask="url('#graph-1618')"
|
|
152
|
+
>
|
|
153
|
+
<LineToolComponent
|
|
154
|
+
graphProps={
|
|
155
|
+
Object {
|
|
156
|
+
"domain": Object {
|
|
157
|
+
"max": 1,
|
|
158
|
+
"min": 0,
|
|
159
|
+
"step": 1,
|
|
160
|
+
},
|
|
161
|
+
"getRootNode": [Function],
|
|
162
|
+
"range": Object {
|
|
163
|
+
"max": 1,
|
|
164
|
+
"min": 0,
|
|
165
|
+
"step": 1,
|
|
166
|
+
},
|
|
167
|
+
"scale": Object {
|
|
168
|
+
"x": [Function],
|
|
169
|
+
"y": [Function],
|
|
170
|
+
},
|
|
171
|
+
"size": Object {
|
|
172
|
+
"height": 400,
|
|
173
|
+
"width": 400,
|
|
174
|
+
},
|
|
175
|
+
"snap": Object {
|
|
176
|
+
"x": [Function],
|
|
177
|
+
"y": [Function],
|
|
178
|
+
},
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
isToolActive={true}
|
|
182
|
+
key="line-0"
|
|
183
|
+
mark={
|
|
184
|
+
Object {
|
|
185
|
+
"building": true,
|
|
186
|
+
"from": Object {
|
|
187
|
+
"x": 0,
|
|
188
|
+
"y": 0,
|
|
189
|
+
},
|
|
190
|
+
"label": "Line",
|
|
191
|
+
"type": "line",
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
onChange={[Function]}
|
|
195
|
+
onClick={[Function]}
|
|
196
|
+
onComplete={[Function]}
|
|
197
|
+
/>
|
|
198
|
+
<foreignObject
|
|
199
|
+
height={400}
|
|
200
|
+
style={
|
|
201
|
+
Object {
|
|
202
|
+
"fontSize": "14px",
|
|
203
|
+
"pointerEvents": "none",
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
width={400}
|
|
207
|
+
x="0"
|
|
208
|
+
y="0"
|
|
209
|
+
/>
|
|
210
|
+
</g>
|
|
211
|
+
</g>
|
|
212
|
+
</WithStyles(Root)>
|
|
213
|
+
`;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Grid snapshot renders 1`] = `
|
|
4
|
+
<Fragment>
|
|
5
|
+
<r
|
|
6
|
+
columnTickValues={
|
|
7
|
+
Array [
|
|
8
|
+
0,
|
|
9
|
+
1,
|
|
10
|
+
]
|
|
11
|
+
}
|
|
12
|
+
height={400}
|
|
13
|
+
innerRef={[Function]}
|
|
14
|
+
rowTickValues={
|
|
15
|
+
Array [
|
|
16
|
+
0,
|
|
17
|
+
1,
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
stroke="#D3D3D3"
|
|
21
|
+
width={400}
|
|
22
|
+
xScale={
|
|
23
|
+
[MockFunction] {
|
|
24
|
+
"calls": Array [
|
|
25
|
+
Array [
|
|
26
|
+
0,
|
|
27
|
+
],
|
|
28
|
+
],
|
|
29
|
+
"results": Array [
|
|
30
|
+
Object {
|
|
31
|
+
"type": "return",
|
|
32
|
+
"value": 0,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
yScale={
|
|
38
|
+
[MockFunction] {
|
|
39
|
+
"calls": Array [
|
|
40
|
+
Array [
|
|
41
|
+
0,
|
|
42
|
+
],
|
|
43
|
+
],
|
|
44
|
+
"results": Array [
|
|
45
|
+
Object {
|
|
46
|
+
"type": "return",
|
|
47
|
+
"value": 0,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/>
|
|
53
|
+
</Fragment>
|
|
54
|
+
`;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Labels snapshot renders 1`] = `
|
|
4
|
+
<Fragment>
|
|
5
|
+
<WithStyles(RawLabel)
|
|
6
|
+
key="left"
|
|
7
|
+
mathMlOptions={Object {}}
|
|
8
|
+
onChange={[Function]}
|
|
9
|
+
side="left"
|
|
10
|
+
/>
|
|
11
|
+
<WithStyles(RawLabel)
|
|
12
|
+
key="top"
|
|
13
|
+
mathMlOptions={Object {}}
|
|
14
|
+
onChange={[Function]}
|
|
15
|
+
side="top"
|
|
16
|
+
/>
|
|
17
|
+
<WithStyles(RawLabel)
|
|
18
|
+
key="bottom"
|
|
19
|
+
mathMlOptions={Object {}}
|
|
20
|
+
onChange={[Function]}
|
|
21
|
+
side="bottom"
|
|
22
|
+
/>
|
|
23
|
+
<WithStyles(RawLabel)
|
|
24
|
+
key="right"
|
|
25
|
+
mathMlOptions={Object {}}
|
|
26
|
+
onChange={[Function]}
|
|
27
|
+
side="right"
|
|
28
|
+
/>
|
|
29
|
+
</Fragment>
|
|
30
|
+
`;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`MarkLabel snapshot renders 1`] = `
|
|
4
|
+
<AutosizeInput
|
|
5
|
+
injectStyles={true}
|
|
6
|
+
inputClassName=""
|
|
7
|
+
inputRef={[Function]}
|
|
8
|
+
minWidth={1}
|
|
9
|
+
onChange={[Function]}
|
|
10
|
+
style={
|
|
11
|
+
Object {
|
|
12
|
+
"left": -9,
|
|
13
|
+
"pointerEvents": "auto",
|
|
14
|
+
"position": "fixed",
|
|
15
|
+
"top": -9,
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/>
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
exports[`MarkLabel snapshot renders 2`] = `
|
|
22
|
+
<AutosizeInput
|
|
23
|
+
injectStyles={true}
|
|
24
|
+
inputClassName=""
|
|
25
|
+
inputRef={[Function]}
|
|
26
|
+
minWidth={1}
|
|
27
|
+
onChange={[Function]}
|
|
28
|
+
style={
|
|
29
|
+
Object {
|
|
30
|
+
"left": 0,
|
|
31
|
+
"pointerEvents": "auto",
|
|
32
|
+
"position": "fixed",
|
|
33
|
+
"top": 0,
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/>
|
|
37
|
+
`;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ToolMenu snapshot renders 1`] = `
|
|
4
|
+
<ToolMenu
|
|
5
|
+
className="className"
|
|
6
|
+
classes={
|
|
7
|
+
Object {
|
|
8
|
+
"lineNameFont": "ToolMenu-lineNameFont-7",
|
|
9
|
+
"lineTypeButtonLeftSelected": "ToolMenu-lineTypeButtonLeftSelected-8",
|
|
10
|
+
"lineTypeButtonLeftSelectedDisabled": "ToolMenu-lineTypeButtonLeftSelectedDisabled-13",
|
|
11
|
+
"lineTypeButtonLeftUnSelected": "ToolMenu-lineTypeButtonLeftUnSelected-9",
|
|
12
|
+
"lineTypeButtonLeftUnSelectedDisabled": "ToolMenu-lineTypeButtonLeftUnSelectedDisabled-14",
|
|
13
|
+
"lineTypeButtonRightSelected": "ToolMenu-lineTypeButtonRightSelected-10",
|
|
14
|
+
"lineTypeButtonRightSelectedDisabled": "ToolMenu-lineTypeButtonRightSelectedDisabled-15",
|
|
15
|
+
"lineTypeButtonRightUnSelected": "ToolMenu-lineTypeButtonRightUnSelected-11",
|
|
16
|
+
"lineTypeButtonRightUnSelectedDisabled": "ToolMenu-lineTypeButtonRightUnSelectedDisabled-16",
|
|
17
|
+
"lineTypeRadio": "ToolMenu-lineTypeRadio-12",
|
|
18
|
+
"lineTypeText": "ToolMenu-lineTypeText-6",
|
|
19
|
+
"radioButtonClass": "ToolMenu-radioButtonClass-1",
|
|
20
|
+
"radioFieldButtons": "ToolMenu-radioFieldButtons-5",
|
|
21
|
+
"radioFieldInner": "ToolMenu-radioFieldInner-3",
|
|
22
|
+
"radioFieldOuter": "ToolMenu-radioFieldOuter-4",
|
|
23
|
+
"selectLineRadioGroup": "ToolMenu-selectLineRadioGroup-2",
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
currentTool="one"
|
|
27
|
+
onChange={[MockFunction]}
|
|
28
|
+
tools={
|
|
29
|
+
Array [
|
|
30
|
+
"one",
|
|
31
|
+
"two",
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
/>
|
|
35
|
+
`;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`UndoRedo snapshot renders 1`] = `
|
|
4
|
+
<UndoRedo
|
|
5
|
+
classes={
|
|
6
|
+
Object {
|
|
7
|
+
"button": "UndoRedo-button-1",
|
|
8
|
+
"undoRedoDiv": "UndoRedo-undoRedoDiv-2",
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
onRedo={[MockFunction]}
|
|
12
|
+
onReset={[MockFunction]}
|
|
13
|
+
onUndo={[MockFunction]}
|
|
14
|
+
/>
|
|
15
|
+
`;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { shallow } from 'enzyme';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
GraphWithControls,
|
|
6
|
+
setToolbarAvailability,
|
|
7
|
+
toolIsAvailable,
|
|
8
|
+
getAvailableTool,
|
|
9
|
+
filterByValidToolTypes,
|
|
10
|
+
filterByVisibleToolTypes,
|
|
11
|
+
} from '../graph-with-controls';
|
|
12
|
+
import { toolsArr, allTools, line as lineTool } from '@pie-lib/tools';
|
|
13
|
+
|
|
14
|
+
const line = {
|
|
15
|
+
type: 'line',
|
|
16
|
+
from: { x: 0, y: 0 },
|
|
17
|
+
to: { x: 1, y: 1 },
|
|
18
|
+
label: 'Line',
|
|
19
|
+
building: true,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const polygon = {
|
|
23
|
+
type: 'polygon',
|
|
24
|
+
points: [
|
|
25
|
+
{ x: 0, y: 0 },
|
|
26
|
+
{ x: 1, y: 1 },
|
|
27
|
+
{ x: 2, y: 2 },
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const marks = [line, polygon];
|
|
32
|
+
|
|
33
|
+
describe('setToolbarAvailability', () => {
|
|
34
|
+
it('sets `toolbar: true` if tool should be displayed in toolbar - all tools', () => {
|
|
35
|
+
const result = setToolbarAvailability(allTools);
|
|
36
|
+
const allTrue = new Array(toolsArr.length).fill(true);
|
|
37
|
+
|
|
38
|
+
expect(result.map((r) => r.toolbar)).toEqual(allTrue);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('sets `toolbar: true` if tool should be displayed in toolbar - few tools', () => {
|
|
42
|
+
const result = setToolbarAvailability(['line', 'polygon']);
|
|
43
|
+
const allOthersFalse = new Array(toolsArr.length - 2).fill(false);
|
|
44
|
+
|
|
45
|
+
expect(result.filter((r) => r.type === 'line' || r.type === 'polygon').map((r) => r.toolbar)).toEqual([true, true]);
|
|
46
|
+
expect(result.filter((r) => r.type !== 'line' && r.type !== 'polygon').map((r) => r.toolbar)).toEqual(
|
|
47
|
+
allOthersFalse,
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe('toolIsAvailable', () => {
|
|
53
|
+
const tools = setToolbarAvailability(['line', 'polygon']);
|
|
54
|
+
|
|
55
|
+
it('returns true if tool is available', () => {
|
|
56
|
+
expect(toolIsAvailable(tools, lineTool())).toEqual(true);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('getAvailableTool', () => {
|
|
61
|
+
it('returns the first available tool in list if there is any', () => {
|
|
62
|
+
const tools = setToolbarAvailability(['line', 'polygon']);
|
|
63
|
+
|
|
64
|
+
expect(getAvailableTool(tools).toolbar).toEqual(true);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('returns undefined list if there is no available tool', () => {
|
|
68
|
+
const tools = setToolbarAvailability([]);
|
|
69
|
+
|
|
70
|
+
expect(getAvailableTool(tools)).toEqual(undefined);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe('filterByValidToolTypes', () => {
|
|
75
|
+
it('filters marks by valid types', () => {
|
|
76
|
+
const marks = [{ type: 'polygon' }, { type: 'a' }, { type: 'b' }, { type: 'line' }, { type: 'c' }];
|
|
77
|
+
|
|
78
|
+
expect(filterByValidToolTypes(marks)).toEqual([{ type: 'polygon' }, { type: 'line' }]);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe('filterByVisibleToolTypes', () => {
|
|
83
|
+
it('filters marks by the types that should be visible', () => {
|
|
84
|
+
expect(
|
|
85
|
+
filterByVisibleToolTypes(['line', 'polygon'], [{ type: 'point' }, { type: 'line' }, { type: 'polygon' }]),
|
|
86
|
+
).toEqual([{ type: 'line' }, { type: 'polygon' }]);
|
|
87
|
+
|
|
88
|
+
expect(filterByVisibleToolTypes(['line'], [{ type: 'point' }, { type: 'line' }, { type: 'circle' }])).toEqual([
|
|
89
|
+
{ type: 'line' },
|
|
90
|
+
]);
|
|
91
|
+
|
|
92
|
+
expect(filterByVisibleToolTypes(['segment'], [{ type: 'point' }, { type: 'line' }, { type: 'circle' }])).toEqual(
|
|
93
|
+
[],
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('GraphWithControls', () => {
|
|
99
|
+
let w;
|
|
100
|
+
let onChangeMarks = jest.fn();
|
|
101
|
+
|
|
102
|
+
const defaultProps = () => ({
|
|
103
|
+
axesSettings: { includeArrows: true },
|
|
104
|
+
classes: {},
|
|
105
|
+
className: '',
|
|
106
|
+
coordinatesOnHover: false,
|
|
107
|
+
domain: { min: 0, max: 10, step: 1 },
|
|
108
|
+
labels: { top: 'a', left: 'b', right: 'c', bottom: 'd' },
|
|
109
|
+
labelModeEnabled: true,
|
|
110
|
+
marks,
|
|
111
|
+
onChangeMarks,
|
|
112
|
+
range: { min: 0, max: 10, step: 1 },
|
|
113
|
+
size: { width: 500, height: 500 },
|
|
114
|
+
title: 'Title',
|
|
115
|
+
toolbarTools: allTools,
|
|
116
|
+
});
|
|
117
|
+
const initialProps = defaultProps();
|
|
118
|
+
|
|
119
|
+
const wrapper = (extras, opts) => {
|
|
120
|
+
const props = { ...initialProps, ...extras };
|
|
121
|
+
|
|
122
|
+
return shallow(<GraphWithControls {...props} />, opts);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
describe('snapshot', () => {
|
|
126
|
+
it('renders', () => {
|
|
127
|
+
w = wrapper();
|
|
128
|
+
expect(w).toMatchSnapshot();
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|