@pie-lib/graphing 4.0.23 → 4.0.24-beta.2

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 (66) hide show
  1. package/CHANGELOG.md +0 -92
  2. package/lib/mark-label.js +7 -197
  3. package/lib/mark-label.js.map +1 -1
  4. package/lib/tools/circle/component.js +3 -34
  5. package/lib/tools/circle/component.js.map +1 -1
  6. package/lib/tools/point/component.js +8 -29
  7. package/lib/tools/point/component.js.map +1 -1
  8. package/lib/tools/polygon/component.js +6 -31
  9. package/lib/tools/polygon/component.js.map +1 -1
  10. package/lib/tools/shared/line/index.js +3 -34
  11. package/lib/tools/shared/line/index.js.map +1 -1
  12. package/package.json +17 -17
  13. package/src/mark-label.jsx +8 -209
  14. package/src/tools/circle/component.jsx +3 -26
  15. package/src/tools/point/component.jsx +8 -21
  16. package/src/tools/polygon/component.jsx +6 -24
  17. package/src/tools/shared/line/index.jsx +3 -26
  18. package/LICENSE.md +0 -5
  19. package/src/__tests__/bg.test.jsx +0 -250
  20. package/src/__tests__/coordinates-label.test.jsx +0 -243
  21. package/src/__tests__/graph-with-controls.test.jsx +0 -198
  22. package/src/__tests__/graph.test.jsx +0 -796
  23. package/src/__tests__/grid-setup.test.jsx +0 -645
  24. package/src/__tests__/grid.test.jsx +0 -22
  25. package/src/__tests__/key-legend.test.jsx +0 -260
  26. package/src/__tests__/label-svg-icon.test.jsx +0 -278
  27. package/src/__tests__/labels.test.jsx +0 -55
  28. package/src/__tests__/mark-label.test.jsx +0 -437
  29. package/src/__tests__/toggle-bar.test.jsx +0 -146
  30. package/src/__tests__/tool-menu.test.jsx +0 -115
  31. package/src/__tests__/undo-redo.test.jsx +0 -24
  32. package/src/__tests__/use-debounce.test.js +0 -21
  33. package/src/__tests__/utils.js +0 -41
  34. package/src/__tests__/utils.test.js +0 -105
  35. package/src/axis/__tests__/arrow.test.jsx +0 -38
  36. package/src/axis/__tests__/axes.test.jsx +0 -216
  37. package/src/container/__tests__/actions.test.js +0 -105
  38. package/src/container/__tests__/index.test.jsx +0 -319
  39. package/src/container/__tests__/marks.test.js +0 -172
  40. package/src/container/__tests__/middleware.test.js +0 -235
  41. package/src/container/__tests__/reducer.test.js +0 -324
  42. package/src/tools/absolute/__tests__/component.test.jsx +0 -53
  43. package/src/tools/circle/__tests__/bg-circle.test.jsx +0 -26
  44. package/src/tools/circle/__tests__/component.test.jsx +0 -494
  45. package/src/tools/circle/__tests__/index.test.js +0 -480
  46. package/src/tools/exponential/__tests__/component.test.jsx +0 -53
  47. package/src/tools/exponential/__tests__/index.test.js +0 -729
  48. package/src/tools/line/__tests__/component.test.jsx +0 -37
  49. package/src/tools/parabola/__tests__/component.test.jsx +0 -48
  50. package/src/tools/parabola/__tests__/index.test.js +0 -470
  51. package/src/tools/point/__tests__/component.test.jsx +0 -475
  52. package/src/tools/point/__tests__/index.test.js +0 -241
  53. package/src/tools/polygon/__tests__/component.test.jsx +0 -471
  54. package/src/tools/polygon/__tests__/index.test.js +0 -294
  55. package/src/tools/polygon/__tests__/line.test.jsx +0 -35
  56. package/src/tools/polygon/__tests__/polygon.test.jsx +0 -61
  57. package/src/tools/ray/__tests__/component.test.jsx +0 -29
  58. package/src/tools/segment/__tests__/component.test.jsx +0 -28
  59. package/src/tools/shared/__tests__/arrow-head.test.jsx +0 -31
  60. package/src/tools/shared/line/__tests__/index.test.jsx +0 -109
  61. package/src/tools/shared/line/__tests__/line-path.test.jsx +0 -53
  62. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +0 -73
  63. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +0 -91
  64. package/src/tools/shared/point/__tests__/base-point.test.jsx +0 -87
  65. package/src/tools/sine/__tests__/component.test.jsx +0 -51
  66. package/src/tools/vector/__tests__/component.test.jsx +0 -25
