@pie-lib/graphing 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 (145) 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 -275
  7. package/lib/__tests__/graph-with-controls.test.js.map +0 -1
  8. package/lib/__tests__/graph.test.js +0 -927
  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__/key-legend.test.js +0 -321
  15. package/lib/__tests__/key-legend.test.js.map +0 -1
  16. package/lib/__tests__/label-svg-icon.test.js +0 -373
  17. package/lib/__tests__/label-svg-icon.test.js.map +0 -1
  18. package/lib/__tests__/labels.test.js +0 -61
  19. package/lib/__tests__/labels.test.js.map +0 -1
  20. package/lib/__tests__/mark-label.test.js +0 -133
  21. package/lib/__tests__/mark-label.test.js.map +0 -1
  22. package/lib/__tests__/toggle-bar.test.js +0 -197
  23. package/lib/__tests__/toggle-bar.test.js.map +0 -1
  24. package/lib/__tests__/tool-menu.test.js +0 -151
  25. package/lib/__tests__/tool-menu.test.js.map +0 -1
  26. package/lib/__tests__/undo-redo.test.js +0 -31
  27. package/lib/__tests__/undo-redo.test.js.map +0 -1
  28. package/lib/__tests__/use-debounce.test.js +0 -24
  29. package/lib/__tests__/use-debounce.test.js.map +0 -1
  30. package/lib/__tests__/utils.js +0 -70
  31. package/lib/__tests__/utils.js.map +0 -1
  32. package/lib/__tests__/utils.test.js +0 -123
  33. package/lib/__tests__/utils.test.js.map +0 -1
  34. package/lib/axis/__tests__/arrow.test.js +0 -60
  35. package/lib/axis/__tests__/arrow.test.js.map +0 -1
  36. package/lib/axis/__tests__/axes.test.js +0 -195
  37. package/lib/axis/__tests__/axes.test.js.map +0 -1
  38. package/lib/container/__tests__/actions.test.js +0 -108
  39. package/lib/container/__tests__/actions.test.js.map +0 -1
  40. package/lib/container/__tests__/index.test.js +0 -503
  41. package/lib/container/__tests__/index.test.js.map +0 -1
  42. package/lib/container/__tests__/marks.test.js +0 -259
  43. package/lib/container/__tests__/marks.test.js.map +0 -1
  44. package/lib/container/__tests__/middleware.test.js +0 -244
  45. package/lib/container/__tests__/middleware.test.js.map +0 -1
  46. package/lib/container/__tests__/reducer.test.js +0 -450
  47. package/lib/container/__tests__/reducer.test.js.map +0 -1
  48. package/lib/tools/absolute/__tests__/component.test.js +0 -65
  49. package/lib/tools/absolute/__tests__/component.test.js.map +0 -1
  50. package/lib/tools/circle/__tests__/bg-circle.test.js +0 -33
  51. package/lib/tools/circle/__tests__/bg-circle.test.js.map +0 -1
  52. package/lib/tools/circle/__tests__/component.test.js +0 -615
  53. package/lib/tools/circle/__tests__/component.test.js.map +0 -1
  54. package/lib/tools/circle/__tests__/index.test.js +0 -576
  55. package/lib/tools/circle/__tests__/index.test.js.map +0 -1
  56. package/lib/tools/exponential/__tests__/component.test.js +0 -64
  57. package/lib/tools/exponential/__tests__/component.test.js.map +0 -1
  58. package/lib/tools/exponential/__tests__/index.test.js +0 -828
  59. package/lib/tools/exponential/__tests__/index.test.js.map +0 -1
  60. package/lib/tools/line/__tests__/component.test.js +0 -45
  61. package/lib/tools/line/__tests__/component.test.js.map +0 -1
  62. package/lib/tools/parabola/__tests__/component.test.js +0 -64
  63. package/lib/tools/parabola/__tests__/component.test.js.map +0 -1
  64. package/lib/tools/parabola/__tests__/index.test.js +0 -564
  65. package/lib/tools/parabola/__tests__/index.test.js.map +0 -1
  66. package/lib/tools/point/__tests__/component.test.js +0 -434
  67. package/lib/tools/point/__tests__/component.test.js.map +0 -1
  68. package/lib/tools/point/__tests__/index.test.js +0 -262
  69. package/lib/tools/point/__tests__/index.test.js.map +0 -1
  70. package/lib/tools/polygon/__tests__/component.test.js +0 -485
  71. package/lib/tools/polygon/__tests__/component.test.js.map +0 -1
  72. package/lib/tools/polygon/__tests__/index.test.js +0 -303
  73. package/lib/tools/polygon/__tests__/index.test.js.map +0 -1
  74. package/lib/tools/polygon/__tests__/line.test.js +0 -50
  75. package/lib/tools/polygon/__tests__/line.test.js.map +0 -1
  76. package/lib/tools/polygon/__tests__/polygon.test.js +0 -85
  77. package/lib/tools/polygon/__tests__/polygon.test.js.map +0 -1
  78. package/lib/tools/ray/__tests__/component.test.js +0 -35
  79. package/lib/tools/ray/__tests__/component.test.js.map +0 -1
  80. package/lib/tools/segment/__tests__/component.test.js +0 -35
  81. package/lib/tools/segment/__tests__/component.test.js.map +0 -1
  82. package/lib/tools/shared/__tests__/arrow-head.test.js +0 -45
  83. package/lib/tools/shared/__tests__/arrow-head.test.js.map +0 -1
  84. package/lib/tools/shared/line/__tests__/index.test.js +0 -124
  85. package/lib/tools/shared/line/__tests__/index.test.js.map +0 -1
  86. package/lib/tools/shared/line/__tests__/line-path.test.js +0 -62
  87. package/lib/tools/shared/line/__tests__/line-path.test.js.map +0 -1
  88. package/lib/tools/shared/line/__tests__/with-root-edge.test.js +0 -90
  89. package/lib/tools/shared/line/__tests__/with-root-edge.test.js.map +0 -1
  90. package/lib/tools/shared/point/__tests__/arrow-point.test.js +0 -127
  91. package/lib/tools/shared/point/__tests__/arrow-point.test.js.map +0 -1
  92. package/lib/tools/shared/point/__tests__/base-point.test.js +0 -122
  93. package/lib/tools/shared/point/__tests__/base-point.test.js.map +0 -1
  94. package/lib/tools/sine/__tests__/component.test.js +0 -72
  95. package/lib/tools/sine/__tests__/component.test.js.map +0 -1
  96. package/lib/tools/vector/__tests__/component.test.js +0 -32
  97. package/lib/tools/vector/__tests__/component.test.js.map +0 -1
  98. package/src/__tests__/bg.test.jsx +0 -250
  99. package/src/__tests__/coordinates-label.test.jsx +0 -243
  100. package/src/__tests__/graph-with-controls.test.jsx +0 -198
  101. package/src/__tests__/graph.test.jsx +0 -721
  102. package/src/__tests__/grid-setup.test.jsx +0 -645
  103. package/src/__tests__/grid.test.jsx +0 -22
  104. package/src/__tests__/key-legend.test.jsx +0 -260
  105. package/src/__tests__/label-svg-icon.test.jsx +0 -278
  106. package/src/__tests__/labels.test.jsx +0 -55
  107. package/src/__tests__/mark-label.test.jsx +0 -63
  108. package/src/__tests__/toggle-bar.test.jsx +0 -146
  109. package/src/__tests__/tool-menu.test.jsx +0 -115
  110. package/src/__tests__/undo-redo.test.jsx +0 -24
  111. package/src/__tests__/use-debounce.test.js +0 -21
  112. package/src/__tests__/utils.js +0 -41
  113. package/src/__tests__/utils.test.js +0 -105
  114. package/src/axis/__tests__/arrow.test.jsx +0 -38
  115. package/src/axis/__tests__/axes.test.jsx +0 -216
  116. package/src/container/__tests__/actions.test.js +0 -105
  117. package/src/container/__tests__/index.test.jsx +0 -319
  118. package/src/container/__tests__/marks.test.js +0 -172
  119. package/src/container/__tests__/middleware.test.js +0 -235
  120. package/src/container/__tests__/reducer.test.js +0 -324
  121. package/src/tools/absolute/__tests__/component.test.jsx +0 -53
  122. package/src/tools/circle/__tests__/bg-circle.test.jsx +0 -26
  123. package/src/tools/circle/__tests__/component.test.jsx +0 -494
  124. package/src/tools/circle/__tests__/index.test.js +0 -480
  125. package/src/tools/exponential/__tests__/component.test.jsx +0 -53
  126. package/src/tools/exponential/__tests__/index.test.js +0 -729
  127. package/src/tools/line/__tests__/component.test.jsx +0 -37
  128. package/src/tools/parabola/__tests__/component.test.jsx +0 -48
  129. package/src/tools/parabola/__tests__/index.test.js +0 -470
  130. package/src/tools/point/__tests__/component.test.jsx +0 -349
  131. package/src/tools/point/__tests__/index.test.js +0 -241
  132. package/src/tools/polygon/__tests__/component.test.jsx +0 -471
  133. package/src/tools/polygon/__tests__/index.test.js +0 -294
  134. package/src/tools/polygon/__tests__/line.test.jsx +0 -35
  135. package/src/tools/polygon/__tests__/polygon.test.jsx +0 -61
  136. package/src/tools/ray/__tests__/component.test.jsx +0 -29
  137. package/src/tools/segment/__tests__/component.test.jsx +0 -28
  138. package/src/tools/shared/__tests__/arrow-head.test.jsx +0 -31
  139. package/src/tools/shared/line/__tests__/index.test.jsx +0 -109
  140. package/src/tools/shared/line/__tests__/line-path.test.jsx +0 -53
  141. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +0 -73
  142. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +0 -91
  143. package/src/tools/shared/point/__tests__/base-point.test.jsx +0 -87
  144. package/src/tools/sine/__tests__/component.test.jsx +0 -51
  145. package/src/tools/vector/__tests__/component.test.jsx +0 -25
