@pie-lib/graphing-solution-set 4.1.0-beta.7 → 4.1.0-beta.9

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 (100) hide show
  1. package/package.json +3 -3
  2. package/lib/__tests__/bg.test.js +0 -282
  3. package/lib/__tests__/bg.test.js.map +0 -1
  4. package/lib/__tests__/coordinates-label.test.js +0 -276
  5. package/lib/__tests__/coordinates-label.test.js.map +0 -1
  6. package/lib/__tests__/graph-with-controls.test.js +0 -256
  7. package/lib/__tests__/graph-with-controls.test.js.map +0 -1
  8. package/lib/__tests__/graph.test.js +0 -113
  9. package/lib/__tests__/graph.test.js.map +0 -1
  10. package/lib/__tests__/grid-setup.test.js +0 -729
  11. package/lib/__tests__/grid-setup.test.js.map +0 -1
  12. package/lib/__tests__/grid.test.js +0 -29
  13. package/lib/__tests__/grid.test.js.map +0 -1
  14. package/lib/__tests__/labels.test.js +0 -45
  15. package/lib/__tests__/labels.test.js.map +0 -1
  16. package/lib/__tests__/mark-label.test.js +0 -133
  17. package/lib/__tests__/mark-label.test.js.map +0 -1
  18. package/lib/__tests__/toggle-bar.test.js +0 -146
  19. package/lib/__tests__/toggle-bar.test.js.map +0 -1
  20. package/lib/__tests__/tool-menu.test.js +0 -540
  21. package/lib/__tests__/tool-menu.test.js.map +0 -1
  22. package/lib/__tests__/undo-redo.test.js +0 -31
  23. package/lib/__tests__/undo-redo.test.js.map +0 -1
  24. package/lib/__tests__/use-debounce.test.js +0 -24
  25. package/lib/__tests__/use-debounce.test.js.map +0 -1
  26. package/lib/__tests__/utils.js +0 -70
  27. package/lib/__tests__/utils.js.map +0 -1
  28. package/lib/__tests__/utils.test.js +0 -123
  29. package/lib/__tests__/utils.test.js.map +0 -1
  30. package/lib/axis/__tests__/arrow.test.js +0 -60
  31. package/lib/axis/__tests__/arrow.test.js.map +0 -1
  32. package/lib/axis/__tests__/axes.test.js +0 -160
  33. package/lib/axis/__tests__/axes.test.js.map +0 -1
  34. package/lib/container/__tests__/actions.test.js +0 -108
  35. package/lib/container/__tests__/actions.test.js.map +0 -1
  36. package/lib/container/__tests__/index.test.js +0 -346
  37. package/lib/container/__tests__/index.test.js.map +0 -1
  38. package/lib/container/__tests__/marks.test.js +0 -259
  39. package/lib/container/__tests__/marks.test.js.map +0 -1
  40. package/lib/container/__tests__/middleware.test.js +0 -244
  41. package/lib/container/__tests__/middleware.test.js.map +0 -1
  42. package/lib/container/__tests__/reducer.test.js +0 -450
  43. package/lib/container/__tests__/reducer.test.js.map +0 -1
  44. package/lib/tools/line/__tests__/component.test.js +0 -45
  45. package/lib/tools/line/__tests__/component.test.js.map +0 -1
  46. package/lib/tools/polygon/__tests__/component.test.js +0 -501
  47. package/lib/tools/polygon/__tests__/component.test.js.map +0 -1
  48. package/lib/tools/polygon/__tests__/index.test.js +0 -92
  49. package/lib/tools/polygon/__tests__/index.test.js.map +0 -1
  50. package/lib/tools/polygon/__tests__/line.test.js +0 -30
  51. package/lib/tools/polygon/__tests__/line.test.js.map +0 -1
  52. package/lib/tools/polygon/__tests__/polygon.test.js +0 -61
  53. package/lib/tools/polygon/__tests__/polygon.test.js.map +0 -1
  54. package/lib/tools/shared/__tests__/arrow-head.test.js +0 -45
  55. package/lib/tools/shared/__tests__/arrow-head.test.js.map +0 -1
  56. package/lib/tools/shared/line/__tests__/index.test.js +0 -725
  57. package/lib/tools/shared/line/__tests__/index.test.js.map +0 -1
  58. package/lib/tools/shared/line/__tests__/line-path.test.js +0 -64
  59. package/lib/tools/shared/line/__tests__/line-path.test.js.map +0 -1
  60. package/lib/tools/shared/line/__tests__/with-root-edge.test.js +0 -618
  61. package/lib/tools/shared/line/__tests__/with-root-edge.test.js.map +0 -1
  62. package/lib/tools/shared/point/__tests__/arrow-point.test.js +0 -127
  63. package/lib/tools/shared/point/__tests__/arrow-point.test.js.map +0 -1
  64. package/lib/tools/shared/point/__tests__/arrow.test.js +0 -619
  65. package/lib/tools/shared/point/__tests__/arrow.test.js.map +0 -1
  66. package/lib/tools/shared/point/__tests__/base-point.test.js +0 -122
  67. package/lib/tools/shared/point/__tests__/base-point.test.js.map +0 -1
  68. package/src/__tests__/bg.test.jsx +0 -250
  69. package/src/__tests__/coordinates-label.test.jsx +0 -243
  70. package/src/__tests__/graph-with-controls.test.jsx +0 -184
  71. package/src/__tests__/graph.test.jsx +0 -93
  72. package/src/__tests__/grid-setup.test.jsx +0 -645
  73. package/src/__tests__/grid.test.jsx +0 -23
  74. package/src/__tests__/labels.test.jsx +0 -41
  75. package/src/__tests__/mark-label.test.jsx +0 -66
  76. package/src/__tests__/toggle-bar.test.jsx +0 -106
  77. package/src/__tests__/tool-menu.test.jsx +0 -453
  78. package/src/__tests__/undo-redo.test.jsx +0 -26
  79. package/src/__tests__/use-debounce.test.js +0 -21
  80. package/src/__tests__/utils.js +0 -41
  81. package/src/__tests__/utils.test.js +0 -105
  82. package/src/axis/__tests__/arrow.test.jsx +0 -43
  83. package/src/axis/__tests__/axes.test.jsx +0 -182
  84. package/src/container/__tests__/actions.test.js +0 -105
  85. package/src/container/__tests__/index.test.jsx +0 -227
  86. package/src/container/__tests__/marks.test.js +0 -172
  87. package/src/container/__tests__/middleware.test.js +0 -235
  88. package/src/container/__tests__/reducer.test.js +0 -324
  89. package/src/tools/line/__tests__/component.test.jsx +0 -37
  90. package/src/tools/polygon/__tests__/component.test.jsx +0 -487
  91. package/src/tools/polygon/__tests__/index.test.js +0 -65
  92. package/src/tools/polygon/__tests__/line.test.jsx +0 -23
  93. package/src/tools/polygon/__tests__/polygon.test.jsx +0 -44
  94. package/src/tools/shared/__tests__/arrow-head.test.jsx +0 -33
  95. package/src/tools/shared/line/__tests__/index.test.jsx +0 -553
  96. package/src/tools/shared/line/__tests__/line-path.test.jsx +0 -56
  97. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +0 -488
  98. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +0 -91
  99. package/src/tools/shared/point/__tests__/arrow.test.jsx +0 -469
  100. package/src/tools/shared/point/__tests__/base-point.test.jsx +0 -87
