@pie-lib/graphing-solution-set 4.0.21 → 4.0.22-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 (36) hide show
  1. package/CHANGELOG.md +0 -78
  2. package/package.json +18 -18
  3. package/LICENSE.md +0 -5
  4. package/src/__tests__/bg.test.jsx +0 -250
  5. package/src/__tests__/coordinates-label.test.jsx +0 -243
  6. package/src/__tests__/graph-with-controls.test.jsx +0 -184
  7. package/src/__tests__/graph.test.jsx +0 -93
  8. package/src/__tests__/grid-setup.test.jsx +0 -645
  9. package/src/__tests__/grid.test.jsx +0 -23
  10. package/src/__tests__/labels.test.jsx +0 -41
  11. package/src/__tests__/mark-label.test.jsx +0 -66
  12. package/src/__tests__/toggle-bar.test.jsx +0 -106
  13. package/src/__tests__/tool-menu.test.jsx +0 -453
  14. package/src/__tests__/undo-redo.test.jsx +0 -26
  15. package/src/__tests__/use-debounce.test.js +0 -21
  16. package/src/__tests__/utils.js +0 -41
  17. package/src/__tests__/utils.test.js +0 -105
  18. package/src/axis/__tests__/arrow.test.jsx +0 -43
  19. package/src/axis/__tests__/axes.test.jsx +0 -182
  20. package/src/container/__tests__/actions.test.js +0 -105
  21. package/src/container/__tests__/index.test.jsx +0 -227
  22. package/src/container/__tests__/marks.test.js +0 -172
  23. package/src/container/__tests__/middleware.test.js +0 -235
  24. package/src/container/__tests__/reducer.test.js +0 -324
  25. package/src/tools/line/__tests__/component.test.jsx +0 -37
  26. package/src/tools/polygon/__tests__/component.test.jsx +0 -487
  27. package/src/tools/polygon/__tests__/index.test.js +0 -65
  28. package/src/tools/polygon/__tests__/line.test.jsx +0 -23
  29. package/src/tools/polygon/__tests__/polygon.test.jsx +0 -44
  30. package/src/tools/shared/__tests__/arrow-head.test.jsx +0 -33
  31. package/src/tools/shared/line/__tests__/index.test.jsx +0 -553
  32. package/src/tools/shared/line/__tests__/line-path.test.jsx +0 -56
  33. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +0 -488
  34. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +0 -91
  35. package/src/tools/shared/point/__tests__/arrow.test.jsx +0 -469
  36. package/src/tools/shared/point/__tests__/base-point.test.jsx +0 -87
@@ -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
- });