@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,243 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@pie-lib/test-utils';
3
- import { CoordinatesLabel, getLabelPosition } from '../coordinates-label';
4
-
5
- describe('CoordinatesLabel', () => {
6
- let defaultProps;
7
- let graphProps;
8
-
9
- beforeEach(() => {
10
- graphProps = {
11
- domain: { min: -10, max: 10, step: 1, label: 'x', axisLabel: 'X' },
12
- range: { min: -10, max: 10, step: 1, label: 'y', axisLabel: 'Y' },
13
- scale: {
14
- x: jest.fn((val) => (val + 10) * 20),
15
- y: jest.fn((val) => (10 - val) * 20),
16
- },
17
- };
18
-
19
- defaultProps = {
20
- x: 5,
21
- y: 5,
22
- graphProps,
23
- };
24
- });
25
-
26
- describe('rendering', () => {
27
- it('renders without crashing', () => {
28
- const { container } = render(<CoordinatesLabel {...defaultProps} />);
29
- expect(container).toBeTruthy();
30
- });
31
-
32
- it('displays formatted coordinates', () => {
33
- const { container } = render(<CoordinatesLabel {...defaultProps} />);
34
- const input = container.querySelector('input');
35
-
36
- expect(input.value).toBe('(5, 5)');
37
- });
38
-
39
- it('rounds coordinates to 4 decimal places', () => {
40
- const props = { ...defaultProps, x: 1.123456, y: 2.987654 };
41
- const { container } = render(<CoordinatesLabel {...props} />);
42
- const input = container.querySelector('input');
43
-
44
- expect(input.value).toBe('(1.1235, 2.9877)');
45
- });
46
-
47
- it('handles integer coordinates', () => {
48
- const props = { ...defaultProps, x: 0, y: 0 };
49
- const { container } = render(<CoordinatesLabel {...props} />);
50
- const input = container.querySelector('input');
51
-
52
- expect(input.value).toBe('(0, 0)');
53
- });
54
-
55
- it('handles negative coordinates', () => {
56
- const props = { ...defaultProps, x: -3, y: -7 };
57
- const { container } = render(<CoordinatesLabel {...props} />);
58
- const input = container.querySelector('input');
59
-
60
- expect(input.value).toBe('(-3, -7)');
61
- });
62
-
63
- it('renders as an input element', () => {
64
- const { container } = render(<CoordinatesLabel {...defaultProps} />);
65
- const input = container.querySelector('input');
66
-
67
- expect(input).toBeTruthy();
68
- expect(input.tagName).toBe('INPUT');
69
- });
70
-
71
- it('applies correct styles', () => {
72
- const { container } = render(<CoordinatesLabel {...defaultProps} />);
73
- const wrapper = container.firstChild;
74
-
75
- expect(wrapper).toHaveStyle({ position: 'absolute' });
76
- expect(wrapper).toHaveStyle({ pointerEvents: 'auto' });
77
- });
78
- });
79
-
80
- describe('getLabelPosition', () => {
81
- it('positions label to the right by default', () => {
82
- const position = getLabelPosition(graphProps, 0, 0, 60);
83
-
84
- expect(position.left).toBeGreaterThan(graphProps.scale.x(0));
85
- expect(position.top).toBeDefined();
86
- });
87
-
88
- it('positions label to the left when near right edge', () => {
89
- const x = 9; // Near max
90
- const labelLength = 100;
91
- const position = getLabelPosition(graphProps, x, 0, labelLength);
92
-
93
- expect(position.left).toBeLessThan(graphProps.scale.x(x));
94
- });
95
-
96
- it('adjusts top position for minimum y value', () => {
97
- const position = getLabelPosition(graphProps, 0, -10, 60);
98
-
99
- expect(position.top).toBe(graphProps.scale.y(-10) - 16);
100
- });
101
-
102
- it('adjusts top position for maximum y value', () => {
103
- const position = getLabelPosition(graphProps, 0, 10, 60);
104
-
105
- expect(position.top).toBe(graphProps.scale.y(10) - 0);
106
- });
107
-
108
- it('centers label vertically for middle values', () => {
109
- const position = getLabelPosition(graphProps, 0, 0, 60);
110
-
111
- expect(position.top).toBe(graphProps.scale.y(0) - 8);
112
- });
113
-
114
- it('applies left shift consistently', () => {
115
- const leftShift = 10;
116
- const labelLength = 60;
117
-
118
- const rightPos = getLabelPosition(graphProps, 0, 0, labelLength);
119
- expect(rightPos.left).toBe(graphProps.scale.x(0) + leftShift);
120
-
121
- const leftPos = getLabelPosition(graphProps, 9, 0, labelLength);
122
- expect(leftPos.left).toBe(graphProps.scale.x(9) - leftShift - labelLength);
123
- });
124
- });
125
-
126
- describe('label width calculation', () => {
127
- it('calculates width based on label length', () => {
128
- const props = { ...defaultProps, x: 1, y: 2 };
129
- const { container } = render(<CoordinatesLabel {...props} />);
130
- const wrapper = container.firstChild;
131
-
132
- const expectedWidth = 6 * 6;
133
- expect(wrapper).toHaveStyle({ width: `${expectedWidth}px` });
134
- });
135
-
136
- it('adjusts width for longer coordinates', () => {
137
- const props = { ...defaultProps, x: -10.123, y: 10.456 };
138
- const { container } = render(<CoordinatesLabel {...props} />);
139
- const wrapper = container.firstChild;
140
-
141
- const style = window.getComputedStyle(wrapper);
142
- expect(parseInt(style.width)).toBeGreaterThan(42);
143
- });
144
- });
145
-
146
- describe('edge cases', () => {
147
- it('handles very small coordinates', () => {
148
- const props = { ...defaultProps, x: 0.0001, y: 0.0002 };
149
- const { container } = render(<CoordinatesLabel {...props} />);
150
- const input = container.querySelector('input');
151
-
152
- expect(input.value).toContain('(');
153
- expect(input.value).toContain(')');
154
- expect(input.value).toContain(',');
155
- });
156
-
157
- it('handles very large coordinates', () => {
158
- const props = { ...defaultProps, x: 999999, y: 888888 };
159
- const { container } = render(<CoordinatesLabel {...props} />);
160
- const input = container.querySelector('input');
161
-
162
- expect(input.value).toBe('(999999, 888888)');
163
- });
164
-
165
- it('handles zero coordinates', () => {
166
- const props = { ...defaultProps, x: 0, y: 0 };
167
- const { container } = render(<CoordinatesLabel {...props} />);
168
- const input = container.querySelector('input');
169
-
170
- expect(input.value).toBe('(0, 0)');
171
- });
172
-
173
- it('handles coordinates at domain/range boundaries', () => {
174
- const props = { ...defaultProps, x: 10, y: 10 };
175
- const { container } = render(<CoordinatesLabel {...props} />);
176
- const input = container.querySelector('input');
177
-
178
- expect(input.value).toBe('(10, 10)');
179
- });
180
-
181
- it('handles negative boundaries', () => {
182
- const props = { ...defaultProps, x: -10, y: -10 };
183
- const { container } = render(<CoordinatesLabel {...props} />);
184
- const input = container.querySelector('input');
185
-
186
- expect(input.value).toBe('(-10, -10)');
187
- });
188
- });
189
-
190
- describe('prop types and validation', () => {
191
- it('accepts required props', () => {
192
- expect(() => {
193
- render(<CoordinatesLabel {...defaultProps} />);
194
- }).not.toThrow();
195
- });
196
-
197
- it('renders with missing optional props', () => {
198
- const props = {
199
- x: 1,
200
- y: 2,
201
- graphProps,
202
- };
203
-
204
- expect(() => {
205
- render(<CoordinatesLabel {...props} />);
206
- }).not.toThrow();
207
- });
208
- });
209
-
210
- describe('updates', () => {
211
- it('updates when x coordinate changes', () => {
212
- const { container, rerender } = render(<CoordinatesLabel {...defaultProps} />);
213
- let input = container.querySelector('input');
214
- expect(input.value).toBe('(5, 5)');
215
-
216
- rerender(<CoordinatesLabel {...defaultProps} x={7} />);
217
- input = container.querySelector('input');
218
- expect(input.value).toBe('(7, 5)');
219
- });
220
-
221
- it('updates when y coordinate changes', () => {
222
- const { container, rerender } = render(<CoordinatesLabel {...defaultProps} />);
223
- let input = container.querySelector('input');
224
- expect(input.value).toBe('(5, 5)');
225
-
226
- rerender(<CoordinatesLabel {...defaultProps} y={3} />);
227
- input = container.querySelector('input');
228
- expect(input.value).toBe('(5, 3)');
229
- });
230
-
231
- it('updates position when coordinates change', () => {
232
- const { container, rerender } = render(<CoordinatesLabel {...defaultProps} />);
233
- const initialStyle = window.getComputedStyle(container.firstChild);
234
- const initialLeft = initialStyle.left;
235
-
236
- rerender(<CoordinatesLabel {...defaultProps} x={8} />);
237
- const newStyle = window.getComputedStyle(container.firstChild);
238
- const newLeft = newStyle.left;
239
-
240
- expect(newLeft).not.toBe(initialLeft);
241
- });
242
- });
243
- });
@@ -1,184 +0,0 @@
1
- import { render } from '@pie-lib/test-utils';
2
- import React from 'react';
3
- import {
4
- filterByValidToolTypes,
5
- filterByVisibleToolTypes,
6
- getAvailableTool,
7
- GraphWithControls,
8
- setToolbarAvailability,
9
- toolIsAvailable,
10
- } from '../graph-with-controls';
11
- import { allTools, line as lineTool, toolsArr } from '../tools';
12
-
13
- // Mock DragProvider to avoid @dnd-kit React version conflicts
14
- jest.mock('@pie-lib/drag', () => ({
15
- DragProvider: ({ children }) => <div data-testid="drag-provider">{children}</div>,
16
- }));
17
-
18
- // Mock @dnd-kit/core hooks to avoid DndContext requirement
19
- jest.mock('@dnd-kit/core', () => ({
20
- useDraggable: jest.fn(() => ({
21
- attributes: {
22
- role: 'button',
23
- tabIndex: 0,
24
- },
25
- listeners: {
26
- onPointerDown: jest.fn(),
27
- },
28
- setNodeRef: jest.fn(),
29
- transform: null,
30
- transition: null,
31
- isDragging: false,
32
- })),
33
- useDroppable: jest.fn(() => ({
34
- setNodeRef: jest.fn(),
35
- isOver: false,
36
- active: null,
37
- })),
38
- }));
39
-
40
- // Mock @dnd-kit/utilities for CSS transform
41
- jest.mock('@dnd-kit/utilities', () => ({
42
- CSS: {
43
- Transform: {
44
- toString: jest.fn((transform) => (transform ? 'translate3d(0, 0, 0)' : '')),
45
- },
46
- },
47
- }));
48
-
49
- // Mock @dnd-kit/sortable for arrayMove
50
- jest.mock('@dnd-kit/sortable', () => ({
51
- arrayMove: jest.fn((array, from, to) => {
52
- const newArray = [...array];
53
- const [removed] = newArray.splice(from, 1);
54
- newArray.splice(to, 0, removed);
55
- return newArray;
56
- }),
57
- }));
58
-
59
- const line = {
60
- type: 'line',
61
- from: { x: 0, y: 0 },
62
- to: { x: 1, y: 1 },
63
- label: 'Line',
64
- building: true,
65
- };
66
-
67
- const polygon = {
68
- type: 'polygon',
69
- points: [
70
- { x: 0, y: 0 },
71
- { x: 1, y: 1 },
72
- { x: 2, y: 2 },
73
- ],
74
- };
75
-
76
- const marks = [line, polygon];
77
-
78
- // Pure function tests - keep as-is
79
- describe('setToolbarAvailability', () => {
80
- it('sets `toolbar: true` if tool should be displayed in toolbar - all tools', () => {
81
- const result = setToolbarAvailability(allTools);
82
- const allTrue = new Array(toolsArr.length).fill(true);
83
-
84
- expect(result.map((r) => r.toolbar)).toEqual(allTrue);
85
- });
86
-
87
- it('sets `toolbar: true` if tool should be displayed in toolbar - few tools', () => {
88
- const result = setToolbarAvailability(['line', 'polygon']);
89
- const allOthersFalse = new Array(toolsArr.length - 2).fill(false);
90
-
91
- expect(result.filter((r) => r.type === 'line' || r.type === 'polygon').map((r) => r.toolbar)).toEqual([true, true]);
92
- expect(result.filter((r) => r.type !== 'line' && r.type !== 'polygon').map((r) => r.toolbar)).toEqual(
93
- allOthersFalse,
94
- );
95
- });
96
- });
97
-
98
- describe('toolIsAvailable', () => {
99
- const tools = setToolbarAvailability(['line', 'polygon']);
100
-
101
- it('returns true if tool is available', () => {
102
- expect(toolIsAvailable(tools, lineTool())).toEqual(true);
103
- });
104
- });
105
-
106
- describe('getAvailableTool', () => {
107
- it('returns the first available tool in list if there is any', () => {
108
- const tools = setToolbarAvailability(['line', 'polygon']);
109
-
110
- expect(getAvailableTool(tools).toolbar).toEqual(true);
111
- });
112
-
113
- it('returns undefined list if there is no available tool', () => {
114
- const tools = setToolbarAvailability([]);
115
-
116
- expect(getAvailableTool(tools)).toEqual(undefined);
117
- });
118
- });
119
-
120
- describe('filterByValidToolTypes', () => {
121
- it('filters marks by valid types', () => {
122
- const marks = [{ type: 'polygon' }, { type: 'a' }, { type: 'b' }, { type: 'line' }, { type: 'c' }];
123
-
124
- expect(filterByValidToolTypes(marks)).toEqual([{ type: 'polygon' }, { type: 'line' }]);
125
- });
126
- });
127
-
128
- describe('filterByVisibleToolTypes', () => {
129
- it('filters marks by the types that should be visible', () => {
130
- expect(
131
- filterByVisibleToolTypes(['line', 'polygon'], [{ type: 'point' }, { type: 'line' }, { type: 'polygon' }]),
132
- ).toEqual([{ type: 'line' }, { type: 'polygon' }]);
133
-
134
- expect(filterByVisibleToolTypes(['line'], [{ type: 'point' }, { type: 'line' }, { type: 'circle' }])).toEqual([
135
- { type: 'line' },
136
- ]);
137
-
138
- expect(filterByVisibleToolTypes(['segment'], [{ type: 'point' }, { type: 'line' }, { type: 'circle' }])).toEqual(
139
- [],
140
- );
141
- });
142
- });
143
-
144
- describe('GraphWithControls', () => {
145
- let onChangeMarks = jest.fn();
146
-
147
- beforeEach(() => {
148
- onChangeMarks.mockClear();
149
- });
150
-
151
- const defaultProps = () => ({
152
- axesSettings: { includeArrows: true },
153
- className: '',
154
- coordinatesOnHover: false,
155
- domain: { min: 0, max: 10, step: 1 },
156
- labels: { top: 'a', left: 'b', right: 'c', bottom: 'd' },
157
- labelModeEnabled: true,
158
- marks,
159
- onChangeMarks,
160
- range: { min: 0, max: 10, step: 1 },
161
- size: { width: 500, height: 500 },
162
- title: 'Title',
163
- toolbarTools: allTools,
164
- language: 'en',
165
- });
166
- const initialProps = defaultProps();
167
-
168
- const renderComponent = (extras) => {
169
- const props = { ...initialProps, ...extras };
170
- return render(<GraphWithControls {...props} />);
171
- };
172
-
173
- describe('rendering', () => {
174
- it('renders without crashing', () => {
175
- const { container } = renderComponent();
176
- expect(container.firstChild).toBeInTheDocument();
177
- });
178
-
179
- it('renders Graph component', () => {
180
- const { container } = renderComponent();
181
- expect(container.querySelector('svg')).toBeInTheDocument();
182
- });
183
- });
184
- });
@@ -1,93 +0,0 @@
1
- import { render } from '@pie-lib/test-utils';
2
- import React from 'react';
3
-
4
- import Graph, { removeBuildingToolIfCurrentToolDiffers } from '../graph';
5
- import { toolsArr } from '../tools';
6
-
7
- // Pure function tests - keep as-is
8
- describe('removeBuildingToolIfCurrentToolDiffers', () => {
9
- let marks = [
10
- {
11
- type: 'point',
12
- x: 2,
13
- y: 2,
14
- label: 'Point',
15
- showLabel: true,
16
- },
17
- {
18
- type: 'line',
19
- from: { x: 0, y: 0 },
20
- label: 'Line',
21
- building: true,
22
- },
23
- ];
24
-
25
- it('keeps all marks if currentTool is the same', () => {
26
- expect(removeBuildingToolIfCurrentToolDiffers({ marks, currentTool: { type: 'line' } })).toEqual(marks);
27
- });
28
-
29
- it('removes building marks if currentTool is different', () => {
30
- expect(removeBuildingToolIfCurrentToolDiffers({ marks, currentTool: { type: 'different' } })).toEqual([marks[0]]);
31
- });
32
- });
33
-
34
- // Note: Instance method tests have been removed. Component behavior should be tested
35
- // through user interactions and integration tests.
36
- describe('Graph', () => {
37
- let onChangeMarks = jest.fn();
38
-
39
- beforeEach(() => {
40
- onChangeMarks.mockClear();
41
- });
42
-
43
- const complete = jest.fn();
44
- const addPoint = jest.fn();
45
- const currentTool = toolsArr[0];
46
- currentTool.complete = complete;
47
- currentTool.addPoint = addPoint;
48
-
49
- const props = {
50
- className: 'className',
51
- onChangeMarks,
52
- tools: toolsArr,
53
- domain: { min: 0, max: 1, step: 1 },
54
- range: { min: 0, max: 1, step: 1 },
55
- size: { width: 400, height: 400 },
56
- currentTool,
57
- };
58
-
59
- const renderComponent = (extras) => {
60
- const properties = {
61
- ...props,
62
- marks: [
63
- {
64
- type: 'point',
65
- x: 2,
66
- y: 2,
67
- label: 'Point',
68
- showLabel: true,
69
- },
70
- {
71
- type: 'line',
72
- from: { x: 0, y: 0 },
73
- label: 'Line',
74
- building: true,
75
- },
76
- ],
77
- ...extras,
78
- };
79
- return render(<Graph {...properties} />);
80
- };
81
-
82
- describe('rendering', () => {
83
- it('renders without crashing', () => {
84
- const { container } = renderComponent();
85
- expect(container.firstChild).toBeInTheDocument();
86
- });
87
-
88
- it('renders SVG graph', () => {
89
- const { container } = renderComponent();
90
- expect(container.querySelector('svg')).toBeInTheDocument();
91
- });
92
- });
93
- });