@pie-lib/graphing-solution-set 4.1.0-beta.6 → 4.1.0-beta.8
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/package.json +3 -3
- package/lib/__tests__/bg.test.js +0 -282
- package/lib/__tests__/bg.test.js.map +0 -1
- package/lib/__tests__/coordinates-label.test.js +0 -276
- package/lib/__tests__/coordinates-label.test.js.map +0 -1
- package/lib/__tests__/graph-with-controls.test.js +0 -256
- package/lib/__tests__/graph-with-controls.test.js.map +0 -1
- package/lib/__tests__/graph.test.js +0 -113
- package/lib/__tests__/graph.test.js.map +0 -1
- package/lib/__tests__/grid-setup.test.js +0 -729
- package/lib/__tests__/grid-setup.test.js.map +0 -1
- package/lib/__tests__/grid.test.js +0 -29
- package/lib/__tests__/grid.test.js.map +0 -1
- package/lib/__tests__/labels.test.js +0 -45
- package/lib/__tests__/labels.test.js.map +0 -1
- package/lib/__tests__/mark-label.test.js +0 -133
- package/lib/__tests__/mark-label.test.js.map +0 -1
- package/lib/__tests__/toggle-bar.test.js +0 -146
- package/lib/__tests__/toggle-bar.test.js.map +0 -1
- package/lib/__tests__/tool-menu.test.js +0 -540
- package/lib/__tests__/tool-menu.test.js.map +0 -1
- package/lib/__tests__/undo-redo.test.js +0 -31
- package/lib/__tests__/undo-redo.test.js.map +0 -1
- package/lib/__tests__/use-debounce.test.js +0 -24
- package/lib/__tests__/use-debounce.test.js.map +0 -1
- package/lib/__tests__/utils.js +0 -70
- package/lib/__tests__/utils.js.map +0 -1
- package/lib/__tests__/utils.test.js +0 -123
- package/lib/__tests__/utils.test.js.map +0 -1
- package/lib/axis/__tests__/arrow.test.js +0 -60
- package/lib/axis/__tests__/arrow.test.js.map +0 -1
- package/lib/axis/__tests__/axes.test.js +0 -160
- package/lib/axis/__tests__/axes.test.js.map +0 -1
- package/lib/container/__tests__/actions.test.js +0 -108
- package/lib/container/__tests__/actions.test.js.map +0 -1
- package/lib/container/__tests__/index.test.js +0 -346
- package/lib/container/__tests__/index.test.js.map +0 -1
- package/lib/container/__tests__/marks.test.js +0 -259
- package/lib/container/__tests__/marks.test.js.map +0 -1
- package/lib/container/__tests__/middleware.test.js +0 -244
- package/lib/container/__tests__/middleware.test.js.map +0 -1
- package/lib/container/__tests__/reducer.test.js +0 -450
- package/lib/container/__tests__/reducer.test.js.map +0 -1
- package/lib/tools/line/__tests__/component.test.js +0 -45
- package/lib/tools/line/__tests__/component.test.js.map +0 -1
- package/lib/tools/polygon/__tests__/component.test.js +0 -501
- package/lib/tools/polygon/__tests__/component.test.js.map +0 -1
- package/lib/tools/polygon/__tests__/index.test.js +0 -92
- package/lib/tools/polygon/__tests__/index.test.js.map +0 -1
- package/lib/tools/polygon/__tests__/line.test.js +0 -30
- package/lib/tools/polygon/__tests__/line.test.js.map +0 -1
- package/lib/tools/polygon/__tests__/polygon.test.js +0 -61
- package/lib/tools/polygon/__tests__/polygon.test.js.map +0 -1
- package/lib/tools/shared/__tests__/arrow-head.test.js +0 -45
- package/lib/tools/shared/__tests__/arrow-head.test.js.map +0 -1
- package/lib/tools/shared/line/__tests__/index.test.js +0 -725
- package/lib/tools/shared/line/__tests__/index.test.js.map +0 -1
- package/lib/tools/shared/line/__tests__/line-path.test.js +0 -64
- package/lib/tools/shared/line/__tests__/line-path.test.js.map +0 -1
- package/lib/tools/shared/line/__tests__/with-root-edge.test.js +0 -618
- package/lib/tools/shared/line/__tests__/with-root-edge.test.js.map +0 -1
- package/lib/tools/shared/point/__tests__/arrow-point.test.js +0 -127
- package/lib/tools/shared/point/__tests__/arrow-point.test.js.map +0 -1
- package/lib/tools/shared/point/__tests__/arrow.test.js +0 -619
- package/lib/tools/shared/point/__tests__/arrow.test.js.map +0 -1
- package/lib/tools/shared/point/__tests__/base-point.test.js +0 -122
- package/lib/tools/shared/point/__tests__/base-point.test.js.map +0 -1
|
@@ -1,618 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
5
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
6
|
-
var _testUtils = require("@pie-lib/test-utils");
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _withRootEdge = require("../with-root-edge");
|
|
9
|
-
var _utils = require("../../../../__tests__/utils");
|
|
10
|
-
var _plot = require("@pie-lib/plot");
|
|
11
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
-
var xy = _plot.utils.xy;
|
|
14
|
-
jest.mock('../index', function () {
|
|
15
|
-
var React = require('react');
|
|
16
|
-
var out = {
|
|
17
|
-
lineBase: jest.fn(function (Component) {
|
|
18
|
-
return Component;
|
|
19
|
-
}),
|
|
20
|
-
lineToolComponent: jest.fn(function (Component) {
|
|
21
|
-
return function (props) {
|
|
22
|
-
return /*#__PURE__*/React.createElement(Component, props);
|
|
23
|
-
};
|
|
24
|
-
})
|
|
25
|
-
};
|
|
26
|
-
return out;
|
|
27
|
-
});
|
|
28
|
-
describe('rootEdgeToFromToWrapper', function () {
|
|
29
|
-
var Comp;
|
|
30
|
-
var onChange;
|
|
31
|
-
beforeEach(function () {
|
|
32
|
-
onChange = jest.fn();
|
|
33
|
-
Comp = (0, _withRootEdge.rootEdgeToFromToWrapper)(function (props) {
|
|
34
|
-
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
|
|
35
|
-
"data-testid": "wrapped-component"
|
|
36
|
-
}, props));
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var renderComponent = function renderComponent(extras) {
|
|
40
|
-
var defaults = {
|
|
41
|
-
mark: {
|
|
42
|
-
root: xy(1, 1),
|
|
43
|
-
edge: xy(2, 2)
|
|
44
|
-
},
|
|
45
|
-
onChange: onChange
|
|
46
|
-
};
|
|
47
|
-
var props = _objectSpread(_objectSpread({}, defaults), extras);
|
|
48
|
-
return (0, _testUtils.render)(/*#__PURE__*/_react["default"].createElement(Comp, props));
|
|
49
|
-
};
|
|
50
|
-
describe('rendering', function () {
|
|
51
|
-
it('renders without crashing', function () {
|
|
52
|
-
var _renderComponent = renderComponent(),
|
|
53
|
-
container = _renderComponent.container;
|
|
54
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
55
|
-
});
|
|
56
|
-
it('renders with only root point', function () {
|
|
57
|
-
var _renderComponent2 = renderComponent({
|
|
58
|
-
mark: {
|
|
59
|
-
root: xy(1, 1)
|
|
60
|
-
}
|
|
61
|
-
}),
|
|
62
|
-
container = _renderComponent2.container;
|
|
63
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
64
|
-
});
|
|
65
|
-
it('renders with root and edge points', function () {
|
|
66
|
-
var _renderComponent3 = renderComponent({
|
|
67
|
-
mark: {
|
|
68
|
-
root: xy(0, 0),
|
|
69
|
-
edge: xy(5, 5)
|
|
70
|
-
}
|
|
71
|
-
}),
|
|
72
|
-
container = _renderComponent3.container;
|
|
73
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
74
|
-
});
|
|
75
|
-
it('renders with negative coordinates', function () {
|
|
76
|
-
var _renderComponent4 = renderComponent({
|
|
77
|
-
mark: {
|
|
78
|
-
root: xy(-5, -5),
|
|
79
|
-
edge: xy(-1, -1)
|
|
80
|
-
}
|
|
81
|
-
}),
|
|
82
|
-
container = _renderComponent4.container;
|
|
83
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
84
|
-
});
|
|
85
|
-
it('renders with decimal coordinates', function () {
|
|
86
|
-
var _renderComponent5 = renderComponent({
|
|
87
|
-
mark: {
|
|
88
|
-
root: xy(0.5, 0.5),
|
|
89
|
-
edge: xy(1.5, 1.5)
|
|
90
|
-
}
|
|
91
|
-
}),
|
|
92
|
-
container = _renderComponent5.container;
|
|
93
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
describe('coordinate transformation', function () {
|
|
97
|
-
it('converts root/edge to from/to for wrapped component', function () {
|
|
98
|
-
var _renderComponent6 = renderComponent({
|
|
99
|
-
mark: {
|
|
100
|
-
root: xy(1, 1),
|
|
101
|
-
edge: xy(2, 2)
|
|
102
|
-
}
|
|
103
|
-
}),
|
|
104
|
-
getByTestId = _renderComponent6.getByTestId;
|
|
105
|
-
var wrappedComponent = getByTestId('wrapped-component');
|
|
106
|
-
expect(wrappedComponent).toBeInTheDocument();
|
|
107
|
-
});
|
|
108
|
-
it('handles mark without edge', function () {
|
|
109
|
-
var _renderComponent7 = renderComponent({
|
|
110
|
-
mark: {
|
|
111
|
-
root: xy(1, 1)
|
|
112
|
-
}
|
|
113
|
-
}),
|
|
114
|
-
container = _renderComponent7.container;
|
|
115
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
116
|
-
});
|
|
117
|
-
it('handles mark with undefined edge', function () {
|
|
118
|
-
var _renderComponent8 = renderComponent({
|
|
119
|
-
mark: {
|
|
120
|
-
root: xy(1, 1),
|
|
121
|
-
edge: undefined
|
|
122
|
-
}
|
|
123
|
-
}),
|
|
124
|
-
container = _renderComponent8.container;
|
|
125
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
describe('onChange handling', function () {
|
|
129
|
-
it('passes onChange handler to wrapped component', function () {
|
|
130
|
-
var _renderComponent9 = renderComponent(),
|
|
131
|
-
container = _renderComponent9.container;
|
|
132
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
133
|
-
expect(onChange).not.toHaveBeenCalled();
|
|
134
|
-
});
|
|
135
|
-
it('provides onChange prop to wrapped component', function () {
|
|
136
|
-
var _renderComponent0 = renderComponent(),
|
|
137
|
-
getByTestId = _renderComponent0.getByTestId;
|
|
138
|
-
var wrappedComponent = getByTestId('wrapped-component');
|
|
139
|
-
expect(wrappedComponent).toBeInTheDocument();
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
describe('prop forwarding', function () {
|
|
143
|
-
it('forwards additional props to wrapped component', function () {
|
|
144
|
-
var _renderComponent1 = renderComponent({
|
|
145
|
-
disabled: true,
|
|
146
|
-
correctness: 'correct'
|
|
147
|
-
}),
|
|
148
|
-
getByTestId = _renderComponent1.getByTestId;
|
|
149
|
-
var wrappedComponent = getByTestId('wrapped-component');
|
|
150
|
-
expect(wrappedComponent).toBeInTheDocument();
|
|
151
|
-
});
|
|
152
|
-
it('forwards graphProps', function () {
|
|
153
|
-
var graphProps = (0, _utils.graphProps)();
|
|
154
|
-
var _renderComponent10 = renderComponent({
|
|
155
|
-
graphProps: graphProps
|
|
156
|
-
}),
|
|
157
|
-
getByTestId = _renderComponent10.getByTestId;
|
|
158
|
-
var wrappedComponent = getByTestId('wrapped-component');
|
|
159
|
-
expect(wrappedComponent).toBeInTheDocument();
|
|
160
|
-
});
|
|
161
|
-
it('forwards all standard props', function () {
|
|
162
|
-
var _renderComponent11 = renderComponent({
|
|
163
|
-
disabled: false,
|
|
164
|
-
correctness: 'incorrect',
|
|
165
|
-
fill: '#ff0000',
|
|
166
|
-
onClick: jest.fn(),
|
|
167
|
-
onDragStart: jest.fn(),
|
|
168
|
-
onDragStop: jest.fn()
|
|
169
|
-
}),
|
|
170
|
-
getByTestId = _renderComponent11.getByTestId;
|
|
171
|
-
var wrappedComponent = getByTestId('wrapped-component');
|
|
172
|
-
expect(wrappedComponent).toBeInTheDocument();
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
describe('edge cases', function () {
|
|
176
|
-
it('handles mark with same root and edge', function () {
|
|
177
|
-
var _renderComponent12 = renderComponent({
|
|
178
|
-
mark: {
|
|
179
|
-
root: xy(1, 1),
|
|
180
|
-
edge: xy(1, 1)
|
|
181
|
-
}
|
|
182
|
-
}),
|
|
183
|
-
container = _renderComponent12.container;
|
|
184
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
185
|
-
});
|
|
186
|
-
it('handles mark with zero coordinates', function () {
|
|
187
|
-
var _renderComponent13 = renderComponent({
|
|
188
|
-
mark: {
|
|
189
|
-
root: xy(0, 0),
|
|
190
|
-
edge: xy(0, 0)
|
|
191
|
-
}
|
|
192
|
-
}),
|
|
193
|
-
container = _renderComponent13.container;
|
|
194
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
195
|
-
});
|
|
196
|
-
it('handles mark with large coordinate values', function () {
|
|
197
|
-
var _renderComponent14 = renderComponent({
|
|
198
|
-
mark: {
|
|
199
|
-
root: xy(1000, 1000),
|
|
200
|
-
edge: xy(2000, 2000)
|
|
201
|
-
}
|
|
202
|
-
}),
|
|
203
|
-
container = _renderComponent14.container;
|
|
204
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
205
|
-
});
|
|
206
|
-
it('handles mark with labels', function () {
|
|
207
|
-
var _renderComponent15 = renderComponent({
|
|
208
|
-
mark: {
|
|
209
|
-
root: {
|
|
210
|
-
x: 1,
|
|
211
|
-
y: 1,
|
|
212
|
-
label: 'Root'
|
|
213
|
-
},
|
|
214
|
-
edge: {
|
|
215
|
-
x: 2,
|
|
216
|
-
y: 2,
|
|
217
|
-
label: 'Edge'
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}),
|
|
221
|
-
container = _renderComponent15.container;
|
|
222
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
describe('rootEdgeComponent', function () {
|
|
227
|
-
var onChange;
|
|
228
|
-
var Comp;
|
|
229
|
-
var mark;
|
|
230
|
-
beforeEach(function () {
|
|
231
|
-
onChange = jest.fn();
|
|
232
|
-
mark = {
|
|
233
|
-
root: xy(0, 0),
|
|
234
|
-
edge: xy(1, 1)
|
|
235
|
-
};
|
|
236
|
-
Comp = (0, _withRootEdge.rootEdgeComponent)(function (props) {
|
|
237
|
-
return /*#__PURE__*/_react["default"].createElement("text", (0, _extends2["default"])({
|
|
238
|
-
"data-testid": "root-edge-comp"
|
|
239
|
-
}, props));
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
var renderComponent = function renderComponent(extras) {
|
|
243
|
-
var defaults = {
|
|
244
|
-
mark: mark,
|
|
245
|
-
graphProps: (0, _utils.graphProps)(),
|
|
246
|
-
onChange: onChange
|
|
247
|
-
};
|
|
248
|
-
var props = _objectSpread(_objectSpread({}, defaults), extras);
|
|
249
|
-
return (0, _testUtils.render)(/*#__PURE__*/_react["default"].createElement(Comp, props));
|
|
250
|
-
};
|
|
251
|
-
describe('rendering', function () {
|
|
252
|
-
it('renders without crashing', function () {
|
|
253
|
-
var _renderComponent16 = renderComponent(),
|
|
254
|
-
container = _renderComponent16.container;
|
|
255
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
256
|
-
});
|
|
257
|
-
it('renders with building mark', function () {
|
|
258
|
-
var buildingMark = {
|
|
259
|
-
root: xy(0, 0),
|
|
260
|
-
building: true
|
|
261
|
-
};
|
|
262
|
-
var _renderComponent17 = renderComponent({
|
|
263
|
-
mark: buildingMark
|
|
264
|
-
}),
|
|
265
|
-
container = _renderComponent17.container;
|
|
266
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
267
|
-
});
|
|
268
|
-
it('renders with complete mark', function () {
|
|
269
|
-
var completeMark = {
|
|
270
|
-
root: xy(0, 0),
|
|
271
|
-
edge: xy(5, 5),
|
|
272
|
-
building: false
|
|
273
|
-
};
|
|
274
|
-
var _renderComponent18 = renderComponent({
|
|
275
|
-
mark: completeMark
|
|
276
|
-
}),
|
|
277
|
-
container = _renderComponent18.container;
|
|
278
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
279
|
-
});
|
|
280
|
-
it('renders with disabled mark', function () {
|
|
281
|
-
var disabledMark = {
|
|
282
|
-
root: xy(0, 0),
|
|
283
|
-
edge: xy(1, 1),
|
|
284
|
-
disabled: true
|
|
285
|
-
};
|
|
286
|
-
var _renderComponent19 = renderComponent({
|
|
287
|
-
mark: disabledMark
|
|
288
|
-
}),
|
|
289
|
-
container = _renderComponent19.container;
|
|
290
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
291
|
-
});
|
|
292
|
-
it('renders with correctness state', function () {
|
|
293
|
-
var correctMark = {
|
|
294
|
-
root: xy(0, 0),
|
|
295
|
-
edge: xy(1, 1),
|
|
296
|
-
correctness: 'correct'
|
|
297
|
-
};
|
|
298
|
-
var _renderComponent20 = renderComponent({
|
|
299
|
-
mark: correctMark
|
|
300
|
-
}),
|
|
301
|
-
container = _renderComponent20.container;
|
|
302
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
describe('mark variations', function () {
|
|
306
|
-
it('handles mark without edge', function () {
|
|
307
|
-
var _renderComponent21 = renderComponent({
|
|
308
|
-
mark: {
|
|
309
|
-
root: xy(1, 1)
|
|
310
|
-
}
|
|
311
|
-
}),
|
|
312
|
-
container = _renderComponent21.container;
|
|
313
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
314
|
-
});
|
|
315
|
-
it('handles mark with middle point', function () {
|
|
316
|
-
var _renderComponent22 = renderComponent({
|
|
317
|
-
mark: {
|
|
318
|
-
root: xy(0, 0),
|
|
319
|
-
edge: xy(2, 2),
|
|
320
|
-
middle: xy(1, 1)
|
|
321
|
-
}
|
|
322
|
-
}),
|
|
323
|
-
container = _renderComponent22.container;
|
|
324
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
325
|
-
});
|
|
326
|
-
it('handles mark with custom fill', function () {
|
|
327
|
-
var _renderComponent23 = renderComponent({
|
|
328
|
-
mark: {
|
|
329
|
-
root: xy(0, 0),
|
|
330
|
-
edge: xy(1, 1),
|
|
331
|
-
fill: '#00ff00'
|
|
332
|
-
}
|
|
333
|
-
}),
|
|
334
|
-
container = _renderComponent23.container;
|
|
335
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
336
|
-
});
|
|
337
|
-
it('handles mark with type property', function () {
|
|
338
|
-
var _renderComponent24 = renderComponent({
|
|
339
|
-
mark: {
|
|
340
|
-
root: xy(0, 0),
|
|
341
|
-
edge: xy(1, 1),
|
|
342
|
-
type: 'parabola'
|
|
343
|
-
}
|
|
344
|
-
}),
|
|
345
|
-
container = _renderComponent24.container;
|
|
346
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
describe('prop forwarding', function () {
|
|
350
|
-
it('forwards graphProps correctly', function () {
|
|
351
|
-
var customGraphProps = (0, _utils.graphProps)(0, 10, 0, 10);
|
|
352
|
-
var _renderComponent25 = renderComponent({
|
|
353
|
-
graphProps: customGraphProps
|
|
354
|
-
}),
|
|
355
|
-
container = _renderComponent25.container;
|
|
356
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
357
|
-
});
|
|
358
|
-
it('forwards onClick handler', function () {
|
|
359
|
-
var onClick = jest.fn();
|
|
360
|
-
var _renderComponent26 = renderComponent({
|
|
361
|
-
onClick: onClick
|
|
362
|
-
}),
|
|
363
|
-
container = _renderComponent26.container;
|
|
364
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
365
|
-
});
|
|
366
|
-
it('forwards labelNode', function () {
|
|
367
|
-
var labelNode = document.createElement('foreignObject');
|
|
368
|
-
var _renderComponent27 = renderComponent({
|
|
369
|
-
labelNode: labelNode
|
|
370
|
-
}),
|
|
371
|
-
container = _renderComponent27.container;
|
|
372
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
373
|
-
});
|
|
374
|
-
it('forwards labelModeEnabled', function () {
|
|
375
|
-
var _renderComponent28 = renderComponent({
|
|
376
|
-
labelModeEnabled: true
|
|
377
|
-
}),
|
|
378
|
-
container = _renderComponent28.container;
|
|
379
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
380
|
-
});
|
|
381
|
-
it('forwards coordinatesOnHover', function () {
|
|
382
|
-
var _renderComponent29 = renderComponent({
|
|
383
|
-
coordinatesOnHover: true
|
|
384
|
-
}),
|
|
385
|
-
container = _renderComponent29.container;
|
|
386
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
387
|
-
});
|
|
388
|
-
});
|
|
389
|
-
describe('edge cases', function () {
|
|
390
|
-
it('handles vertical line (same x coordinates)', function () {
|
|
391
|
-
var _renderComponent30 = renderComponent({
|
|
392
|
-
mark: {
|
|
393
|
-
root: xy(1, 0),
|
|
394
|
-
edge: xy(1, 5)
|
|
395
|
-
}
|
|
396
|
-
}),
|
|
397
|
-
container = _renderComponent30.container;
|
|
398
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
399
|
-
});
|
|
400
|
-
it('handles horizontal line (same y coordinates)', function () {
|
|
401
|
-
var _renderComponent31 = renderComponent({
|
|
402
|
-
mark: {
|
|
403
|
-
root: xy(0, 1),
|
|
404
|
-
edge: xy(5, 1)
|
|
405
|
-
}
|
|
406
|
-
}),
|
|
407
|
-
container = _renderComponent31.container;
|
|
408
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
409
|
-
});
|
|
410
|
-
it('handles diagonal line', function () {
|
|
411
|
-
var _renderComponent32 = renderComponent({
|
|
412
|
-
mark: {
|
|
413
|
-
root: xy(0, 0),
|
|
414
|
-
edge: xy(5, 5)
|
|
415
|
-
}
|
|
416
|
-
}),
|
|
417
|
-
container = _renderComponent32.container;
|
|
418
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
419
|
-
});
|
|
420
|
-
it('handles negative slope', function () {
|
|
421
|
-
var _renderComponent33 = renderComponent({
|
|
422
|
-
mark: {
|
|
423
|
-
root: xy(0, 5),
|
|
424
|
-
edge: xy(5, 0)
|
|
425
|
-
}
|
|
426
|
-
}),
|
|
427
|
-
container = _renderComponent33.container;
|
|
428
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
429
|
-
});
|
|
430
|
-
});
|
|
431
|
-
});
|
|
432
|
-
describe('withRootEdge', function () {
|
|
433
|
-
var getPoints;
|
|
434
|
-
var Comp;
|
|
435
|
-
beforeEach(function () {
|
|
436
|
-
getPoints = jest.fn(function () {
|
|
437
|
-
return {
|
|
438
|
-
dataPoints: [{
|
|
439
|
-
x: 0,
|
|
440
|
-
y: 0
|
|
441
|
-
}, {
|
|
442
|
-
x: 1,
|
|
443
|
-
y: 1
|
|
444
|
-
}, {
|
|
445
|
-
x: 2,
|
|
446
|
-
y: 4
|
|
447
|
-
}],
|
|
448
|
-
enableCurve: true
|
|
449
|
-
};
|
|
450
|
-
});
|
|
451
|
-
Comp = (0, _withRootEdge.withRootEdge)(getPoints);
|
|
452
|
-
});
|
|
453
|
-
var renderComponent = function renderComponent(extras) {
|
|
454
|
-
var defaults = {
|
|
455
|
-
from: xy(0, 0),
|
|
456
|
-
to: xy(2, 2),
|
|
457
|
-
graphProps: (0, _utils.graphProps)(),
|
|
458
|
-
onChange: jest.fn()
|
|
459
|
-
};
|
|
460
|
-
var props = _objectSpread(_objectSpread({}, defaults), extras);
|
|
461
|
-
return (0, _testUtils.render)(/*#__PURE__*/_react["default"].createElement(Comp, props));
|
|
462
|
-
};
|
|
463
|
-
describe('rendering', function () {
|
|
464
|
-
it('renders without crashing', function () {
|
|
465
|
-
var _renderComponent34 = renderComponent(),
|
|
466
|
-
container = _renderComponent34.container;
|
|
467
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
468
|
-
});
|
|
469
|
-
it('calls getPoints with correct parameters', function () {
|
|
470
|
-
renderComponent();
|
|
471
|
-
expect(getPoints).toHaveBeenCalled();
|
|
472
|
-
});
|
|
473
|
-
it('renders with curve enabled', function () {
|
|
474
|
-
getPoints.mockReturnValue({
|
|
475
|
-
dataPoints: [xy(0, 0), xy(1, 1), xy(2, 2)],
|
|
476
|
-
enableCurve: true
|
|
477
|
-
});
|
|
478
|
-
var _renderComponent35 = renderComponent(),
|
|
479
|
-
container = _renderComponent35.container;
|
|
480
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
481
|
-
});
|
|
482
|
-
it('renders with curve disabled', function () {
|
|
483
|
-
getPoints.mockReturnValue({
|
|
484
|
-
dataPoints: [xy(0, 0), xy(1, 1), xy(2, 2)],
|
|
485
|
-
enableCurve: false
|
|
486
|
-
});
|
|
487
|
-
var _renderComponent36 = renderComponent(),
|
|
488
|
-
container = _renderComponent36.container;
|
|
489
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
490
|
-
});
|
|
491
|
-
});
|
|
492
|
-
describe('data points handling', function () {
|
|
493
|
-
it('handles empty data points', function () {
|
|
494
|
-
getPoints.mockReturnValue({
|
|
495
|
-
dataPoints: [],
|
|
496
|
-
enableCurve: true
|
|
497
|
-
});
|
|
498
|
-
var _renderComponent37 = renderComponent(),
|
|
499
|
-
container = _renderComponent37.container;
|
|
500
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
501
|
-
});
|
|
502
|
-
it('handles single data point', function () {
|
|
503
|
-
getPoints.mockReturnValue({
|
|
504
|
-
dataPoints: [xy(1, 1)],
|
|
505
|
-
enableCurve: true
|
|
506
|
-
});
|
|
507
|
-
var _renderComponent38 = renderComponent(),
|
|
508
|
-
container = _renderComponent38.container;
|
|
509
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
510
|
-
});
|
|
511
|
-
it('handles many data points', function () {
|
|
512
|
-
var points = Array.from({
|
|
513
|
-
length: 100
|
|
514
|
-
}, function (_, i) {
|
|
515
|
-
return xy(i, i * i);
|
|
516
|
-
});
|
|
517
|
-
getPoints.mockReturnValue({
|
|
518
|
-
dataPoints: points,
|
|
519
|
-
enableCurve: true
|
|
520
|
-
});
|
|
521
|
-
var _renderComponent39 = renderComponent(),
|
|
522
|
-
container = _renderComponent39.container;
|
|
523
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
524
|
-
});
|
|
525
|
-
it('handles negative coordinate data points', function () {
|
|
526
|
-
getPoints.mockReturnValue({
|
|
527
|
-
dataPoints: [xy(-5, -5), xy(-3, -3), xy(-1, -1)],
|
|
528
|
-
enableCurve: true
|
|
529
|
-
});
|
|
530
|
-
var _renderComponent40 = renderComponent(),
|
|
531
|
-
container = _renderComponent40.container;
|
|
532
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
533
|
-
});
|
|
534
|
-
});
|
|
535
|
-
describe('prop handling', function () {
|
|
536
|
-
it('forwards onClick handler', function () {
|
|
537
|
-
var onClick = jest.fn();
|
|
538
|
-
var _renderComponent41 = renderComponent({
|
|
539
|
-
onClick: onClick
|
|
540
|
-
}),
|
|
541
|
-
container = _renderComponent41.container;
|
|
542
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
543
|
-
});
|
|
544
|
-
it('forwards onDragStart handler', function () {
|
|
545
|
-
var onDragStart = jest.fn();
|
|
546
|
-
var _renderComponent42 = renderComponent({
|
|
547
|
-
onDragStart: onDragStart
|
|
548
|
-
}),
|
|
549
|
-
container = _renderComponent42.container;
|
|
550
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
551
|
-
});
|
|
552
|
-
it('forwards onDragStop handler', function () {
|
|
553
|
-
var onDragStop = jest.fn();
|
|
554
|
-
var _renderComponent43 = renderComponent({
|
|
555
|
-
onDragStop: onDragStop
|
|
556
|
-
}),
|
|
557
|
-
container = _renderComponent43.container;
|
|
558
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
559
|
-
});
|
|
560
|
-
it('forwards disabled state', function () {
|
|
561
|
-
var _renderComponent44 = renderComponent({
|
|
562
|
-
disabled: true
|
|
563
|
-
}),
|
|
564
|
-
container = _renderComponent44.container;
|
|
565
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
566
|
-
});
|
|
567
|
-
it('forwards correctness state', function () {
|
|
568
|
-
var _renderComponent45 = renderComponent({
|
|
569
|
-
correctness: 'correct'
|
|
570
|
-
}),
|
|
571
|
-
container = _renderComponent45.container;
|
|
572
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
573
|
-
});
|
|
574
|
-
it('forwards custom props', function () {
|
|
575
|
-
var _renderComponent46 = renderComponent({
|
|
576
|
-
fill: '#ff0000',
|
|
577
|
-
strokeWidth: 5
|
|
578
|
-
}),
|
|
579
|
-
container = _renderComponent46.container;
|
|
580
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
581
|
-
});
|
|
582
|
-
});
|
|
583
|
-
describe('edge cases', function () {
|
|
584
|
-
it('handles undefined to point', function () {
|
|
585
|
-
var _renderComponent47 = renderComponent({
|
|
586
|
-
to: undefined
|
|
587
|
-
}),
|
|
588
|
-
container = _renderComponent47.container;
|
|
589
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
590
|
-
});
|
|
591
|
-
it('handles same from and to points', function () {
|
|
592
|
-
var _renderComponent48 = renderComponent({
|
|
593
|
-
from: xy(1, 1),
|
|
594
|
-
to: xy(1, 1)
|
|
595
|
-
}),
|
|
596
|
-
container = _renderComponent48.container;
|
|
597
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
598
|
-
});
|
|
599
|
-
it('handles different graph scales', function () {
|
|
600
|
-
var customGraphProps = (0, _utils.graphProps)(-10, 10, -10, 10);
|
|
601
|
-
var _renderComponent49 = renderComponent({
|
|
602
|
-
graphProps: customGraphProps
|
|
603
|
-
}),
|
|
604
|
-
container = _renderComponent49.container;
|
|
605
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
606
|
-
});
|
|
607
|
-
it('handles getPoints returning enableCurve as undefined', function () {
|
|
608
|
-
getPoints.mockReturnValue({
|
|
609
|
-
dataPoints: [xy(0, 0), xy(1, 1)]
|
|
610
|
-
// enableCurve is undefined
|
|
611
|
-
});
|
|
612
|
-
var _renderComponent50 = renderComponent(),
|
|
613
|
-
container = _renderComponent50.container;
|
|
614
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
615
|
-
});
|
|
616
|
-
});
|
|
617
|
-
});
|
|
618
|
-
//# sourceMappingURL=with-root-edge.test.js.map
|