@pie-lib/graphing 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.
- package/lib/axis/arrow.js +0 -3
- package/lib/axis/arrow.js.map +1 -1
- package/lib/axis/axes.js +0 -16
- package/lib/axis/axes.js.map +1 -1
- package/lib/axis/index.js +0 -7
- package/lib/axis/index.js.map +1 -1
- package/lib/bg.js +0 -6
- package/lib/bg.js.map +1 -1
- package/lib/container/actions.js +0 -1
- package/lib/container/actions.js.map +1 -1
- package/lib/container/index.js +4 -8
- package/lib/container/index.js.map +1 -1
- package/lib/container/marks.js +0 -2
- package/lib/container/marks.js.map +1 -1
- package/lib/container/middleware.js +0 -1
- package/lib/container/middleware.js.map +1 -1
- package/lib/container/reducer.js +0 -1
- package/lib/container/reducer.js.map +1 -1
- package/lib/coordinates-label.js +0 -11
- package/lib/coordinates-label.js.map +1 -1
- package/lib/graph-with-controls.js +3 -21
- package/lib/graph-with-controls.js.map +1 -1
- package/lib/graph.js +8 -27
- package/lib/graph.js.map +1 -1
- package/lib/grid-setup.js +0 -11
- package/lib/grid-setup.js.map +1 -1
- package/lib/grid.js +0 -22
- package/lib/grid.js.map +1 -1
- package/lib/index.js +0 -7
- package/lib/index.js.map +1 -1
- package/lib/key-legend.js +1 -2
- package/lib/key-legend.js.map +1 -1
- package/lib/label-svg-icon.js +0 -1
- package/lib/label-svg-icon.js.map +1 -1
- package/lib/labels.js +0 -13
- package/lib/labels.js.map +1 -1
- package/lib/mark-label.js +0 -15
- package/lib/mark-label.js.map +1 -1
- package/lib/toggle-bar.js +0 -17
- package/lib/toggle-bar.js.map +1 -1
- package/lib/tool-menu.js +0 -3
- package/lib/tool-menu.js.map +1 -1
- package/lib/tools/absolute/component.js +0 -1
- package/lib/tools/absolute/component.js.map +1 -1
- package/lib/tools/absolute/index.js +0 -10
- package/lib/tools/absolute/index.js.map +1 -1
- package/lib/tools/circle/bg-circle.js +0 -15
- package/lib/tools/circle/bg-circle.js.map +1 -1
- package/lib/tools/circle/component.js +2 -15
- package/lib/tools/circle/component.js.map +1 -1
- package/lib/tools/circle/index.js +0 -10
- package/lib/tools/circle/index.js.map +1 -1
- package/lib/tools/exponential/component.js +0 -1
- package/lib/tools/exponential/component.js.map +1 -1
- package/lib/tools/exponential/index.js +0 -10
- package/lib/tools/exponential/index.js.map +1 -1
- package/lib/tools/index.js +0 -1
- package/lib/tools/index.js.map +1 -1
- package/lib/tools/line/component.js +0 -2
- package/lib/tools/line/component.js.map +1 -1
- package/lib/tools/line/index.js +0 -1
- package/lib/tools/line/index.js.map +1 -1
- package/lib/tools/parabola/component.js +0 -1
- package/lib/tools/parabola/component.js.map +1 -1
- package/lib/tools/parabola/index.js +0 -10
- package/lib/tools/parabola/index.js.map +1 -1
- package/lib/tools/point/component.js +3 -15
- package/lib/tools/point/component.js.map +1 -1
- package/lib/tools/point/index.js +0 -10
- package/lib/tools/point/index.js.map +1 -1
- package/lib/tools/polygon/component.js +5 -29
- package/lib/tools/polygon/component.js.map +1 -1
- package/lib/tools/polygon/index.js +0 -12
- package/lib/tools/polygon/index.js.map +1 -1
- package/lib/tools/polygon/line.js +0 -15
- package/lib/tools/polygon/line.js.map +1 -1
- package/lib/tools/polygon/polygon.js +0 -18
- package/lib/tools/polygon/polygon.js.map +1 -1
- package/lib/tools/ray/component.js +0 -11
- package/lib/tools/ray/component.js.map +1 -1
- package/lib/tools/ray/index.js +0 -1
- package/lib/tools/ray/index.js.map +1 -1
- package/lib/tools/segment/component.js +0 -10
- package/lib/tools/segment/component.js.map +1 -1
- package/lib/tools/segment/index.js +0 -1
- package/lib/tools/segment/index.js.map +1 -1
- package/lib/tools/shared/arrow-head.js +0 -14
- package/lib/tools/shared/arrow-head.js.map +1 -1
- package/lib/tools/shared/icons/CorrectSVG.js +0 -1
- package/lib/tools/shared/icons/CorrectSVG.js.map +1 -1
- package/lib/tools/shared/icons/IncorrectSVG.js +0 -1
- package/lib/tools/shared/icons/IncorrectSVG.js.map +1 -1
- package/lib/tools/shared/icons/MissingSVG.js +0 -1
- package/lib/tools/shared/icons/MissingSVG.js.map +1 -1
- package/lib/tools/shared/line/index.js +7 -21
- package/lib/tools/shared/line/index.js.map +1 -1
- package/lib/tools/shared/line/line-path.js +0 -15
- package/lib/tools/shared/line/line-path.js.map +1 -1
- package/lib/tools/shared/line/with-root-edge.js +0 -11
- package/lib/tools/shared/line/with-root-edge.js.map +1 -1
- package/lib/tools/shared/point/arrow-point.js +0 -3
- package/lib/tools/shared/point/arrow-point.js.map +1 -1
- package/lib/tools/shared/point/arrow.js +0 -3
- package/lib/tools/shared/point/arrow.js.map +1 -1
- package/lib/tools/shared/point/base-point.js +0 -16
- package/lib/tools/shared/point/base-point.js.map +1 -1
- package/lib/tools/shared/point/index.js +0 -7
- package/lib/tools/shared/point/index.js.map +1 -1
- package/lib/tools/shared/styles.js +0 -1
- package/lib/tools/shared/styles.js.map +1 -1
- package/lib/tools/shared/types.js +0 -1
- package/lib/tools/shared/types.js.map +1 -1
- package/lib/tools/sine/component.js +0 -10
- package/lib/tools/sine/component.js.map +1 -1
- package/lib/tools/sine/index.js +0 -10
- package/lib/tools/sine/index.js.map +1 -1
- package/lib/tools/vector/component.js +0 -10
- package/lib/tools/vector/component.js.map +1 -1
- package/lib/tools/vector/index.js +0 -1
- package/lib/tools/vector/index.js.map +1 -1
- package/lib/undo-redo.js +0 -2
- package/lib/undo-redo.js.map +1 -1
- package/lib/use-debounce.js +0 -2
- package/lib/use-debounce.js.map +1 -1
- package/lib/utils.js +9 -26
- package/lib/utils.js.map +1 -1
- package/package.json +13 -10
- package/src/__tests__/bg.test.jsx +250 -0
- package/src/__tests__/coordinates-label.test.jsx +243 -0
- package/src/__tests__/graph-with-controls.test.jsx +9 -16
- package/src/__tests__/graph.test.jsx +560 -5
- package/src/__tests__/grid-setup.test.jsx +645 -0
- package/src/__tests__/grid.test.jsx +1 -1
- package/src/__tests__/key-legend.test.jsx +260 -0
- package/src/__tests__/label-svg-icon.test.jsx +278 -0
- package/src/__tests__/mark-label.test.jsx +1 -1
- package/src/__tests__/toggle-bar.test.jsx +0 -6
- package/src/__tests__/tool-menu.test.jsx +0 -4
- package/src/__tests__/use-debounce.test.js +1 -1
- package/src/__tests__/utils.test.js +15 -61
- package/src/axis/__tests__/axes.test.jsx +1 -1
- package/src/axis/axes.jsx +7 -21
- package/src/axis/index.js +1 -0
- package/src/bg.jsx +1 -1
- package/src/container/__tests__/actions.test.js +105 -0
- package/src/container/__tests__/index.test.jsx +319 -0
- package/src/container/__tests__/marks.test.js +172 -0
- package/src/container/__tests__/middleware.test.js +235 -0
- package/src/container/__tests__/reducer.test.js +324 -0
- package/src/container/index.jsx +2 -3
- package/src/coordinates-label.jsx +1 -7
- package/src/graph-with-controls.jsx +8 -6
- package/src/graph.jsx +2 -3
- package/src/grid-setup.jsx +1 -1
- package/src/key-legend.jsx +2 -1
- package/src/mark-label.jsx +7 -24
- package/src/toggle-bar.jsx +8 -1
- package/src/tools/absolute/__tests__/component.test.jsx +1 -2
- package/src/tools/absolute/component.jsx +2 -2
- package/src/tools/circle/__tests__/component.test.jsx +438 -0
- package/src/tools/circle/__tests__/index.test.js +480 -0
- package/src/tools/circle/bg-circle.jsx +2 -2
- package/src/tools/circle/component.jsx +10 -12
- package/src/tools/exponential/__tests__/component.test.jsx +0 -1
- package/src/tools/exponential/__tests__/index.test.js +729 -0
- package/src/tools/exponential/component.jsx +1 -1
- package/src/tools/line/__tests__/component.test.jsx +1 -0
- package/src/tools/line/component.jsx +4 -11
- package/src/tools/parabola/__tests__/component.test.jsx +0 -1
- package/src/tools/parabola/__tests__/index.test.js +470 -0
- package/src/tools/parabola/component.jsx +1 -1
- package/src/tools/point/__tests__/component.test.jsx +310 -2
- package/src/tools/point/__tests__/index.test.js +241 -0
- package/src/tools/point/component.jsx +1 -2
- package/src/tools/polygon/__tests__/component.test.jsx +391 -2
- package/src/tools/polygon/__tests__/index.test.js +237 -8
- package/src/tools/polygon/__tests__/line.test.jsx +13 -0
- package/src/tools/polygon/__tests__/polygon.test.jsx +19 -1
- package/src/tools/polygon/component.jsx +4 -14
- package/src/tools/polygon/line.jsx +1 -1
- package/src/tools/polygon/polygon.jsx +1 -1
- package/src/tools/ray/__tests__/component.test.jsx +1 -0
- package/src/tools/ray/component.jsx +3 -5
- package/src/tools/segment/__tests__/component.test.jsx +1 -0
- package/src/tools/segment/component.jsx +1 -1
- package/src/tools/shared/arrow-head.jsx +11 -6
- package/src/tools/shared/line/__tests__/index.test.jsx +1 -1
- package/src/tools/shared/line/__tests__/line-path.test.jsx +3 -3
- package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +2 -2
- package/src/tools/shared/line/index.jsx +4 -6
- package/src/tools/shared/line/line-path.jsx +2 -8
- package/src/tools/shared/point/arrow-point.jsx +2 -5
- package/src/tools/sine/component.jsx +2 -2
- package/src/tools/vector/component.jsx +1 -1
- package/src/undo-redo.jsx +3 -9
- package/src/use-debounce.js +1 -1
- package/src/utils.js +1 -5
- package/NEXT.CHANGELOG.json +0 -16
|
@@ -45,6 +45,444 @@ describe('Component', () => {
|
|
|
45
45
|
const { container } = renderWithLabels();
|
|
46
46
|
expect(container.firstChild).toBeInTheDocument();
|
|
47
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
|
+
});
|
|
48
486
|
});
|
|
49
487
|
|
|
50
488
|
// Note: Instance method tests (dragFrom, dragTo, dragCircle, labelChange, clickPoint)
|