@pie-lib/graphing-solution-set 3.1.1-next.0 → 3.2.0-next.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.
Files changed (124) hide show
  1. package/lib/axis/arrow.js +0 -3
  2. package/lib/axis/arrow.js.map +1 -1
  3. package/lib/axis/axes.js +0 -16
  4. package/lib/axis/axes.js.map +1 -1
  5. package/lib/axis/index.js +0 -7
  6. package/lib/axis/index.js.map +1 -1
  7. package/lib/bg.js +0 -6
  8. package/lib/bg.js.map +1 -1
  9. package/lib/container/actions.js +0 -1
  10. package/lib/container/actions.js.map +1 -1
  11. package/lib/container/index.js +4 -10
  12. package/lib/container/index.js.map +1 -1
  13. package/lib/container/marks.js +0 -2
  14. package/lib/container/marks.js.map +1 -1
  15. package/lib/container/middleware.js +0 -1
  16. package/lib/container/middleware.js.map +1 -1
  17. package/lib/container/reducer.js +0 -1
  18. package/lib/container/reducer.js.map +1 -1
  19. package/lib/coordinates-label.js +0 -11
  20. package/lib/coordinates-label.js.map +1 -1
  21. package/lib/graph-with-controls.js +3 -22
  22. package/lib/graph-with-controls.js.map +1 -1
  23. package/lib/graph.js +7 -26
  24. package/lib/graph.js.map +1 -1
  25. package/lib/grid-setup.js +0 -11
  26. package/lib/grid-setup.js.map +1 -1
  27. package/lib/grid.js +0 -22
  28. package/lib/grid.js.map +1 -1
  29. package/lib/index.js +0 -7
  30. package/lib/index.js.map +1 -1
  31. package/lib/labels.js +0 -13
  32. package/lib/labels.js.map +1 -1
  33. package/lib/mark-label.js +0 -16
  34. package/lib/mark-label.js.map +1 -1
  35. package/lib/toggle-bar.js +0 -17
  36. package/lib/toggle-bar.js.map +1 -1
  37. package/lib/tool-menu.js +0 -3
  38. package/lib/tool-menu.js.map +1 -1
  39. package/lib/tools/index.js +0 -1
  40. package/lib/tools/index.js.map +1 -1
  41. package/lib/tools/line/component.js +0 -13
  42. package/lib/tools/line/component.js.map +1 -1
  43. package/lib/tools/line/index.js +0 -1
  44. package/lib/tools/line/index.js.map +1 -1
  45. package/lib/tools/polygon/component.js +5 -25
  46. package/lib/tools/polygon/component.js.map +1 -1
  47. package/lib/tools/polygon/index.js +0 -12
  48. package/lib/tools/polygon/index.js.map +1 -1
  49. package/lib/tools/polygon/line.js +0 -16
  50. package/lib/tools/polygon/line.js.map +1 -1
  51. package/lib/tools/polygon/polygon.js +0 -19
  52. package/lib/tools/polygon/polygon.js.map +1 -1
  53. package/lib/tools/shared/arrow-head.js +0 -3
  54. package/lib/tools/shared/arrow-head.js.map +1 -1
  55. package/lib/tools/shared/line/index.js +7 -22
  56. package/lib/tools/shared/line/index.js.map +1 -1
  57. package/lib/tools/shared/line/line-path.js +0 -16
  58. package/lib/tools/shared/line/line-path.js.map +1 -1
  59. package/lib/tools/shared/line/with-root-edge.js +0 -11
  60. package/lib/tools/shared/line/with-root-edge.js.map +1 -1
  61. package/lib/tools/shared/point/arrow-point.js +2 -5
  62. package/lib/tools/shared/point/arrow-point.js.map +1 -1
  63. package/lib/tools/shared/point/arrow.js +0 -3
  64. package/lib/tools/shared/point/arrow.js.map +1 -1
  65. package/lib/tools/shared/point/base-point.js +0 -11
  66. package/lib/tools/shared/point/base-point.js.map +1 -1
  67. package/lib/tools/shared/point/index.js +0 -16
  68. package/lib/tools/shared/point/index.js.map +1 -1
  69. package/lib/tools/shared/styles.js +0 -1
  70. package/lib/tools/shared/styles.js.map +1 -1
  71. package/lib/tools/shared/types.js +0 -1
  72. package/lib/tools/shared/types.js.map +1 -1
  73. package/lib/undo-redo.js +0 -2
  74. package/lib/undo-redo.js.map +1 -1
  75. package/lib/use-debounce.js +0 -2
  76. package/lib/use-debounce.js.map +1 -1
  77. package/lib/utils.js +8 -26
  78. package/lib/utils.js.map +1 -1
  79. package/package.json +14 -11
  80. package/src/__tests__/bg.test.jsx +250 -0
  81. package/src/__tests__/coordinates-label.test.jsx +243 -0
  82. package/src/__tests__/graph-with-controls.test.jsx +9 -10
  83. package/src/__tests__/graph.test.jsx +0 -2
  84. package/src/__tests__/grid-setup.test.jsx +645 -0
  85. package/src/__tests__/mark-label.test.jsx +1 -1
  86. package/src/__tests__/tool-menu.test.jsx +422 -2
  87. package/src/__tests__/use-debounce.test.js +1 -1
  88. package/src/__tests__/utils.test.js +15 -61
  89. package/src/axis/__tests__/axes.test.jsx +1 -1
  90. package/src/axis/axes.jsx +7 -21
  91. package/src/axis/index.js +1 -0
  92. package/src/bg.jsx +1 -1
  93. package/src/container/__tests__/actions.test.js +105 -0
  94. package/src/container/__tests__/index.test.jsx +227 -0
  95. package/src/container/__tests__/marks.test.js +172 -0
  96. package/src/container/__tests__/middleware.test.js +235 -0
  97. package/src/container/__tests__/reducer.test.js +324 -0
  98. package/src/container/index.jsx +3 -4
  99. package/src/coordinates-label.jsx +1 -7
  100. package/src/graph-with-controls.jsx +7 -25
  101. package/src/graph.jsx +3 -4
  102. package/src/grid-setup.jsx +1 -1
  103. package/src/mark-label.jsx +2 -2
  104. package/src/toggle-bar.jsx +8 -1
  105. package/src/tool-menu.jsx +1 -1
  106. package/src/tools/line/__tests__/component.test.jsx +1 -0
  107. package/src/tools/line/component.jsx +2 -2
  108. package/src/tools/polygon/__tests__/component.test.jsx +417 -5
  109. package/src/tools/polygon/__tests__/polygon.test.jsx +1 -1
  110. package/src/tools/polygon/component.jsx +4 -14
  111. package/src/tools/polygon/line.jsx +1 -1
  112. package/src/tools/shared/line/__tests__/index.test.jsx +460 -17
  113. package/src/tools/shared/line/__tests__/line-path.test.jsx +7 -4
  114. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +439 -14
  115. package/src/tools/shared/line/index.jsx +4 -6
  116. package/src/tools/shared/line/line-path.jsx +2 -8
  117. package/src/tools/shared/point/__tests__/arrow.test.jsx +469 -0
  118. package/src/tools/shared/point/arrow-point.jsx +2 -2
  119. package/src/tools/shared/point/base-point.jsx +1 -1
  120. package/src/tools/shared/point/index.jsx +1 -1
  121. package/src/undo-redo.jsx +1 -3
  122. package/src/use-debounce.js +1 -1
  123. package/src/utils.js +1 -5
  124. package/NEXT.CHANGELOG.json +0 -16