@@ -1,494 +0,0 @@
1
- import { render } from '@pie-lib/test-utils';
2
- import React from 'react';
3
- import { graphProps, xy } from '../../../__tests__/utils';
4
-
5
- import { RawBaseCircle } from '../component';
6
-
7
- describe('Component', () => {
8
- let onChange = jest.fn();
9
- let changeMarkProps = jest.fn();
10
-
11
- const renderComponent = (extras) => {
12
- const defaults = {
13
- classes: {},
14
- className: 'className',
15
- onChange,
16
- changeMarkProps,
17
- graphProps: graphProps(),
18
- from: xy(0, 0),
19
- to: xy(1, 1),
20
- };
21
- const props = { ...defaults, ...extras };
22
-
23
- return render(<RawBaseCircle {...props} />);
24
- };
25
-
26
- // used to test items that have labels attached to points
27
- const labelNode = document.createElement('foreignObject');
28
- const fromWithLabel = { x: 0, y: 0, label: 'A' };
29
- const toWithLabel = { x: 1, y: 1, label: 'B' };
30
- const renderWithLabels = (extras = {}) =>
31
- renderComponent({
32
- ...extras,
33
- labelNode: labelNode,
34
- from: fromWithLabel,
35
- to: toWithLabel,
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 labels', () => {
45
- const { container } = renderWithLabels();
46
- expect(container.firstChild).toBeInTheDocument();
47
- });
48
-
49
- it('renders a g element', () => {
50
- const { container } = renderComponent();
51
- const g = container.querySelector('g');
52
- expect(g).toBeInTheDocument();
53
- });
54
-
55
- it('renders BgCircle component', () => {
56
- const { container } = renderComponent();
57
- // BgCircle is rendered as a styled component
58
- expect(container.querySelector('g')).toBeInTheDocument();
59
- });
60
-
61
- it('renders two BasePoint components', () => {
62
- const { container } = renderComponent();
63
- // Two points: from and to
64
- const points = container.querySelectorAll('g');
65
- expect(points.length).toBeGreaterThanOrEqual(2);
66
- });
67
-
68
- it('renders with building prop', () => {
69
- const { container } = renderComponent({ building: true });
70
- expect(container.firstChild).toBeInTheDocument();
71
- });
72
-
73
- it('renders with disabled prop', () => {
74
- const { container } = renderComponent({ disabled: true });
75
- expect(container.firstChild).toBeInTheDocument();
76
- });
77
-
78
- it('renders with correctness prop', () => {
79
- const { container } = renderComponent({ correctness: 'correct' });
80
- expect(container.firstChild).toBeInTheDocument();
81
- });
82
-
83
- it('renders with coordinatesOnHover enabled', () => {
84
- const { container } = renderComponent({ coordinatesOnHover: true });
85
- expect(container.firstChild).toBeInTheDocument();
86
- });
87
-
88
- it('renders with labelModeEnabled', () => {
89
- const { container } = renderComponent({ labelModeEnabled: true });
90
- expect(container.firstChild).toBeInTheDocument();
91
- });
92
-
93
- it('renders with middle point', () => {
94
- const middle = { x: 0.5, y: 0.5, label: 'M' };
95
- const { container } = renderComponent({
96
- middle,
97
- labelNode,
98
- labelModeEnabled: true,
99
- });
100
- expect(container.firstChild).toBeInTheDocument();
101
- });
102
-
103
- it('handles undefined to point (uses from)', () => {
104
- const { container } = renderComponent({ to: undefined });
105
- expect(container.firstChild).toBeInTheDocument();
106
- });
107
-
108
- it('handles null to point (uses from)', () => {
109
- const { container } = renderComponent({ to: null });
110
- expect(container.firstChild).toBeInTheDocument();
111
- });
112
- });
113
-
114
- describe('props', () => {
115
- it('passes onChange callback', () => {
116
- const customOnChange = jest.fn();
117
- const { container } = renderComponent({ onChange: customOnChange });
118
- expect(container.firstChild).toBeInTheDocument();
119
- });
120
-
121
- it('passes changeMarkProps callback', () => {
122
- const customChangeMarkProps = jest.fn();
123
- const { container } = renderComponent({ changeMarkProps: customChangeMarkProps });
124
- expect(container.firstChild).toBeInTheDocument();
125
- });
126
-
127
- it('passes onClick callback', () => {
128
- const onClick = jest.fn();
129
- const { container } = renderComponent({ onClick });
130
- expect(container.firstChild).toBeInTheDocument();
131
- });
132
-
133
- it('passes onDragStart callback', () => {
134
- const onDragStart = jest.fn();
135
- const { container } = renderComponent({ onDragStart });
136
- expect(container.firstChild).toBeInTheDocument();
137
- });
138
-
139
- it('passes onDragStop callback', () => {
140
- const onDragStop = jest.fn();
141
- const { container } = renderComponent({ onDragStop });
142
- expect(container.firstChild).toBeInTheDocument();
143
- });
144
-
145
- it('uses default onClick when not provided', () => {
146
- const { container } = renderComponent({ onClick: undefined });
147
- expect(container.firstChild).toBeInTheDocument();
148
- });
149
-
150
- it('passes graphProps', () => {
151
- const customGraphProps = graphProps();
152
- customGraphProps.size = { width: 800, height: 600 };
153
- const { container } = renderComponent({ graphProps: customGraphProps });
154
- expect(container.firstChild).toBeInTheDocument();
155
- });
156
-
157
- it('passes className', () => {
158
- const { container } = renderComponent({ className: 'custom-circle' });
159
- expect(container.firstChild).toBeInTheDocument();
160
- });
161
- });
162
-
163
- describe('labels', () => {
164
- it('renders from label when provided', () => {
165
- const { container } = renderWithLabels();
166
- expect(container.firstChild).toBeInTheDocument();
167
- });
168
-
169
- it('renders to label when provided', () => {
170
- const { container } = renderWithLabels();
171
- expect(container.firstChild).toBeInTheDocument();
172
- });
173
-
174
- it('renders middle label when provided', () => {
175
- const middle = { x: 0.5, y: 0.5, label: 'M' };
176
- const { container } = renderComponent({
177
- labelNode,
178
- middle,
179
- from: fromWithLabel,
180
- to: toWithLabel,
181
- });
182
- expect(container.firstChild).toBeInTheDocument();
183
- });
184
-
185
- it('does not render labels when labelNode is not provided', () => {
186
- const { container } = renderComponent({
187
- from: fromWithLabel,
188
- to: toWithLabel,
189
- labelNode: null,
190
- });
191
- expect(container.firstChild).toBeInTheDocument();
192
- });
193
-
194
- it('handles empty label', () => {
195
- const from = { x: 0, y: 0, label: '' };
196
- const to = { x: 1, y: 1, label: '' };
197
- const { container } = renderComponent({
198
- labelNode,
199
- from,
200
- to,
201
- });
202
- expect(container.firstChild).toBeInTheDocument();
203
- });
204
-
205
- it('renders with label mode enabled', () => {
206
- const { container } = renderComponent({
207
- labelNode,
208
- labelModeEnabled: true,
209
- from: fromWithLabel,
210
- to: toWithLabel,
211
- });
212
- expect(container.firstChild).toBeInTheDocument();
213
- });
214
-
215
- it('renders with label mode disabled', () => {
216
- const { container } = renderComponent({
217
- labelNode,
218
- labelModeEnabled: false,
219
- from: fromWithLabel,
220
- to: toWithLabel,
221
- });
222
- expect(container.firstChild).toBeInTheDocument();
223
- });
224
-
225
- it('renders with limitLabeling enabled', () => {
226
- const { container } = renderComponent({
227
- labelNode,
228
- limitLabeling: true,
229
- from: fromWithLabel,
230
- to: toWithLabel,
231
- });
232
- expect(container.firstChild).toBeInTheDocument();
233
- });
234
-
235
- it('handles from label undefined', () => {
236
- const from = { x: 0, y: 0 };
237
- const to = { x: 1, y: 1, label: 'B' };
238
- const { container } = renderComponent({
239
- labelNode,
240
- from,
241
- to,
242
- });
243
- expect(container.firstChild).toBeInTheDocument();
244
- });
245
-
246
- it('handles to label undefined', () => {
247
- const from = { x: 0, y: 0, label: 'A' };
248
- const to = { x: 1, y: 1 };
249
- const { container } = renderComponent({
250
- labelNode,
251
- from,
252
- to,
253
- });
254
- expect(container.firstChild).toBeInTheDocument();
255
- });
256
- });
257
-
258
- describe('coordinates', () => {
259
- it('renders with positive coordinates', () => {
260
- const { container } = renderComponent({
261
- from: xy(5, 10),
262
- to: xy(15, 20),
263
- });
264
- expect(container.firstChild).toBeInTheDocument();
265
- });
266
-
267
- it('renders with negative coordinates', () => {
268
- const { container } = renderComponent({
269
- from: xy(-5, -10),
270
- to: xy(-15, -20),
271
- });
272
- expect(container.firstChild).toBeInTheDocument();
273
- });
274
-
275
- it('renders with zero coordinates', () => {
276
- const { container } = renderComponent({
277
- from: xy(0, 0),
278
- to: xy(0, 0),
279
- });
280
- expect(container.firstChild).toBeInTheDocument();
281
- });
282
-
283
- it('renders with decimal coordinates', () => {
284
- const { container } = renderComponent({
285
- from: { x: 1.5, y: 2.7 },
286
- to: { x: 3.2, y: 4.9 },
287
- });
288
- expect(container.firstChild).toBeInTheDocument();
289
- });
290
-
291
- it('renders with large coordinates', () => {
292
- const { container } = renderComponent({
293
- from: xy(1000, 1000),
294
- to: xy(2000, 2000),
295
- });
296
- expect(container.firstChild).toBeInTheDocument();
297
- });
298
-
299
- it('renders with mixed coordinate signs', () => {
300
- const { container } = renderComponent({
301
- from: xy(-5, 10),
302
- to: xy(15, -20),
303
- });
304
- expect(container.firstChild).toBeInTheDocument();
305
- });
306
-
307
- it('renders with very close points', () => {
308
- const { container } = renderComponent({
309
- from: { x: 5, y: 5 },
310
- to: { x: 5.01, y: 5.01 },
311
- });
312
- expect(container.firstChild).toBeInTheDocument();
313
- });
314
-
315
- it('renders with very far points', () => {
316
- const { container } = renderComponent({
317
- from: xy(0, 0),
318
- to: xy(10000, 10000),
319
- });
320
- expect(container.firstChild).toBeInTheDocument();
321
- });
322
- });
323
-
324
- describe('states', () => {
325
- it('renders in building state', () => {
326
- const { container } = renderComponent({ building: true });
327
- expect(container.firstChild).toBeInTheDocument();
328
- });
329
-
330
- it('renders in completed state', () => {
331
- const { container } = renderComponent({ building: false });
332
- expect(container.firstChild).toBeInTheDocument();
333
- });
334
-
335
- it('renders in disabled state', () => {
336
- const { container } = renderComponent({ disabled: true });
337
- expect(container.firstChild).toBeInTheDocument();
338
- });
339
-
340
- it('renders in enabled state', () => {
341
- const { container } = renderComponent({ disabled: false });
342
- expect(container.firstChild).toBeInTheDocument();
343
- });
344
-
345
- it('renders with building and disabled', () => {
346
- const { container } = renderComponent({ building: true, disabled: true });
347
- expect(container.firstChild).toBeInTheDocument();
348
- });
349
-
350
- it('renders with correctness correct', () => {
351
- const { container } = renderComponent({ correctness: 'correct' });
352
- expect(container.firstChild).toBeInTheDocument();
353
- });
354
-
355
- it('renders with correctness incorrect', () => {
356
- const { container } = renderComponent({ correctness: 'incorrect' });
357
- expect(container.firstChild).toBeInTheDocument();
358
- });
359
-
360
- it('renders with correctness partial', () => {
361
- const { container } = renderComponent({ correctness: 'partial' });
362
- expect(container.firstChild).toBeInTheDocument();
363
- });
364
-
365
- it('renders without correctness', () => {
366
- const { container } = renderComponent({ correctness: undefined });
367
- expect(container.firstChild).toBeInTheDocument();
368
- });
369
- });
370
-
371
- describe('edge cases', () => {
372
- it('handles null labelNode', () => {
373
- const { container } = renderComponent({
374
- labelNode: null,
375
- from: fromWithLabel,
376
- to: toWithLabel,
377
- });
378
- expect(container.firstChild).toBeInTheDocument();
379
- });
380
-
381
- it('handles undefined labelNode', () => {
382
- const { container } = renderComponent({
383
- labelNode: undefined,
384
- from: fromWithLabel,
385
- to: toWithLabel,
386
- });
387
- expect(container.firstChild).toBeInTheDocument();
388
- });
389
-
390
- it('handles missing from coordinates', () => {
391
- const { container } = renderComponent({
392
- from: {},
393
- to: xy(1, 1),
394
- });
395
- expect(container.firstChild).toBeInTheDocument();
396
- });
397
-
398
- it('handles all props undefined except required', () => {
399
- const { container } = renderComponent({
400
- building: undefined,
401
- disabled: undefined,
402
- correctness: undefined,
403
- coordinatesOnHover: undefined,
404
- labelModeEnabled: undefined,
405
- limitLabeling: undefined,
406
- });
407
- expect(container.firstChild).toBeInTheDocument();
408
- });
409
-
410
- it('renders with custom classes', () => {
411
- const { container } = renderComponent({
412
- classes: { root: 'custom-root' },
413
- });
414
- expect(container.firstChild).toBeInTheDocument();
415
- });
416
-
417
- it('renders with empty classes', () => {
418
- const { container } = renderComponent({ classes: {} });
419
- expect(container.firstChild).toBeInTheDocument();
420
- });
421
-
422
- it('handles middle point without label', () => {
423
- const middle = { x: 0.5, y: 0.5 };
424
- const { container } = renderComponent({
425
- labelNode,
426
- middle,
427
- });
428
- expect(container.firstChild).toBeInTheDocument();
429
- });
430
-
431
- it('renders with all label types simultaneously', () => {
432
- const middle = { x: 0.5, y: 0.5, label: 'M' };
433
- const { container } = renderComponent({
434
- labelNode,
435
- from: fromWithLabel,
436
- to: toWithLabel,
437
- middle,
438
- labelModeEnabled: true,
439
- });
440
- expect(container.firstChild).toBeInTheDocument();
441
- });
442
- });
443
-
444
- describe('integration', () => {
445
- it('renders complete circle with all features', () => {
446
- const middle = { x: 0.5, y: 0.5, label: 'Middle' };
447
- const { container } = renderComponent({
448
- from: fromWithLabel,
449
- to: toWithLabel,
450
- middle,
451
- labelNode,
452
- labelModeEnabled: true,
453
- coordinatesOnHover: true,
454
- correctness: 'correct',
455
- building: false,
456
- disabled: false,
457
- onClick: jest.fn(),
458
- onChange: jest.fn(),
459
- changeMarkProps: jest.fn(),
460
- onDragStart: jest.fn(),
461
- onDragStop: jest.fn(),
462
- });
463
- expect(container.firstChild).toBeInTheDocument();
464
- });
465
-
466
- it('renders building circle without labels', () => {
467
- const { container } = renderComponent({
468
- from: xy(0, 0),
469
- to: xy(1, 1),
470
- building: true,
471
- disabled: false,
472
- });
473
- expect(container.firstChild).toBeInTheDocument();
474
- });
475
-
476
- it('renders disabled circle with labels', () => {
477
- const { container } = renderComponent({
478
- from: fromWithLabel,
479
- to: toWithLabel,
480
- labelNode,
481
- disabled: true,
482
- building: false,
483
- });
484
- expect(container.firstChild).toBeInTheDocument();
485
- });
486
- });
487
-
488
- // Note: Instance method tests (dragFrom, dragTo, dragCircle, labelChange, clickPoint)
489
- // have been removed as they test internal implementation details.
490
- // These behaviors should be tested through:
491
- // 1. User interaction tests (drag-and-drop, clicks) - requires complex setup with @dnd-kit
492
- // 2. Integration/E2E tests
493
- // The component's public API (onChange, changeMarkProps callbacks) is what matters for RTL testing.
494
- });