@@ -1,488 +0,0 @@
1
- import { render } from '@pie-lib/test-utils';
2
- import React from 'react';
3
- import { rootEdgeComponent, rootEdgeToFromToWrapper, withRootEdge } from '../with-root-edge';
4
- import { graphProps as getGraphProps } from '../../../../__tests__/utils';
5
- import { utils } from '@pie-lib/plot';
6
-
7
- const { xy } = utils;
8
-
9
- jest.mock('../index', () => {
10
- const React = require('react');
11
- const out = {
12
- lineBase: jest.fn((Component) => Component),
13
- lineToolComponent: jest.fn((Component) => {
14
- return (props) => <Component {...props} />;
15
- }),
16
- };
17
- return out;
18
- });
19
-
20
- describe('rootEdgeToFromToWrapper', () => {
21
- let Comp;
22
- let onChange;
23
-
24
- beforeEach(() => {
25
- onChange = jest.fn();
26
- Comp = rootEdgeToFromToWrapper((props) => <div data-testid="wrapped-component" {...props} />);
27
- });
28
-
29
- const renderComponent = (extras) => {
30
- const defaults = {
31
- mark: { root: xy(1, 1), edge: xy(2, 2) },
32
- onChange,
33
- };
34
- const props = { ...defaults, ...extras };
35
- return render(<Comp {...props} />);
36
- };
37
-
38
- describe('rendering', () => {
39
- it('renders without crashing', () => {
40
- const { container } = renderComponent();
41
- expect(container.firstChild).toBeInTheDocument();
42
- });
43
-
44
- it('renders with only root point', () => {
45
- const { container } = renderComponent({
46
- mark: { root: xy(1, 1) },
47
- });
48
- expect(container.firstChild).toBeInTheDocument();
49
- });
50
-
51
- it('renders with root and edge points', () => {
52
- const { container } = renderComponent({
53
- mark: { root: xy(0, 0), edge: xy(5, 5) },
54
- });
55
- expect(container.firstChild).toBeInTheDocument();
56
- });
57
-
58
- it('renders with negative coordinates', () => {
59
- const { container } = renderComponent({
60
- mark: { root: xy(-5, -5), edge: xy(-1, -1) },
61
- });
62
- expect(container.firstChild).toBeInTheDocument();
63
- });
64
-
65
- it('renders with decimal coordinates', () => {
66
- const { container } = renderComponent({
67
- mark: { root: xy(0.5, 0.5), edge: xy(1.5, 1.5) },
68
- });
69
- expect(container.firstChild).toBeInTheDocument();
70
- });
71
- });
72
-
73
- describe('coordinate transformation', () => {
74
- it('converts root/edge to from/to for wrapped component', () => {
75
- const { getByTestId } = renderComponent({
76
- mark: { root: xy(1, 1), edge: xy(2, 2) },
77
- });
78
-
79
- const wrappedComponent = getByTestId('wrapped-component');
80
- expect(wrappedComponent).toBeInTheDocument();
81
- });
82
-
83
- it('handles mark without edge', () => {
84
- const { container } = renderComponent({
85
- mark: { root: xy(1, 1) },
86
- });
87
- expect(container.firstChild).toBeInTheDocument();
88
- });
89
-
90
- it('handles mark with undefined edge', () => {
91
- const { container } = renderComponent({
92
- mark: { root: xy(1, 1), edge: undefined },
93
- });
94
- expect(container.firstChild).toBeInTheDocument();
95
- });
96
- });
97
-
98
- describe('onChange handling', () => {
99
- it('passes onChange handler to wrapped component', () => {
100
- const { container } = renderComponent();
101
- expect(container.firstChild).toBeInTheDocument();
102
- expect(onChange).not.toHaveBeenCalled();
103
- });
104
-
105
- it('provides onChange prop to wrapped component', () => {
106
- const { getByTestId } = renderComponent();
107
- const wrappedComponent = getByTestId('wrapped-component');
108
- expect(wrappedComponent).toBeInTheDocument();
109
- });
110
- });
111
-
112
- describe('prop forwarding', () => {
113
- it('forwards additional props to wrapped component', () => {
114
- const { getByTestId } = renderComponent({
115
- disabled: true,
116
- correctness: 'correct',
117
- });
118
-
119
- const wrappedComponent = getByTestId('wrapped-component');
120
- expect(wrappedComponent).toBeInTheDocument();
121
- });
122
-
123
- it('forwards graphProps', () => {
124
- const graphProps = getGraphProps();
125
- const { getByTestId } = renderComponent({
126
- graphProps,
127
- });
128
-
129
- const wrappedComponent = getByTestId('wrapped-component');
130
- expect(wrappedComponent).toBeInTheDocument();
131
- });
132
-
133
- it('forwards all standard props', () => {
134
- const { getByTestId } = renderComponent({
135
- disabled: false,
136
- correctness: 'incorrect',
137
- fill: '#ff0000',
138
- onClick: jest.fn(),
139
- onDragStart: jest.fn(),
140
- onDragStop: jest.fn(),
141
- });
142
-
143
- const wrappedComponent = getByTestId('wrapped-component');
144
- expect(wrappedComponent).toBeInTheDocument();
145
- });
146
- });
147
-
148
- describe('edge cases', () => {
149
- it('handles mark with same root and edge', () => {
150
- const { container } = renderComponent({
151
- mark: { root: xy(1, 1), edge: xy(1, 1) },
152
- });
153
- expect(container.firstChild).toBeInTheDocument();
154
- });
155
-
156
- it('handles mark with zero coordinates', () => {
157
- const { container } = renderComponent({
158
- mark: { root: xy(0, 0), edge: xy(0, 0) },
159
- });
160
- expect(container.firstChild).toBeInTheDocument();
161
- });
162
-
163
- it('handles mark with large coordinate values', () => {
164
- const { container } = renderComponent({
165
- mark: { root: xy(1000, 1000), edge: xy(2000, 2000) },
166
- });
167
- expect(container.firstChild).toBeInTheDocument();
168
- });
169
-
170
- it('handles mark with labels', () => {
171
- const { container } = renderComponent({
172
- mark: {
173
- root: { x: 1, y: 1, label: 'Root' },
174
- edge: { x: 2, y: 2, label: 'Edge' },
175
- },
176
- });
177
- expect(container.firstChild).toBeInTheDocument();
178
- });
179
- });
180
- });
181
-
182
- describe('rootEdgeComponent', () => {
183
- let onChange;
184
- let Comp;
185
- let mark;
186
-
187
- beforeEach(() => {
188
- onChange = jest.fn();
189
- mark = { root: xy(0, 0), edge: xy(1, 1) };
190
- Comp = rootEdgeComponent((props) => <text data-testid="root-edge-comp" {...props} />);
191
- });
192
-
193
- const renderComponent = (extras) => {
194
- const defaults = {
195
- mark,
196
- graphProps: getGraphProps(),
197
- onChange,
198
- };
199
- const props = { ...defaults, ...extras };
200
- return render(<Comp {...props} />);
201
- };
202
-
203
- describe('rendering', () => {
204
- it('renders without crashing', () => {
205
- const { container } = renderComponent();
206
- expect(container.firstChild).toBeInTheDocument();
207
- });
208
-
209
- it('renders with building mark', () => {
210
- const buildingMark = { root: xy(0, 0), building: true };
211
- const { container } = renderComponent({ mark: buildingMark });
212
- expect(container.firstChild).toBeInTheDocument();
213
- });
214
-
215
- it('renders with complete mark', () => {
216
- const completeMark = { root: xy(0, 0), edge: xy(5, 5), building: false };
217
- const { container } = renderComponent({ mark: completeMark });
218
- expect(container.firstChild).toBeInTheDocument();
219
- });
220
-
221
- it('renders with disabled mark', () => {
222
- const disabledMark = { root: xy(0, 0), edge: xy(1, 1), disabled: true };
223
- const { container } = renderComponent({ mark: disabledMark });
224
- expect(container.firstChild).toBeInTheDocument();
225
- });
226
-
227
- it('renders with correctness state', () => {
228
- const correctMark = { root: xy(0, 0), edge: xy(1, 1), correctness: 'correct' };
229
- const { container } = renderComponent({ mark: correctMark });
230
- expect(container.firstChild).toBeInTheDocument();
231
- });
232
- });
233
-
234
- describe('mark variations', () => {
235
- it('handles mark without edge', () => {
236
- const { container } = renderComponent({
237
- mark: { root: xy(1, 1) },
238
- });
239
- expect(container.firstChild).toBeInTheDocument();
240
- });
241
-
242
- it('handles mark with middle point', () => {
243
- const { container } = renderComponent({
244
- mark: { root: xy(0, 0), edge: xy(2, 2), middle: xy(1, 1) },
245
- });
246
- expect(container.firstChild).toBeInTheDocument();
247
- });
248
-
249
- it('handles mark with custom fill', () => {
250
- const { container } = renderComponent({
251
- mark: { root: xy(0, 0), edge: xy(1, 1), fill: '#00ff00' },
252
- });
253
- expect(container.firstChild).toBeInTheDocument();
254
- });
255
-
256
- it('handles mark with type property', () => {
257
- const { container } = renderComponent({
258
- mark: { root: xy(0, 0), edge: xy(1, 1), type: 'parabola' },
259
- });
260
- expect(container.firstChild).toBeInTheDocument();
261
- });
262
- });
263
-
264
- describe('prop forwarding', () => {
265
- it('forwards graphProps correctly', () => {
266
- const customGraphProps = getGraphProps(0, 10, 0, 10);
267
- const { container } = renderComponent({ graphProps: customGraphProps });
268
- expect(container.firstChild).toBeInTheDocument();
269
- });
270
-
271
- it('forwards onClick handler', () => {
272
- const onClick = jest.fn();
273
- const { container } = renderComponent({ onClick });
274
- expect(container.firstChild).toBeInTheDocument();
275
- });
276
-
277
- it('forwards labelNode', () => {
278
- const labelNode = document.createElement('foreignObject');
279
- const { container } = renderComponent({ labelNode });
280
- expect(container.firstChild).toBeInTheDocument();
281
- });
282
-
283
- it('forwards labelModeEnabled', () => {
284
- const { container } = renderComponent({ labelModeEnabled: true });
285
- expect(container.firstChild).toBeInTheDocument();
286
- });
287
-
288
- it('forwards coordinatesOnHover', () => {
289
- const { container } = renderComponent({ coordinatesOnHover: true });
290
- expect(container.firstChild).toBeInTheDocument();
291
- });
292
- });
293
-
294
- describe('edge cases', () => {
295
- it('handles vertical line (same x coordinates)', () => {
296
- const { container } = renderComponent({
297
- mark: { root: xy(1, 0), edge: xy(1, 5) },
298
- });
299
- expect(container.firstChild).toBeInTheDocument();
300
- });
301
-
302
- it('handles horizontal line (same y coordinates)', () => {
303
- const { container } = renderComponent({
304
- mark: { root: xy(0, 1), edge: xy(5, 1) },
305
- });
306
- expect(container.firstChild).toBeInTheDocument();
307
- });
308
-
309
- it('handles diagonal line', () => {
310
- const { container } = renderComponent({
311
- mark: { root: xy(0, 0), edge: xy(5, 5) },
312
- });
313
- expect(container.firstChild).toBeInTheDocument();
314
- });
315
-
316
- it('handles negative slope', () => {
317
- const { container } = renderComponent({
318
- mark: { root: xy(0, 5), edge: xy(5, 0) },
319
- });
320
- expect(container.firstChild).toBeInTheDocument();
321
- });
322
- });
323
- });
324
-
325
- describe('withRootEdge', () => {
326
- let getPoints;
327
- let Comp;
328
-
329
- beforeEach(() => {
330
- getPoints = jest.fn(() => ({
331
- dataPoints: [
332
- { x: 0, y: 0 },
333
- { x: 1, y: 1 },
334
- { x: 2, y: 4 },
335
- ],
336
- enableCurve: true,
337
- }));
338
- Comp = withRootEdge(getPoints);
339
- });
340
-
341
- const renderComponent = (extras) => {
342
- const defaults = {
343
- from: xy(0, 0),
344
- to: xy(2, 2),
345
- graphProps: getGraphProps(),
346
- onChange: jest.fn(),
347
- };
348
- const props = { ...defaults, ...extras };
349
- return render(<Comp {...props} />);
350
- };
351
-
352
- describe('rendering', () => {
353
- it('renders without crashing', () => {
354
- const { container } = renderComponent();
355
- expect(container.firstChild).toBeInTheDocument();
356
- });
357
-
358
- it('calls getPoints with correct parameters', () => {
359
- renderComponent();
360
- expect(getPoints).toHaveBeenCalled();
361
- });
362
-
363
- it('renders with curve enabled', () => {
364
- getPoints.mockReturnValue({
365
- dataPoints: [xy(0, 0), xy(1, 1), xy(2, 2)],
366
- enableCurve: true,
367
- });
368
- const { container } = renderComponent();
369
- expect(container.firstChild).toBeInTheDocument();
370
- });
371
-
372
- it('renders with curve disabled', () => {
373
- getPoints.mockReturnValue({
374
- dataPoints: [xy(0, 0), xy(1, 1), xy(2, 2)],
375
- enableCurve: false,
376
- });
377
- const { container } = renderComponent();
378
- expect(container.firstChild).toBeInTheDocument();
379
- });
380
- });
381
-
382
- describe('data points handling', () => {
383
- it('handles empty data points', () => {
384
- getPoints.mockReturnValue({
385
- dataPoints: [],
386
- enableCurve: true,
387
- });
388
- const { container } = renderComponent();
389
- expect(container.firstChild).toBeInTheDocument();
390
- });
391
-
392
- it('handles single data point', () => {
393
- getPoints.mockReturnValue({
394
- dataPoints: [xy(1, 1)],
395
- enableCurve: true,
396
- });
397
- const { container } = renderComponent();
398
- expect(container.firstChild).toBeInTheDocument();
399
- });
400
-
401
- it('handles many data points', () => {
402
- const points = Array.from({ length: 100 }, (_, i) => xy(i, i * i));
403
- getPoints.mockReturnValue({
404
- dataPoints: points,
405
- enableCurve: true,
406
- });
407
- const { container } = renderComponent();
408
- expect(container.firstChild).toBeInTheDocument();
409
- });
410
-
411
- it('handles negative coordinate data points', () => {
412
- getPoints.mockReturnValue({
413
- dataPoints: [xy(-5, -5), xy(-3, -3), xy(-1, -1)],
414
- enableCurve: true,
415
- });
416
- const { container } = renderComponent();
417
- expect(container.firstChild).toBeInTheDocument();
418
- });
419
- });
420
-
421
- describe('prop handling', () => {
422
- it('forwards onClick handler', () => {
423
- const onClick = jest.fn();
424
- const { container } = renderComponent({ onClick });
425
- expect(container.firstChild).toBeInTheDocument();
426
- });
427
-
428
- it('forwards onDragStart handler', () => {
429
- const onDragStart = jest.fn();
430
- const { container } = renderComponent({ onDragStart });
431
- expect(container.firstChild).toBeInTheDocument();
432
- });
433
-
434
- it('forwards onDragStop handler', () => {
435
- const onDragStop = jest.fn();
436
- const { container } = renderComponent({ onDragStop });
437
- expect(container.firstChild).toBeInTheDocument();
438
- });
439
-
440
- it('forwards disabled state', () => {
441
- const { container } = renderComponent({ disabled: true });
442
- expect(container.firstChild).toBeInTheDocument();
443
- });
444
-
445
- it('forwards correctness state', () => {
446
- const { container } = renderComponent({ correctness: 'correct' });
447
- expect(container.firstChild).toBeInTheDocument();
448
- });
449
-
450
- it('forwards custom props', () => {
451
- const { container } = renderComponent({
452
- fill: '#ff0000',
453
- strokeWidth: 5,
454
- });
455
- expect(container.firstChild).toBeInTheDocument();
456
- });
457
- });
458
-
459
- describe('edge cases', () => {
460
- it('handles undefined to point', () => {
461
- const { container } = renderComponent({ to: undefined });
462
- expect(container.firstChild).toBeInTheDocument();
463
- });
464
-
465
- it('handles same from and to points', () => {
466
- const { container } = renderComponent({
467
- from: xy(1, 1),
468
- to: xy(1, 1),
469
- });
470
- expect(container.firstChild).toBeInTheDocument();
471
- });
472
-
473
- it('handles different graph scales', () => {
474
- const customGraphProps = getGraphProps(-10, 10, -10, 10);
475
- const { container } = renderComponent({ graphProps: customGraphProps });
476
- expect(container.firstChild).toBeInTheDocument();
477
- });
478
-
479
- it('handles getPoints returning enableCurve as undefined', () => {
480
- getPoints.mockReturnValue({
481
- dataPoints: [xy(0, 0), xy(1, 1)],
482
- // enableCurve is undefined
483
- });
484
- const { container } = renderComponent();
485
- expect(container.firstChild).toBeInTheDocument();
486
- });
487
- });
488
- });
@@ -1,91 +0,0 @@
1
- import { render } from '@pie-lib/test-utils';
2
- import React from 'react';
3
- import { ArrowPoint } from '../index';
4
- import { graphProps } from '../../../../__tests__/utils';
5
- import { bounds } from '../../../../utils';
6
- import { gridDraggable, utils } from '@pie-lib/plot';
7
-
8
- const { xy } = utils;
9
- jest.mock('../../../../utils', () => {
10
- const { point, getAngleDeg, arrowDimensions } = jest.requireActual('../../../../utils');
11
- return {
12
- bounds: jest.fn(),
13
- point,
14
- getAngleDeg,
15
- arrowDimensions,
16
- };
17
- });
18
-
19
- jest.mock('@pie-lib/plot', () => {
20
- const { types, utils } = jest.requireActual('@pie-lib/plot');
21
- return {
22
- gridDraggable: jest.fn((opts) => (Comp) => Comp),
23
- types,
24
- utils,
25
- };
26
- });
27
-
28
- describe('ArrowPoint', () => {
29
- let onChange = jest.fn();
30
-
31
- const renderComponent = (extras) => {
32
- const defaults = {
33
- classes: {},
34
- className: 'className',
35
- onChange,
36
- graphProps: graphProps(),
37
- from: xy(0, 0),
38
- to: xy(1, 1),
39
- x: 0,
40
- y: 0,
41
- };
42
- const props = { ...defaults, ...extras };
43
- return render(<ArrowPoint {...props} />);
44
- };
45
-
46
- describe('rendering', () => {
47
- it('renders without crashing', () => {
48
- const { container } = renderComponent();
49
- expect(container.firstChild).toBeInTheDocument();
50
- });
51
- });
52
- describe('gridDraggable options', () => {
53
- let opts;
54
- let domain;
55
- let range;
56
- beforeEach(() => {
57
- domain = {
58
- min: 0,
59
- max: 1,
60
- step: 1,
61
- };
62
- range = {
63
- min: 0,
64
- max: 1,
65
- step: 1,
66
- };
67
- renderComponent();
68
- opts = gridDraggable.mock.calls[gridDraggable.mock.calls.length - 1][0];
69
- });
70
-
71
- describe('bounds', () => {
72
- it('calls utils.bounds with area', () => {
73
- const result = opts.bounds({ x: 0, y: 0 }, { domain, range });
74
- expect(bounds).toHaveBeenCalledWith({ left: 0, top: 0, bottom: 0, right: 0 }, domain, range);
75
- });
76
- });
77
- describe('anchorPoint', () => {
78
- it('returns x/y', () => {
79
- const result = opts.anchorPoint({ x: 0, y: 0 });
80
- expect(result).toEqual({ x: 0, y: 0 });
81
- });
82
- });
83
-
84
- describe('fromDelta', () => {
85
- it('returns a new point from the x/y + delta', () => {
86
- const result = opts.fromDelta({ x: -1, y: 0 }, { x: 1, y: 3 });
87
- expect(result).toEqual({ x: 0, y: 3 });
88
- });
89
- });
90
- });
91
- });