@@ -1,480 +0,0 @@
1
- import { tool } from '../index';
2
- import { equalPoints } from '../../../utils';
3
-
4
- jest.mock('../../../utils', () => ({
5
- equalPoints: jest.fn(),
6
- }));
7
-
8
- describe('circle tool', () => {
9
- let circleTool;
10
-
11
- beforeEach(() => {
12
- jest.clearAllMocks();
13
- circleTool = tool();
14
- });
15
-
16
- describe('tool configuration', () => {
17
- it('creates a tool object', () => {
18
- expect(circleTool).toBeDefined();
19
- expect(typeof circleTool).toBe('object');
20
- });
21
-
22
- it('has type circle', () => {
23
- expect(circleTool.type).toBe('circle');
24
- });
25
-
26
- it('has a Component', () => {
27
- expect(circleTool.Component).toBeDefined();
28
- });
29
-
30
- it('has hover function', () => {
31
- expect(typeof circleTool.hover).toBe('function');
32
- });
33
-
34
- it('has addPoint function', () => {
35
- expect(typeof circleTool.addPoint).toBe('function');
36
- });
37
- });
38
-
39
- describe('hover', () => {
40
- it('returns mark with edge point', () => {
41
- const point = { x: 5, y: 10 };
42
- const mark = { type: 'circle', root: { x: 0, y: 0 } };
43
-
44
- const result = circleTool.hover(point, mark);
45
-
46
- expect(result).toEqual({ ...mark, edge: point });
47
- });
48
-
49
- it('updates existing mark with new edge', () => {
50
- const point = { x: 7, y: 8 };
51
- const mark = {
52
- type: 'circle',
53
- root: { x: 1, y: 1 },
54
- edge: { x: 3, y: 3 },
55
- };
56
-
57
- const result = circleTool.hover(point, mark);
58
-
59
- expect(result.edge).toEqual(point);
60
- expect(result.root).toEqual(mark.root);
61
- });
62
-
63
- it('preserves mark properties', () => {
64
- const point = { x: 5, y: 5 };
65
- const mark = {
66
- type: 'circle',
67
- root: { x: 0, y: 0 },
68
- label: 'Circle A',
69
- correctness: { value: 'correct' },
70
- };
71
-
72
- const result = circleTool.hover(point, mark);
73
-
74
- expect(result.label).toBe('Circle A');
75
- expect(result.correctness).toEqual({ value: 'correct' });
76
- });
77
-
78
- it('handles null mark', () => {
79
- const point = { x: 5, y: 10 };
80
- const mark = null;
81
-
82
- const result = circleTool.hover(point, mark);
83
-
84
- expect(result).toEqual({ edge: point });
85
- });
86
-
87
- it('handles undefined mark', () => {
88
- const point = { x: 5, y: 10 };
89
- const mark = undefined;
90
-
91
- const result = circleTool.hover(point, mark);
92
-
93
- expect(result).toEqual({ edge: point });
94
- });
95
-
96
- it('works with negative coordinates', () => {
97
- const point = { x: -5, y: -10 };
98
- const mark = { type: 'circle', root: { x: -1, y: -1 } };
99
-
100
- const result = circleTool.hover(point, mark);
101
-
102
- expect(result.edge).toEqual(point);
103
- });
104
-
105
- it('works with decimal coordinates', () => {
106
- const point = { x: 3.5, y: 7.8 };
107
- const mark = { type: 'circle', root: { x: 1.2, y: 2.4 } };
108
-
109
- const result = circleTool.hover(point, mark);
110
-
111
- expect(result.edge).toEqual(point);
112
- });
113
- });
114
-
115
- describe('addPoint', () => {
116
- describe('first point (creating root)', () => {
117
- it('creates new circle mark when no mark exists', () => {
118
- const point = { x: 5, y: 10 };
119
- const mark = null;
120
- equalPoints.mockReturnValue(false);
121
-
122
- const result = circleTool.addPoint(point, mark);
123
-
124
- expect(result).toEqual({
125
- type: 'circle',
126
- root: point,
127
- building: true,
128
- });
129
- });
130
-
131
- it('creates building circle with correct properties', () => {
132
- const point = { x: 3, y: 7 };
133
- equalPoints.mockReturnValue(false);
134
-
135
- const result = circleTool.addPoint(point, null);
136
-
137
- expect(result.type).toBe('circle');
138
- expect(result.root).toEqual(point);
139
- expect(result.building).toBe(true);
140
- expect(result.edge).toBeUndefined();
141
- });
142
-
143
- it('works with negative coordinates', () => {
144
- const point = { x: -5, y: -10 };
145
- equalPoints.mockReturnValue(false);
146
-
147
- const result = circleTool.addPoint(point, null);
148
-
149
- expect(result.root).toEqual(point);
150
- expect(result.building).toBe(true);
151
- });
152
-
153
- it('works with zero coordinates', () => {
154
- const point = { x: 0, y: 0 };
155
- equalPoints.mockReturnValue(false);
156
-
157
- const result = circleTool.addPoint(point, null);
158
-
159
- expect(result.root).toEqual(point);
160
- expect(result.building).toBe(true);
161
- });
162
-
163
- it('works with decimal coordinates', () => {
164
- const point = { x: 3.5, y: 7.25 };
165
- equalPoints.mockReturnValue(false);
166
-
167
- const result = circleTool.addPoint(point, null);
168
-
169
- expect(result.root).toEqual(point);
170
- expect(result.building).toBe(true);
171
- });
172
- });
173
-
174
- describe('second point (completing circle)', () => {
175
- it('completes circle when adding edge point', () => {
176
- const root = { x: 0, y: 0 };
177
- const edge = { x: 5, y: 5 };
178
- const mark = {
179
- type: 'circle',
180
- root,
181
- building: true,
182
- };
183
- equalPoints.mockReturnValue(false);
184
-
185
- const result = circleTool.addPoint(edge, mark);
186
-
187
- expect(result).toEqual({
188
- ...mark,
189
- edge,
190
- building: false,
191
- });
192
- });
193
-
194
- it('sets building to false', () => {
195
- const mark = {
196
- type: 'circle',
197
- root: { x: 1, y: 1 },
198
- building: true,
199
- };
200
- const point = { x: 5, y: 5 };
201
- equalPoints.mockReturnValue(false);
202
-
203
- const result = circleTool.addPoint(point, mark);
204
-
205
- expect(result.building).toBe(false);
206
- });
207
-
208
- it('preserves mark type', () => {
209
- const mark = {
210
- type: 'circle',
211
- root: { x: 1, y: 1 },
212
- building: true,
213
- };
214
- const point = { x: 5, y: 5 };
215
- equalPoints.mockReturnValue(false);
216
-
217
- const result = circleTool.addPoint(point, mark);
218
-
219
- expect(result.type).toBe('circle');
220
- });
221
-
222
- it('preserves root when adding edge', () => {
223
- const root = { x: 2, y: 3 };
224
- const mark = {
225
- type: 'circle',
226
- root,
227
- building: true,
228
- };
229
- const edge = { x: 8, y: 9 };
230
- equalPoints.mockReturnValue(false);
231
-
232
- const result = circleTool.addPoint(edge, mark);
233
-
234
- expect(result.root).toEqual(root);
235
- expect(result.edge).toEqual(edge);
236
- });
237
-
238
- it('works with large radius', () => {
239
- const root = { x: 0, y: 0 };
240
- const edge = { x: 100, y: 100 };
241
- const mark = {
242
- type: 'circle',
243
- root,
244
- building: true,
245
- };
246
- equalPoints.mockReturnValue(false);
247
-
248
- const result = circleTool.addPoint(edge, mark);
249
-
250
- expect(result.edge).toEqual(edge);
251
- expect(result.building).toBe(false);
252
- });
253
-
254
- it('works with small radius', () => {
255
- const root = { x: 5, y: 5 };
256
- const edge = { x: 5.1, y: 5.1 };
257
- const mark = {
258
- type: 'circle',
259
- root,
260
- building: true,
261
- };
262
- equalPoints.mockReturnValue(false);
263
-
264
- const result = circleTool.addPoint(edge, mark);
265
-
266
- expect(result.edge).toEqual(edge);
267
- expect(result.building).toBe(false);
268
- });
269
- });
270
-
271
- describe('same point handling', () => {
272
- it('returns same mark when clicking same point as root', () => {
273
- const point = { x: 5, y: 10 };
274
- const mark = {
275
- type: 'circle',
276
- root: point,
277
- building: true,
278
- };
279
- equalPoints.mockReturnValue(true);
280
-
281
- const result = circleTool.addPoint(point, mark);
282
-
283
- expect(result).toBe(mark);
284
- });
285
-
286
- it('calls equalPoints with correct arguments', () => {
287
- const point = { x: 5, y: 10 };
288
- const mark = {
289
- type: 'circle',
290
- root: { x: 5, y: 10 },
291
- building: true,
292
- };
293
- equalPoints.mockReturnValue(true);
294
-
295
- circleTool.addPoint(point, mark);
296
-
297
- expect(equalPoints).toHaveBeenCalledWith(mark.root, point);
298
- });
299
-
300
- it('prevents zero-radius circle', () => {
301
- const point = { x: 5, y: 10 };
302
- const mark = {
303
- type: 'circle',
304
- root: { x: 5, y: 10 },
305
- building: true,
306
- };
307
- equalPoints.mockReturnValue(true);
308
-
309
- const result = circleTool.addPoint(point, mark);
310
-
311
- // Should return unchanged mark, not complete the circle
312
- expect(result).toBe(mark);
313
- expect(result.building).toBe(true);
314
- });
315
- });
316
-
317
- describe('edge cases', () => {
318
- it('handles undefined mark on first click', () => {
319
- const point = { x: 5, y: 10 };
320
- equalPoints.mockReturnValue(false);
321
-
322
- const result = circleTool.addPoint(point, undefined);
323
-
324
- expect(result.type).toBe('circle');
325
- expect(result.root).toEqual(point);
326
- expect(result.building).toBe(true);
327
- });
328
-
329
- it('handles mark with additional properties', () => {
330
- const mark = {
331
- type: 'circle',
332
- root: { x: 1, y: 1 },
333
- building: true,
334
- label: 'Circle 1',
335
- correctness: { value: 'correct' },
336
- };
337
- const point = { x: 5, y: 5 };
338
- equalPoints.mockReturnValue(false);
339
-
340
- const result = circleTool.addPoint(point, mark);
341
-
342
- expect(result.label).toBe('Circle 1');
343
- expect(result.correctness).toEqual({ value: 'correct' });
344
- expect(result.edge).toEqual(point);
345
- expect(result.building).toBe(false);
346
- });
347
-
348
- it('handles mark with existing edge', () => {
349
- const mark = {
350
- type: 'circle',
351
- root: { x: 0, y: 0 },
352
- edge: { x: 3, y: 3 },
353
- building: true,
354
- };
355
- const newEdge = { x: 5, y: 5 };
356
- equalPoints.mockReturnValue(false);
357
-
358
- const result = circleTool.addPoint(newEdge, mark);
359
-
360
- expect(result.edge).toEqual(newEdge);
361
- expect(result.building).toBe(false);
362
- });
363
-
364
- it('works with point at origin', () => {
365
- const point = { x: 0, y: 0 };
366
- equalPoints.mockReturnValue(false);
367
-
368
- const result = circleTool.addPoint(point, null);
369
-
370
- expect(result.root).toEqual(point);
371
- expect(result.building).toBe(true);
372
- });
373
-
374
- it('works with very large coordinates', () => {
375
- const point = { x: 1000, y: 1000 };
376
- equalPoints.mockReturnValue(false);
377
-
378
- const result = circleTool.addPoint(point, null);
379
-
380
- expect(result.root).toEqual(point);
381
- expect(result.building).toBe(true);
382
- });
383
-
384
- it('works with negative coordinates', () => {
385
- const point = { x: -10, y: -20 };
386
- equalPoints.mockReturnValue(false);
387
-
388
- const result = circleTool.addPoint(point, null);
389
-
390
- expect(result.root).toEqual(point);
391
- expect(result.building).toBe(true);
392
- });
393
- });
394
-
395
- describe('immutability', () => {
396
- it('does not mutate original mark when adding edge', () => {
397
- const mark = {
398
- type: 'circle',
399
- root: { x: 1, y: 1 },
400
- building: true,
401
- };
402
- const originalMark = { ...mark };
403
- const point = { x: 5, y: 5 };
404
- equalPoints.mockReturnValue(false);
405
-
406
- const result = circleTool.addPoint(point, mark);
407
-
408
- expect(mark).toEqual(originalMark);
409
- expect(result).not.toBe(mark);
410
- });
411
-
412
- it('does not mutate original mark when returning same', () => {
413
- const mark = {
414
- type: 'circle',
415
- root: { x: 5, y: 10 },
416
- building: true,
417
- };
418
- const point = { x: 5, y: 10 };
419
- equalPoints.mockReturnValue(true);
420
-
421
- const result = circleTool.addPoint(point, mark);
422
-
423
- expect(result).toBe(mark);
424
- });
425
- });
426
- });
427
-
428
- describe('integration scenarios', () => {
429
- it('handles full circle creation flow', () => {
430
- equalPoints.mockReturnValue(false);
431
-
432
- // First click - create root
433
- const firstPoint = { x: 5, y: 5 };
434
- const mark1 = circleTool.addPoint(firstPoint, null);
435
- expect(mark1.root).toEqual(firstPoint);
436
- expect(mark1.building).toBe(true);
437
-
438
- // Hover - show preview
439
- const hoverPoint = { x: 10, y: 10 };
440
- const mark2 = circleTool.hover(hoverPoint, mark1);
441
- expect(mark2.edge).toEqual(hoverPoint);
442
-
443
- // Second click - complete circle
444
- const secondPoint = { x: 10, y: 5 };
445
- const mark3 = circleTool.addPoint(secondPoint, mark1);
446
- expect(mark3.root).toEqual(firstPoint);
447
- expect(mark3.edge).toEqual(secondPoint);
448
- expect(mark3.building).toBe(false);
449
- });
450
-
451
- it('handles attempted zero-radius circle', () => {
452
- const point = { x: 5, y: 5 };
453
-
454
- // First click
455
- equalPoints.mockReturnValue(false);
456
- const mark1 = circleTool.addPoint(point, null);
457
-
458
- // Second click at same point
459
- equalPoints.mockReturnValue(true);
460
- const mark2 = circleTool.addPoint(point, mark1);
461
-
462
- // Should return unchanged mark
463
- expect(mark2).toBe(mark1);
464
- expect(mark2.building).toBe(true);
465
- });
466
-
467
- it('handles circle with labels', () => {
468
- equalPoints.mockReturnValue(false);
469
-
470
- const firstPoint = { x: 0, y: 0, label: 'Center' };
471
- const mark1 = circleTool.addPoint(firstPoint, null);
472
-
473
- const secondPoint = { x: 5, y: 0, label: 'Edge' };
474
- const mark2 = circleTool.addPoint(secondPoint, mark1);
475
-
476
- expect(mark2.root.label).toBe('Center');
477
- expect(mark2.building).toBe(false);
478
- });
479
- });
480
- });
@@ -1,53 +0,0 @@
1
- import { withRootEdge } from '../../shared/line/with-root-edge';
2
- import { buildDataPoints, exponentialFromTwoPoints } from '@pie-lib/graphing-utils';
3
- import { utils } from '@pie-lib/plot';
4
-
5
- import { graphProps as getGraphProps } from '../../../__tests__/utils';
6
-
7
- const { xy } = utils;
8
-
9
- jest.mock('@pie-lib/graphing-utils', () => ({
10
- buildDataPoints: jest.fn().mockReturnValue([]),
11
- exponentialFromTwoPoints: jest.fn(() => jest.fn()),
12
- getAmplitudeAndFreq: jest.fn().mockReturnValue({ freq: 4, amplitude: 1 }),
13
- }));
14
-
15
- jest.mock('../../shared/line/with-root-edge', () => ({
16
- withRootEdge: jest.fn(),
17
- rootEdgeComponent: jest.fn(),
18
- }));
19
-
20
- describe('Exponential', () => {
21
- let fnBody;
22
- let graphProps;
23
- let root;
24
- let edge;
25
- let result;
26
-
27
- beforeEach(() => {
28
- require('../component');
29
- fnBody = withRootEdge.mock.calls[0][0];
30
- graphProps = getGraphProps();
31
- root = xy(1, 1);
32
- edge = xy(2, 2);
33
-
34
- result = fnBody({ graphProps, root, edge });
35
- });
36
-
37
- it('fnBody is not null', () => {
38
- expect(fnBody).toBeDefined();
39
- });
40
-
41
- it('calls buildDataPoints', () => {
42
- const { domain, range } = graphProps;
43
- expect(buildDataPoints).toHaveBeenCalledWith(domain, range, root, edge, expect.anything(), true);
44
- });
45
-
46
- it('calls exponentialFromTwoPoints', () => {
47
- expect(exponentialFromTwoPoints).toHaveBeenCalledWith(root, edge);
48
- });
49
-
50
- it('returns dataPoints', () => {
51
- expect(result).toEqual({ root, edge, dataPoints: [] });
52
- });
53
- });