@pie-lib/charting 7.1.0-beta.8 → 7.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.
- package/package.json +2 -2
- package/src/__tests__/actions-button.test.jsx +0 -280
- package/src/__tests__/axes.test.jsx +0 -667
- package/src/__tests__/chart-setup.test.jsx +0 -532
- package/src/__tests__/chart-type.test.jsx +0 -23
- package/src/__tests__/chart.test.jsx +0 -86
- package/src/__tests__/grid.test.jsx +0 -37
- package/src/__tests__/key-legend.test.jsx +0 -223
- package/src/__tests__/mark-label.test.jsx +0 -33
- package/src/__tests__/tool-menu.test.jsx +0 -522
- package/src/__tests__/utils.js +0 -36
- package/src/__tests__/utils.test.js +0 -100
- package/src/bars/__tests__/bar.test.jsx +0 -45
- package/src/bars/__tests__/histogram.test.jsx +0 -45
- package/src/bars/__tests__/utils.js +0 -30
- package/src/bars/common/__tests__/bars.test.jsx +0 -68
- package/src/bars/common/__tests__/utils.js +0 -30
- package/src/common/__tests__/correctness-indicators.test.jsx +0 -720
- package/src/common/__tests__/drag-handle.test.jsx +0 -58
- package/src/common/__tests__/utils.js +0 -30
- package/src/line/__tests__/line-cross.test.jsx +0 -463
- package/src/line/__tests__/line-dot.test.jsx +0 -41
- package/src/line/__tests__/utils.js +0 -36
- package/src/line/common/__tests__/drag-handle.test.jsx +0 -62
- package/src/line/common/__tests__/line.test.jsx +0 -79
- package/src/line/common/__tests__/utils.js +0 -30
- package/src/plot/__tests__/dot.test.jsx +0 -344
- package/src/plot/__tests__/line.test.jsx +0 -375
- package/src/plot/__tests__/utils.js +0 -30
- package/src/plot/common/__tests__/plot.test.jsx +0 -69
- package/src/plot/common/__tests__/utils.js +0 -30
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '@pie-lib/test-utils';
|
|
3
|
-
import { createTheme, ThemeProvider } from '@mui/material/styles';
|
|
4
|
-
import Line, { LinePlot } from '../line';
|
|
5
|
-
import { graphProps } from './utils';
|
|
6
|
-
|
|
7
|
-
jest.mock('@mui/icons-material/Check', () => {
|
|
8
|
-
return function Check(props) {
|
|
9
|
-
return <div data-testid="check-icon" {...props} />;
|
|
10
|
-
};
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
jest.mock('@visx/shape', () => ({
|
|
14
|
-
LinePath: ({ data, x, y, ...rest }) => (
|
|
15
|
-
<path d={data.map((d, i) => `${i === 0 ? 'M' : 'L'}${x(d)},${y(d)}`).join(' ')} {...rest} />
|
|
16
|
-
),
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
jest.mock('@visx/group', () => ({
|
|
20
|
-
Group: ({ children }) => <g className="visx-group">{children}</g>,
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
let theme;
|
|
24
|
-
|
|
25
|
-
beforeAll(() => {
|
|
26
|
-
theme = createTheme();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe('LinePlot', () => {
|
|
30
|
-
const renderComponent = (extras) => {
|
|
31
|
-
const defaults = {
|
|
32
|
-
classes: {},
|
|
33
|
-
className: 'className',
|
|
34
|
-
graphProps: graphProps(),
|
|
35
|
-
xBand: () => {
|
|
36
|
-
return {
|
|
37
|
-
bandwidth: () => {},
|
|
38
|
-
};
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
const props = { ...defaults, ...extras };
|
|
42
|
-
return render(
|
|
43
|
-
<ThemeProvider theme={theme}>
|
|
44
|
-
<svg>
|
|
45
|
-
<LinePlot {...props} />
|
|
46
|
-
</svg>
|
|
47
|
-
</ThemeProvider>,
|
|
48
|
-
);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
describe('rendering', () => {
|
|
52
|
-
it('renders line plot', () => {
|
|
53
|
-
const { container } = renderComponent();
|
|
54
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('renders without graphProps', () => {
|
|
58
|
-
const { container } = renderComponent({ graphProps: undefined });
|
|
59
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('renders with data array', () => {
|
|
63
|
-
const data = [
|
|
64
|
-
{ value: 1, label: 'A' },
|
|
65
|
-
{ value: 2, label: 'B' },
|
|
66
|
-
{ value: 3, label: 'C' },
|
|
67
|
-
];
|
|
68
|
-
const { container } = renderComponent({ data });
|
|
69
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('renders with empty data array', () => {
|
|
73
|
-
const { container } = renderComponent({ data: [] });
|
|
74
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('renders with null data', () => {
|
|
78
|
-
const { container } = renderComponent({ data: null });
|
|
79
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('renders with undefined data', () => {
|
|
83
|
-
const { container } = renderComponent({ data: undefined });
|
|
84
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('renders with custom className', () => {
|
|
88
|
-
const { container } = renderComponent({ className: 'custom-line-plot' });
|
|
89
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('renders with onChange handler', () => {
|
|
93
|
-
const onChange = jest.fn();
|
|
94
|
-
const { container } = renderComponent({ onChange });
|
|
95
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('renders in defineChart mode', () => {
|
|
99
|
-
const { container } = renderComponent({ defineChart: true });
|
|
100
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('renders with correctData', () => {
|
|
104
|
-
const data = [{ value: 2, label: 'A' }];
|
|
105
|
-
const correctData = [{ value: 3, label: 'A' }];
|
|
106
|
-
const { container } = renderComponent({ data, correctData });
|
|
107
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe('graphProps handling', () => {
|
|
112
|
-
it('handles graphProps with missing scale', () => {
|
|
113
|
-
const props = graphProps();
|
|
114
|
-
delete props.scale;
|
|
115
|
-
const { container } = renderComponent({ graphProps: props });
|
|
116
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('handles graphProps with missing size', () => {
|
|
120
|
-
const props = graphProps();
|
|
121
|
-
delete props.size;
|
|
122
|
-
const { container } = renderComponent({ graphProps: props });
|
|
123
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('handles graphProps with empty scale object', () => {
|
|
127
|
-
const props = graphProps();
|
|
128
|
-
props.scale = {};
|
|
129
|
-
const { container } = renderComponent({ graphProps: props });
|
|
130
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('handles graphProps with empty size object', () => {
|
|
134
|
-
const props = graphProps();
|
|
135
|
-
props.size = {};
|
|
136
|
-
const { container } = renderComponent({ graphProps: props });
|
|
137
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
describe('data variations', () => {
|
|
142
|
-
it('renders with single data point', () => {
|
|
143
|
-
const data = [{ value: 1, label: 'A' }];
|
|
144
|
-
const { container } = renderComponent({ data });
|
|
145
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('renders with multiple data points', () => {
|
|
149
|
-
const data = [
|
|
150
|
-
{ value: 1, label: 'A' },
|
|
151
|
-
{ value: 2, label: 'B' },
|
|
152
|
-
{ value: 3, label: 'C' },
|
|
153
|
-
{ value: 4, label: 'D' },
|
|
154
|
-
];
|
|
155
|
-
const { container } = renderComponent({ data });
|
|
156
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it('renders with zero values', () => {
|
|
160
|
-
const data = [
|
|
161
|
-
{ value: 0, label: 'A' },
|
|
162
|
-
{ value: 0, label: 'B' },
|
|
163
|
-
];
|
|
164
|
-
const { container } = renderComponent({ data });
|
|
165
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('renders with mixed values', () => {
|
|
169
|
-
const data = [
|
|
170
|
-
{ value: 0, label: 'A' },
|
|
171
|
-
{ value: 5, label: 'B' },
|
|
172
|
-
{ value: 1, label: 'C' },
|
|
173
|
-
];
|
|
174
|
-
const { container } = renderComponent({ data });
|
|
175
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('renders with large values', () => {
|
|
179
|
-
const data = [
|
|
180
|
-
{ value: 100, label: 'A' },
|
|
181
|
-
{ value: 200, label: 'B' },
|
|
182
|
-
];
|
|
183
|
-
const { container } = renderComponent({ data });
|
|
184
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it('renders with correctness data', () => {
|
|
188
|
-
const data = [
|
|
189
|
-
{ value: 2, label: 'A', correctness: { value: 'correct', label: 'Correct' } },
|
|
190
|
-
{ value: 3, label: 'B', correctness: { value: 'correct', label: 'Correct' } },
|
|
191
|
-
];
|
|
192
|
-
const { container } = renderComponent({ data });
|
|
193
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it('renders with incorrect correctness and correctData', () => {
|
|
197
|
-
const data = [
|
|
198
|
-
{ value: 2, label: 'A', correctness: { value: 'incorrect', label: 'Incorrect' } },
|
|
199
|
-
{ value: 3, label: 'B', correctness: { value: 'incorrect', label: 'Incorrect' } },
|
|
200
|
-
];
|
|
201
|
-
const correctData = [
|
|
202
|
-
{ value: 3, label: 'A' },
|
|
203
|
-
{ value: 4, label: 'B' },
|
|
204
|
-
];
|
|
205
|
-
const { container } = renderComponent({ data, correctData });
|
|
206
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it('renders with interactive data points', () => {
|
|
210
|
-
const data = [
|
|
211
|
-
{ value: 2, label: 'A', interactive: true },
|
|
212
|
-
{ value: 3, label: 'B', interactive: false },
|
|
213
|
-
];
|
|
214
|
-
const { container } = renderComponent({ data });
|
|
215
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
describe('callbacks', () => {
|
|
220
|
-
it('passes onChange handler to Plot component', () => {
|
|
221
|
-
const onChange = jest.fn();
|
|
222
|
-
const data = [{ value: 1, label: 'A' }];
|
|
223
|
-
const { container } = renderComponent({ data, onChange });
|
|
224
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it('handles onChangeCategory callback', () => {
|
|
228
|
-
const onChangeCategory = jest.fn();
|
|
229
|
-
const data = [{ value: 1, label: 'A' }];
|
|
230
|
-
const { container } = renderComponent({ data, onChangeCategory });
|
|
231
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
describe('component', () => {
|
|
236
|
-
it('returns correct chart object', () => {
|
|
237
|
-
const chart = Line();
|
|
238
|
-
|
|
239
|
-
expect(chart).toEqual({
|
|
240
|
-
type: 'linePlot',
|
|
241
|
-
Component: LinePlot,
|
|
242
|
-
name: 'Line Plot',
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('returns object with Component that can be rendered', () => {
|
|
247
|
-
const chart = Line();
|
|
248
|
-
const { Component } = chart;
|
|
249
|
-
|
|
250
|
-
const { container } = render(<Component graphProps={graphProps()} />);
|
|
251
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
describe('CustomBarElement (Line)', () => {
|
|
257
|
-
const renderLinePlot = (props) =>
|
|
258
|
-
render(
|
|
259
|
-
<ThemeProvider theme={theme}>
|
|
260
|
-
<svg>
|
|
261
|
-
<LinePlot {...props} />
|
|
262
|
-
</svg>
|
|
263
|
-
</ThemeProvider>,
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
it('renders line elements', () => {
|
|
267
|
-
const data = [{ value: 1, label: 'A' }];
|
|
268
|
-
const { container } = renderLinePlot({
|
|
269
|
-
data,
|
|
270
|
-
graphProps: graphProps(),
|
|
271
|
-
});
|
|
272
|
-
expect(container).toBeInTheDocument();
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
it('renders with dottedOverline prop', () => {
|
|
276
|
-
const data = [{ value: 2, label: 'A', correctness: { value: 'incorrect' } }];
|
|
277
|
-
const correctData = [{ value: 3, label: 'A' }];
|
|
278
|
-
const { container } = renderLinePlot({
|
|
279
|
-
data,
|
|
280
|
-
graphProps: graphProps(),
|
|
281
|
-
correctData,
|
|
282
|
-
});
|
|
283
|
-
expect(container).toBeInTheDocument();
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
it('renders without dottedOverline prop', () => {
|
|
287
|
-
const data = [{ value: 2, label: 'A' }];
|
|
288
|
-
const { container } = renderLinePlot({
|
|
289
|
-
data,
|
|
290
|
-
graphProps: graphProps(),
|
|
291
|
-
});
|
|
292
|
-
expect(container).toBeInTheDocument();
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
it('renders two LinePath elements for X shape when not dotted', () => {
|
|
296
|
-
const data = [{ value: 3, label: 'A' }];
|
|
297
|
-
const { container } = renderLinePlot({
|
|
298
|
-
data,
|
|
299
|
-
graphProps: graphProps(),
|
|
300
|
-
});
|
|
301
|
-
expect(container).toBeInTheDocument();
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
it('renders rect with dashed stroke when dottedOverline is true', () => {
|
|
305
|
-
const data = [{ value: 2, label: 'A', correctness: { value: 'incorrect' } }];
|
|
306
|
-
const correctData = [{ value: 3, label: 'A' }];
|
|
307
|
-
const { container } = renderLinePlot({
|
|
308
|
-
data,
|
|
309
|
-
graphProps: graphProps(),
|
|
310
|
-
correctData,
|
|
311
|
-
});
|
|
312
|
-
expect(container).toBeInTheDocument();
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
it('calculates correct line positions', () => {
|
|
316
|
-
const data = [{ value: 2, label: 'A' }];
|
|
317
|
-
const { container } = renderLinePlot({
|
|
318
|
-
data,
|
|
319
|
-
graphProps: graphProps(),
|
|
320
|
-
});
|
|
321
|
-
expect(container).toBeInTheDocument();
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
it('handles zero pointDiameter', () => {
|
|
325
|
-
const props = graphProps();
|
|
326
|
-
props.size = { width: 0, height: 0 };
|
|
327
|
-
const data = [{ value: 1, label: 'A' }];
|
|
328
|
-
const { container } = renderLinePlot({
|
|
329
|
-
data,
|
|
330
|
-
graphProps: props,
|
|
331
|
-
});
|
|
332
|
-
expect(container).toBeInTheDocument();
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
it('handles large pointDiameter values', () => {
|
|
336
|
-
const props = graphProps();
|
|
337
|
-
props.size = { width: 1000, height: 1000 };
|
|
338
|
-
const data = [{ value: 1, label: 'A' }];
|
|
339
|
-
const { container } = renderLinePlot({
|
|
340
|
-
data,
|
|
341
|
-
graphProps: props,
|
|
342
|
-
});
|
|
343
|
-
expect(container).toBeInTheDocument();
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
it('applies correct strokeWidth based on pointDiameter', () => {
|
|
347
|
-
const data = [{ value: 2, label: 'A' }];
|
|
348
|
-
const { container } = renderLinePlot({
|
|
349
|
-
data,
|
|
350
|
-
graphProps: graphProps(),
|
|
351
|
-
});
|
|
352
|
-
// strokeWidth should be pointDiameter / 5
|
|
353
|
-
expect(container).toBeInTheDocument();
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
it('renders Group component wrapping LinePaths', () => {
|
|
357
|
-
const data = [{ value: 1, label: 'A' }];
|
|
358
|
-
const { container } = renderLinePlot({
|
|
359
|
-
data,
|
|
360
|
-
graphProps: graphProps(),
|
|
361
|
-
});
|
|
362
|
-
expect(container).toBeInTheDocument();
|
|
363
|
-
});
|
|
364
|
-
|
|
365
|
-
it('handles rect with extra padding when dotted', () => {
|
|
366
|
-
const data = [{ value: 2, label: 'A', correctness: { value: 'incorrect' } }];
|
|
367
|
-
const correctData = [{ value: 3, label: 'A' }];
|
|
368
|
-
const { container } = renderLinePlot({
|
|
369
|
-
data,
|
|
370
|
-
graphProps: graphProps(),
|
|
371
|
-
correctData,
|
|
372
|
-
});
|
|
373
|
-
expect(container).toBeInTheDocument();
|
|
374
|
-
});
|
|
375
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export const scaleMock = () => {
|
|
2
|
-
const fn = jest.fn((n) => n);
|
|
3
|
-
fn.invert = jest.fn((n) => n);
|
|
4
|
-
return fn;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const graphProps = (dmin = 0, dmax = 1, rmin = 0, rmax = 1) => ({
|
|
8
|
-
scale: {
|
|
9
|
-
x: scaleMock(),
|
|
10
|
-
y: scaleMock(),
|
|
11
|
-
},
|
|
12
|
-
snap: {
|
|
13
|
-
x: jest.fn((n) => n),
|
|
14
|
-
y: jest.fn((n) => n),
|
|
15
|
-
},
|
|
16
|
-
domain: {
|
|
17
|
-
min: dmin,
|
|
18
|
-
max: dmax,
|
|
19
|
-
step: 1,
|
|
20
|
-
},
|
|
21
|
-
range: {
|
|
22
|
-
min: rmin,
|
|
23
|
-
max: rmax,
|
|
24
|
-
step: 1,
|
|
25
|
-
},
|
|
26
|
-
size: {
|
|
27
|
-
width: 400,
|
|
28
|
-
height: 400,
|
|
29
|
-
},
|
|
30
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import Plot, { RawPlot } from '../plot';
|
|
4
|
-
import { graphProps } from './utils';
|
|
5
|
-
|
|
6
|
-
describe('Plot', () => {
|
|
7
|
-
const xBand = () => {};
|
|
8
|
-
xBand.bandwidth = () => {};
|
|
9
|
-
const onChange = jest.fn();
|
|
10
|
-
|
|
11
|
-
const renderComponent = (extras) => {
|
|
12
|
-
const defaults = {
|
|
13
|
-
classes: {},
|
|
14
|
-
className: 'className',
|
|
15
|
-
graphProps: graphProps(),
|
|
16
|
-
xBand,
|
|
17
|
-
onChange,
|
|
18
|
-
data: [{ value: 0, label: '0' }],
|
|
19
|
-
};
|
|
20
|
-
const props = { ...defaults, ...extras };
|
|
21
|
-
return render(<Plot {...props} />);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
describe('rendering', () => {
|
|
25
|
-
it('renders without crashing', () => {
|
|
26
|
-
const { container } = renderComponent();
|
|
27
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe('RawPlot', () => {
|
|
33
|
-
const xBand = () => {};
|
|
34
|
-
xBand.bandwidth = () => {};
|
|
35
|
-
const onChangeCategory = jest.fn();
|
|
36
|
-
|
|
37
|
-
const renderComponent = (extras) => {
|
|
38
|
-
const defaults = {
|
|
39
|
-
classes: {},
|
|
40
|
-
className: 'className',
|
|
41
|
-
graphProps: graphProps(),
|
|
42
|
-
xBand,
|
|
43
|
-
onChangeCategory,
|
|
44
|
-
data: [],
|
|
45
|
-
label: 'label',
|
|
46
|
-
CustomBarElement: () => <div />,
|
|
47
|
-
};
|
|
48
|
-
const props = { ...defaults, ...extras };
|
|
49
|
-
return render(<RawPlot {...props} />);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
describe('rendering', () => {
|
|
53
|
-
it('renders without crashing', () => {
|
|
54
|
-
const { container } = renderComponent();
|
|
55
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe('functionality', () => {
|
|
60
|
-
it('calls onChangeCategory when drag completes with a value', () => {
|
|
61
|
-
const { container } = renderComponent();
|
|
62
|
-
// Testing drag functionality requires interaction - the component should
|
|
63
|
-
// call onChangeCategory when a drag operation completes with a new value
|
|
64
|
-
// This would typically be tested through user interactions rather than
|
|
65
|
-
// directly calling instance methods
|
|
66
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export const scaleMock = () => {
|
|
2
|
-
const fn = jest.fn((n) => n);
|
|
3
|
-
fn.invert = jest.fn((n) => n);
|
|
4
|
-
return fn;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const graphProps = (dmin = 0, dmax = 1, rmin = 0, rmax = 1) => ({
|
|
8
|
-
scale: {
|
|
9
|
-
x: scaleMock(),
|
|
10
|
-
y: scaleMock(),
|
|
11
|
-
},
|
|
12
|
-
snap: {
|
|
13
|
-
x: jest.fn((n) => n),
|
|
14
|
-
y: jest.fn((n) => n),
|
|
15
|
-
},
|
|
16
|
-
domain: {
|
|
17
|
-
min: dmin,
|
|
18
|
-
max: dmax,
|
|
19
|
-
step: 1,
|
|
20
|
-
},
|
|
21
|
-
range: {
|
|
22
|
-
min: rmin,
|
|
23
|
-
max: rmax,
|
|
24
|
-
step: 1,
|
|
25
|
-
},
|
|
26
|
-
size: {
|
|
27
|
-
width: 400,
|
|
28
|
-
height: 400,
|
|
29
|
-
},
|
|
30
|
-
});
|