@pie-lib/graphing-solution-set 2.15.0-beta.1

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.
Files changed (166) hide show
  1. package/CHANGELOG.json +1 -0
  2. package/CHANGELOG.md +28 -0
  3. package/LICENSE.md +5 -0
  4. package/NEXT.CHANGELOG.json +1 -0
  5. package/lib/axis/arrow.js +115 -0
  6. package/lib/axis/arrow.js.map +1 -0
  7. package/lib/axis/axes.js +415 -0
  8. package/lib/axis/axes.js.map +1 -0
  9. package/lib/axis/index.js +26 -0
  10. package/lib/axis/index.js.map +1 -0
  11. package/lib/bg.js +139 -0
  12. package/lib/bg.js.map +1 -0
  13. package/lib/container/actions.js +24 -0
  14. package/lib/container/actions.js.map +1 -0
  15. package/lib/container/index.js +166 -0
  16. package/lib/container/index.js.map +1 -0
  17. package/lib/container/marks.js +27 -0
  18. package/lib/container/marks.js.map +1 -0
  19. package/lib/container/middleware.js +25 -0
  20. package/lib/container/middleware.js.map +1 -0
  21. package/lib/container/reducer.js +25 -0
  22. package/lib/container/reducer.js.map +1 -0
  23. package/lib/coordinates-label.js +109 -0
  24. package/lib/coordinates-label.js.map +1 -0
  25. package/lib/graph-with-controls.js +372 -0
  26. package/lib/graph-with-controls.js.map +1 -0
  27. package/lib/graph.js +419 -0
  28. package/lib/graph.js.map +1 -0
  29. package/lib/grid-setup.js +462 -0
  30. package/lib/grid-setup.js.map +1 -0
  31. package/lib/grid.js +176 -0
  32. package/lib/grid.js.map +1 -0
  33. package/lib/index.js +51 -0
  34. package/lib/index.js.map +1 -0
  35. package/lib/labels.js +299 -0
  36. package/lib/labels.js.map +1 -0
  37. package/lib/mark-label.js +208 -0
  38. package/lib/mark-label.js.map +1 -0
  39. package/lib/toggle-bar.js +336 -0
  40. package/lib/toggle-bar.js.map +1 -0
  41. package/lib/tool-menu.js +325 -0
  42. package/lib/tool-menu.js.map +1 -0
  43. package/lib/tools/index.js +29 -0
  44. package/lib/tools/index.js.map +1 -0
  45. package/lib/tools/line/component.js +106 -0
  46. package/lib/tools/line/component.js.map +1 -0
  47. package/lib/tools/line/index.js +16 -0
  48. package/lib/tools/line/index.js.map +1 -0
  49. package/lib/tools/polygon/component.js +457 -0
  50. package/lib/tools/polygon/component.js.map +1 -0
  51. package/lib/tools/polygon/index.js +106 -0
  52. package/lib/tools/polygon/index.js.map +1 -0
  53. package/lib/tools/polygon/line.js +151 -0
  54. package/lib/tools/polygon/line.js.map +1 -0
  55. package/lib/tools/polygon/polygon.js +171 -0
  56. package/lib/tools/polygon/polygon.js.map +1 -0
  57. package/lib/tools/shared/arrow-head.js +75 -0
  58. package/lib/tools/shared/arrow-head.js.map +1 -0
  59. package/lib/tools/shared/line/index.js +637 -0
  60. package/lib/tools/shared/line/index.js.map +1 -0
  61. package/lib/tools/shared/line/line-path.js +145 -0
  62. package/lib/tools/shared/line/line-path.js.map +1 -0
  63. package/lib/tools/shared/line/with-root-edge.js +155 -0
  64. package/lib/tools/shared/line/with-root-edge.js.map +1 -0
  65. package/lib/tools/shared/point/arrow-point.js +113 -0
  66. package/lib/tools/shared/point/arrow-point.js.map +1 -0
  67. package/lib/tools/shared/point/arrow.js +96 -0
  68. package/lib/tools/shared/point/arrow.js.map +1 -0
  69. package/lib/tools/shared/point/base-point.js +151 -0
  70. package/lib/tools/shared/point/base-point.js.map +1 -0
  71. package/lib/tools/shared/point/index.js +94 -0
  72. package/lib/tools/shared/point/index.js.map +1 -0
  73. package/lib/tools/shared/styles.js +49 -0
  74. package/lib/tools/shared/styles.js.map +1 -0
  75. package/lib/tools/shared/types.js +19 -0
  76. package/lib/tools/shared/types.js.map +1 -0
  77. package/lib/undo-redo.js +107 -0
  78. package/lib/undo-redo.js.map +1 -0
  79. package/lib/use-debounce.js +32 -0
  80. package/lib/use-debounce.js.map +1 -0
  81. package/lib/utils.js +314 -0
  82. package/lib/utils.js.map +1 -0
  83. package/package.json +57 -0
  84. package/src/__tests__/__snapshots__/graph-with-controls.test.jsx.snap +114 -0
  85. package/src/__tests__/__snapshots__/graph.test.jsx.snap +213 -0
  86. package/src/__tests__/__snapshots__/grid.test.jsx.snap +54 -0
  87. package/src/__tests__/__snapshots__/labels.test.jsx.snap +30 -0
  88. package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +37 -0
  89. package/src/__tests__/__snapshots__/toggle-bar.test.jsx.snap +7 -0
  90. package/src/__tests__/__snapshots__/tool-menu.test.jsx.snap +35 -0
  91. package/src/__tests__/__snapshots__/undo-redo.test.jsx.snap +15 -0
  92. package/src/__tests__/graph-with-controls.test.jsx +131 -0
  93. package/src/__tests__/graph.test.jsx +230 -0
  94. package/src/__tests__/grid.test.jsx +20 -0
  95. package/src/__tests__/labels.test.jsx +38 -0
  96. package/src/__tests__/mark-label.test.jsx +68 -0
  97. package/src/__tests__/toggle-bar.test.jsx +36 -0
  98. package/src/__tests__/tool-menu.test.jsx +29 -0
  99. package/src/__tests__/undo-redo.test.jsx +25 -0
  100. package/src/__tests__/use-debounce.test.js +21 -0
  101. package/src/__tests__/utils.js +38 -0
  102. package/src/__tests__/utils.test.js +151 -0
  103. package/src/axis/__tests__/__snapshots__/arrow.test.jsx.snap +33 -0
  104. package/src/axis/__tests__/__snapshots__/axes.test.jsx.snap +122 -0
  105. package/src/axis/__tests__/arrow.test.jsx +39 -0
  106. package/src/axis/__tests__/axes.test.jsx +220 -0
  107. package/src/axis/arrow.jsx +62 -0
  108. package/src/axis/axes.jsx +307 -0
  109. package/src/axis/index.js +2 -0
  110. package/src/bg.jsx +96 -0
  111. package/src/container/actions.js +8 -0
  112. package/src/container/index.jsx +86 -0
  113. package/src/container/marks.js +14 -0
  114. package/src/container/middleware.js +7 -0
  115. package/src/container/reducer.js +5 -0
  116. package/src/coordinates-label.jsx +73 -0
  117. package/src/graph-with-controls.jsx +263 -0
  118. package/src/graph.jsx +334 -0
  119. package/src/grid-setup.jsx +424 -0
  120. package/src/grid.jsx +135 -0
  121. package/src/index.js +7 -0
  122. package/src/labels.jsx +214 -0
  123. package/src/mark-label.jsx +136 -0
  124. package/src/toggle-bar.jsx +242 -0
  125. package/src/tool-menu.jsx +294 -0
  126. package/src/tools/index.js +8 -0
  127. package/src/tools/line/__tests__/__snapshots__/component.test.jsx.snap +20 -0
  128. package/src/tools/line/__tests__/component.test.jsx +36 -0
  129. package/src/tools/line/component.jsx +77 -0
  130. package/src/tools/line/index.js +4 -0
  131. package/src/tools/polygon/__tests__/__snapshots__/component.test.jsx.snap +94 -0
  132. package/src/tools/polygon/__tests__/__snapshots__/line.test.jsx.snap +44 -0
  133. package/src/tools/polygon/__tests__/__snapshots__/polygon.test.jsx.snap +53 -0
  134. package/src/tools/polygon/__tests__/component.test.jsx +214 -0
  135. package/src/tools/polygon/__tests__/index.test.js +65 -0
  136. package/src/tools/polygon/__tests__/line.test.jsx +25 -0
  137. package/src/tools/polygon/__tests__/polygon.test.jsx +44 -0
  138. package/src/tools/polygon/component.jsx +336 -0
  139. package/src/tools/polygon/index.js +52 -0
  140. package/src/tools/polygon/line.jsx +78 -0
  141. package/src/tools/polygon/polygon.jsx +101 -0
  142. package/src/tools/shared/__tests__/__snapshots__/arrow-head.test.jsx.snap +32 -0
  143. package/src/tools/shared/__tests__/arrow-head.test.jsx +34 -0
  144. package/src/tools/shared/arrow-head.jsx +46 -0
  145. package/src/tools/shared/line/__tests__/__snapshots__/index.test.jsx.snap +360 -0
  146. package/src/tools/shared/line/__tests__/__snapshots__/line-path.test.jsx.snap +57 -0
  147. package/src/tools/shared/line/__tests__/__snapshots__/with-root-edge.test.jsx.snap +63 -0
  148. package/src/tools/shared/line/__tests__/index.test.jsx +247 -0
  149. package/src/tools/shared/line/__tests__/line-path.test.jsx +53 -0
  150. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +73 -0
  151. package/src/tools/shared/line/index.jsx +473 -0
  152. package/src/tools/shared/line/line-path.jsx +88 -0
  153. package/src/tools/shared/line/with-root-edge.jsx +97 -0
  154. package/src/tools/shared/point/__tests__/__snapshots__/arrow-point.test.jsx.snap +55 -0
  155. package/src/tools/shared/point/__tests__/__snapshots__/base-point.test.jsx.snap +43 -0
  156. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +87 -0
  157. package/src/tools/shared/point/__tests__/base-point.test.jsx +84 -0
  158. package/src/tools/shared/point/arrow-point.jsx +60 -0
  159. package/src/tools/shared/point/arrow.jsx +40 -0
  160. package/src/tools/shared/point/base-point.jsx +86 -0
  161. package/src/tools/shared/point/index.jsx +60 -0
  162. package/src/tools/shared/styles.js +20 -0
  163. package/src/tools/shared/types.js +8 -0
  164. package/src/undo-redo.jsx +47 -0
  165. package/src/use-debounce.js +13 -0
  166. 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,7 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ToggleBar snapshot renders 1`] = `
4
+ <div
5
+ className="className"
6
+ />
7
+ `;
@@ -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
+ });