@@ -1,26 +1,31 @@
1
1
  import { render } from '@pie-lib/test-utils';
2
2
  import React from 'react';
3
- import { rootEdgeComponent, withRootEdge, rootEdgeToFromToWrapper } from '../with-root-edge';
3
+ import { rootEdgeComponent, rootEdgeToFromToWrapper, withRootEdge } from '../with-root-edge';
4
4
  import { graphProps as getGraphProps } from '../../../../__tests__/utils';
5
5
  import { utils } from '@pie-lib/plot';
6
- import { lineToolComponent, LineToolMockComponent } from '../index';
6
+
7
7
  const { xy } = utils;
8
+
8
9
  jest.mock('../index', () => {
10
+ const React = require('react');
9
11
  const out = {
10
- lineBase: jest.fn().mockReturnValue(() => <div />),
11
- lineToolComponent: jest.fn().mockReturnValue(() => <div />),
12
+ lineBase: jest.fn((Component) => Component),
13
+ lineToolComponent: jest.fn((Component) => {
14
+ return (props) => <Component {...props} />;
15
+ }),
12
16
  };
13
17
  return out;
14
18
  });
15
19
 
16
- // Note: Instance method tests have been removed. Component behavior should be tested
17
- // through user interactions and integration tests.
18
- describe('rootEdgeToToFromWRapper', () => {
20
+ describe('rootEdgeToFromToWrapper', () => {
19
21
  let Comp;
20
- let onChange = jest.fn();
22
+ let onChange;
23
+
21
24
  beforeEach(() => {
22
- Comp = rootEdgeToFromToWrapper(() => <div />);
25
+ onChange = jest.fn();
26
+ Comp = rootEdgeToFromToWrapper((props) => <div data-testid="wrapped-component" {...props} />);
23
27
  });
28
+
24
29
  const renderComponent = (extras) => {
25
30
  const defaults = {
26
31
  mark: { root: xy(1, 1), edge: xy(2, 2) },
@@ -30,34 +35,454 @@ describe('rootEdgeToToFromWRapper', () => {
30
35
  return render(<Comp {...props} />);
31
36
  };
32
37
 
33
- it('renders', () => {
34
- const { container } = renderComponent();
35
- expect(container.firstChild).toBeInTheDocument();
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
+ });
36
179
  });
37
180
  });
38
181
 
39
182
  describe('rootEdgeComponent', () => {
40
- let onChange = jest.fn();
183
+ let onChange;
41
184
  let Comp;
42
185
  let mark;
186
+
43
187
  beforeEach(() => {
188
+ onChange = jest.fn();
44
189
  mark = { root: xy(0, 0), edge: xy(1, 1) };
45
- Comp = rootEdgeComponent(() => <text />);
190
+ Comp = rootEdgeComponent((props) => <text data-testid="root-edge-comp" {...props} />);
46
191
  });
192
+
47
193
  const renderComponent = (extras) => {
48
194
  const defaults = {
49
195
  mark,
50
196
  graphProps: getGraphProps(),
51
197
  onChange,
52
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
+ });
53
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
+ };
54
348
  const props = { ...defaults, ...extras };
55
349
  return render(<Comp {...props} />);
56
350
  };
351
+
57
352
  describe('rendering', () => {
58
353
  it('renders without crashing', () => {
59
354
  const { container } = renderComponent();
60
355
  expect(container.firstChild).toBeInTheDocument();
61
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
+ });
62
487
  });
63
488
  });
@@ -1,15 +1,13 @@
1
1
  import React from 'react';
2
- import isEqual from 'lodash/isEqual';
3
- import cloneDeep from 'lodash/cloneDeep';
2
+ import { cloneDeep, isEmpty, isEqual } from 'lodash-es';
4
3
  import { BasePoint } from '../point';
5
- import { types, utils, gridDraggable, trig } from '@pie-lib/plot';
4
+ import { gridDraggable, trig, types, utils } from '@pie-lib/plot';
6
5
  import PropTypes from 'prop-types';
7
- import { disabled, correct, incorrect, missing } from '../styles';
6
+ import { correct, disabled, incorrect, missing } from '../styles';
8
7
  import ReactDOM from 'react-dom';
9
8
  import MarkLabel from '../../../mark-label';
10
- import isEmpty from 'lodash/isEmpty';
11
9
  import { color } from '@pie-lib/render-ui';
12
- import { getMiddleOfTwoPoints, equalPoints, sameAxes } from '../../../utils';
10
+ import { equalPoints, getMiddleOfTwoPoints, sameAxes } from '../../../utils';
13
11
 
14
12
  export const lineTool = (type, Component) => () => ({
15
13
  type,
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import { types } from '@pie-lib/plot';
5
- import { disabled, correct, incorrect, missing } from '../styles';
5
+ import { correct, disabled, incorrect, missing } from '../styles';
6
6
  import * as vx from '@visx/shape';
7
7
  import { color } from '@pie-lib/render-ui';
8
8
 
@@ -68,13 +68,7 @@ export class RawLinePath extends React.Component {
68
68
 
69
69
  return (
70
70
  <React.Fragment>
71
- <StyledDrawLine
72
- data={data}
73
- disabled={disabled}
74
- correctness={correctness}
75
- className={className}
76
- {...rest}
77
- />
71
+ <StyledDrawLine data={data} disabled={disabled} correctness={correctness} className={className} {...rest} />
78
72
  <StyledInteractionLine
79
73
  data={data}
80
74
  isDragging={isDragging}