@pie-lib/charting 5.15.6 → 5.15.7-next.1618

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 (109) hide show
  1. package/CHANGELOG.json +1 -581
  2. package/CHANGELOG.md +206 -38
  3. package/NEXT.CHANGELOG.json +1 -0
  4. package/lib/actions-button.js +175 -0
  5. package/lib/actions-button.js.map +1 -0
  6. package/lib/axes.js +154 -104
  7. package/lib/axes.js.map +1 -1
  8. package/lib/bars/common/bars.js +105 -19
  9. package/lib/bars/common/bars.js.map +1 -1
  10. package/lib/bars/common/correct-check-icon.js +55 -0
  11. package/lib/bars/common/correct-check-icon.js.map +1 -0
  12. package/lib/chart-type.js +4 -4
  13. package/lib/chart-type.js.map +1 -1
  14. package/lib/chart.js +96 -65
  15. package/lib/chart.js.map +1 -1
  16. package/lib/common/correctness-indicators.js +99 -0
  17. package/lib/common/correctness-indicators.js.map +1 -0
  18. package/lib/common/drag-handle.js +47 -13
  19. package/lib/common/drag-handle.js.map +1 -1
  20. package/lib/common/drag-icon.js +7 -24
  21. package/lib/common/drag-icon.js.map +1 -1
  22. package/lib/grid.js +47 -10
  23. package/lib/grid.js.map +1 -1
  24. package/lib/index.js +8 -0
  25. package/lib/index.js.map +1 -1
  26. package/lib/key-legend.js +111 -0
  27. package/lib/key-legend.js.map +1 -0
  28. package/lib/line/common/drag-handle.js +40 -18
  29. package/lib/line/common/drag-handle.js.map +1 -1
  30. package/lib/line/common/line.js +7 -8
  31. package/lib/line/common/line.js.map +1 -1
  32. package/lib/line/line-cross.js +76 -9
  33. package/lib/line/line-cross.js.map +1 -1
  34. package/lib/line/line-dot.js +58 -5
  35. package/lib/line/line-dot.js.map +1 -1
  36. package/lib/mark-label.js +40 -15
  37. package/lib/mark-label.js.map +1 -1
  38. package/lib/plot/common/plot.js +129 -16
  39. package/lib/plot/common/plot.js.map +1 -1
  40. package/lib/plot/dot.js +17 -4
  41. package/lib/plot/dot.js.map +1 -1
  42. package/lib/plot/line.js +19 -6
  43. package/lib/plot/line.js.map +1 -1
  44. package/lib/tool-menu.js +0 -4
  45. package/lib/tool-menu.js.map +1 -1
  46. package/package.json +6 -8
  47. package/src/__tests__/__snapshots__/axes.test.jsx.snap +569 -0
  48. package/src/__tests__/__snapshots__/chart-type.test.jsx.snap +14 -0
  49. package/src/__tests__/__snapshots__/chart.test.jsx.snap +595 -0
  50. package/src/__tests__/__snapshots__/grid.test.jsx.snap +72 -0
  51. package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +73 -0
  52. package/src/__tests__/axes.test.jsx +141 -0
  53. package/src/__tests__/chart-setup.test.jsx +47 -0
  54. package/src/__tests__/chart-type.test.jsx +29 -0
  55. package/src/__tests__/chart.test.jsx +95 -0
  56. package/src/__tests__/grid.test.jsx +25 -0
  57. package/src/__tests__/mark-label.test.jsx +31 -0
  58. package/src/__tests__/utils.js +30 -0
  59. package/src/__tests__/utils.test.js +100 -0
  60. package/src/actions-button.jsx +110 -0
  61. package/src/axes.jsx +98 -54
  62. package/src/bars/__tests__/__snapshots__/bar.test.jsx.snap +43 -0
  63. package/src/bars/__tests__/__snapshots__/histogram.test.jsx.snap +45 -0
  64. package/src/bars/__tests__/bar.test.jsx +37 -0
  65. package/src/bars/__tests__/histogram.test.jsx +38 -0
  66. package/src/bars/__tests__/utils.js +30 -0
  67. package/src/bars/common/__tests__/__snapshots__/bars.test.jsx.snap +110 -0
  68. package/src/bars/common/__tests__/bars.test.jsx +69 -0
  69. package/src/bars/common/__tests__/utils.js +30 -0
  70. package/src/bars/common/bars.jsx +101 -14
  71. package/src/bars/common/correct-check-icon.jsx +20 -0
  72. package/src/chart-type.js +7 -3
  73. package/src/chart.jsx +53 -29
  74. package/src/common/__tests__/__snapshots__/drag-handle.test.jsx.snap +48 -0
  75. package/src/common/__tests__/drag-handle.test.jsx +88 -0
  76. package/src/common/__tests__/utils.js +30 -0
  77. package/src/common/correctness-indicators.jsx +55 -0
  78. package/src/common/drag-handle.jsx +48 -26
  79. package/src/common/drag-icon.jsx +6 -21
  80. package/src/grid.jsx +37 -12
  81. package/src/index.js +2 -1
  82. package/src/key-legend.jsx +75 -0
  83. package/src/line/__tests__/__snapshots__/line-cross.test.jsx.snap +45 -0
  84. package/src/line/__tests__/__snapshots__/line-dot.test.jsx.snap +45 -0
  85. package/src/line/__tests__/line-cross.test.jsx +38 -0
  86. package/src/line/__tests__/line-dot.test.jsx +38 -0
  87. package/src/line/__tests__/utils.js +30 -0
  88. package/src/line/common/__tests__/__snapshots__/drag-handle.test.jsx.snap +49 -0
  89. package/src/line/common/__tests__/__snapshots__/line.test.jsx.snap +143 -0
  90. package/src/line/common/__tests__/drag-handle.test.jsx +88 -0
  91. package/src/line/common/__tests__/line.test.jsx +82 -0
  92. package/src/line/common/__tests__/utils.js +30 -0
  93. package/src/line/common/drag-handle.jsx +38 -16
  94. package/src/line/common/line.jsx +4 -6
  95. package/src/line/line-cross.js +56 -4
  96. package/src/line/line-dot.js +74 -10
  97. package/src/mark-label.jsx +83 -51
  98. package/src/plot/__tests__/__snapshots__/dot.test.jsx.snap +45 -0
  99. package/src/plot/__tests__/__snapshots__/line.test.jsx.snap +45 -0
  100. package/src/plot/__tests__/dot.test.jsx +38 -0
  101. package/src/plot/__tests__/line.test.jsx +38 -0
  102. package/src/plot/__tests__/utils.js +30 -0
  103. package/src/plot/common/__tests__/__snapshots__/plot.test.jsx.snap +97 -0
  104. package/src/plot/common/__tests__/plot.test.jsx +70 -0
  105. package/src/plot/common/__tests__/utils.js +30 -0
  106. package/src/plot/common/plot.jsx +127 -10
  107. package/src/plot/dot.js +19 -3
  108. package/src/plot/line.js +18 -4
  109. package/src/tool-menu.jsx +0 -4
@@ -3,6 +3,7 @@ import classNames from 'classnames';
3
3
  import { withStyles } from '@material-ui/core/styles';
4
4
  import AutosizeInput from 'react-input-autosize';
5
5
  import PropTypes from 'prop-types';
6
+
6
7
  import { types } from '@pie-lib/plot';
7
8
  import { correct, incorrect, disabled } from './common/styles';
8
9
  import { color } from '@pie-lib/render-ui';
@@ -14,11 +15,9 @@ const styles = (theme) => ({
14
15
  fontFamily: theme.typography.fontFamily,
15
16
  fontSize: theme.typography.fontSize,
16
17
  border: 'none',
17
- color: color.primaryDark(),
18
18
  '&.correct': correct('color'),
19
19
  '&.incorrect': incorrect('color'),
20
20
  '&.disabled': {
21
- ...disabled('color'),
22
21
  backgroundColor: 'transparent !important',
23
22
  },
24
23
  '&.error': { border: `2px solid ${theme.palette.error.main}` },
@@ -26,9 +25,10 @@ const styles = (theme) => ({
26
25
  mathInput: {
27
26
  pointerEvents: 'auto',
28
27
  textAlign: 'center',
29
- fontSize: theme.typography.fontSize,
28
+ fontSize: theme.typography.fontSize + 2,
30
29
  fontFamily: theme.typography.fontFamily,
31
30
  color: color.primaryDark(),
31
+ paddingTop: theme.typography.fontSize / 2,
32
32
  },
33
33
  disabled: {
34
34
  ...disabled('color'),
@@ -43,6 +43,11 @@ const styles = (theme) => ({
43
43
  incorrect: {
44
44
  ...incorrect('color'),
45
45
  },
46
+ flexContainer: {
47
+ display: 'flex',
48
+ flexDirection: 'column',
49
+ alignItems: 'center',
50
+ },
46
51
  });
47
52
 
48
53
  function isFractionFormat(label) {
@@ -88,6 +93,9 @@ export const MarkLabel = (props) => {
88
93
  correctness,
89
94
  autoFocus,
90
95
  error,
96
+ isHiddenLabel,
97
+ limitCharacters,
98
+ correctnessIndicator,
91
99
  } = props;
92
100
 
93
101
  const [label, setLabel] = useState(mark.label);
@@ -96,6 +104,10 @@ export const MarkLabel = (props) => {
96
104
  let root = useRef(null);
97
105
 
98
106
  const onChange = (e) => {
107
+ if (limitCharacters && e.target.value && e.target.value.length > 20) {
108
+ return;
109
+ }
110
+
99
111
  setLabel(e.target.value);
100
112
  };
101
113
 
@@ -126,55 +138,72 @@ export const MarkLabel = (props) => {
126
138
  renderMath(root);
127
139
  }, []);
128
140
 
129
- return isMathRendering() ? (
130
- <div
131
- ref={(r) => (root = r)}
132
- dangerouslySetInnerHTML={{ __html: getLabelMathFormat(label) }}
133
- className={classNames(classes.mathInput, {
134
- [classes.disabled]: disabled,
135
- [classes.error]: error,
136
- [classes.correct]: correctness && correctness.label === 'correct',
137
- [classes.incorrect]: correctness && correctness.label === 'incorrect',
138
- })}
139
- onClick={() => setIsEditing(true)}
140
- style={{ minWidth: barWidth }}
141
- ></div>
142
- ) : (
143
- <AutosizeInput
144
- inputRef={(r) => {
145
- _ref(r);
146
- externalInputRef(r);
147
- }}
148
- autoFocus={isEditing || autoFocus}
149
- disabled={disabled}
150
- inputClassName={classNames(
151
- classes.input,
152
- correctness && correctness.label,
153
- disabled && 'disabled',
154
- error && 'error',
141
+ return (
142
+ <div className={classes.flexContainer}>
143
+ {correctnessIndicator}
144
+ {isMathRendering() ? (
145
+ <div
146
+ ref={(r) => {
147
+ root = r;
148
+ externalInputRef(r);
149
+ }}
150
+ dangerouslySetInnerHTML={{ __html: getLabelMathFormat(label) }}
151
+ className={classNames(classes.mathInput, {
152
+ [classes.disabled]: disabled,
153
+ [classes.error]: error,
154
+ [classes.correct]: mark.editable && correctness?.label === 'correct',
155
+ [classes.incorrect]: mark.editable && correctness?.label === 'incorrect',
156
+ })}
157
+ onClick={() => setIsEditing(true)}
158
+ style={{
159
+ minWidth: barWidth,
160
+ position: 'fixed',
161
+ transformOrigin: 'left',
162
+ transform: `rotate(${rotate}deg)`,
163
+ visibility: isHiddenLabel ? 'hidden' : 'unset',
164
+ marginTop: correctnessIndicator ? '24px' : '0',
165
+ }}
166
+ ></div>
167
+ ) : (
168
+ <AutosizeInput
169
+ inputRef={(r) => {
170
+ _ref(r);
171
+ externalInputRef(r);
172
+ }}
173
+ autoFocus={isEditing || autoFocus}
174
+ disabled={disabled}
175
+ inputClassName={classNames(
176
+ classes.input,
177
+ correctness && mark.editable ? correctness.label : null,
178
+ disabled && 'disabled',
179
+ error && 'error',
180
+ )}
181
+ inputStyle={{
182
+ minWidth: barWidth,
183
+ textAlign: 'center',
184
+ background: 'transparent',
185
+ boxSizing: 'border-box',
186
+ paddingLeft: 0,
187
+ paddingRight: 0,
188
+ ...extraStyle,
189
+ }}
190
+ value={label}
191
+ style={{
192
+ position: 'fixed',
193
+ pointerEvents: 'auto',
194
+ top: 0,
195
+ left: 0,
196
+ minWidth: barWidth,
197
+ transformOrigin: 'left',
198
+ transform: `rotate(${rotate}deg)`,
199
+ visibility: isHiddenLabel ? 'hidden' : 'unset',
200
+ marginTop: correctnessIndicator ? '24px' : '0',
201
+ }}
202
+ onChange={onChange}
203
+ onBlur={onChangeProp}
204
+ />
155
205
  )}
156
- inputStyle={{
157
- minWidth: barWidth,
158
- textAlign: 'center',
159
- background: 'transparent',
160
- boxSizing: 'border-box',
161
- paddingLeft: 0,
162
- paddingRight: 0,
163
- ...extraStyle,
164
- }}
165
- value={label}
166
- style={{
167
- position: 'fixed',
168
- pointerEvents: 'auto',
169
- top: 0,
170
- left: 0,
171
- minWidth: barWidth,
172
- transformOrigin: 'left',
173
- transform: `rotate(${rotate}deg)`,
174
- }}
175
- onChange={onChange}
176
- onBlur={onChangeProp}
177
- />
206
+ </div>
178
207
  );
179
208
  };
180
209
 
@@ -193,6 +222,9 @@ MarkLabel.propTypes = {
193
222
  value: PropTypes.string,
194
223
  label: PropTypes.string,
195
224
  }),
225
+ isHiddenLabel: PropTypes.bool,
226
+ limitCharacters: PropTypes.bool,
227
+ correctnessIndicator: PropTypes.node,
196
228
  };
197
229
 
198
230
  export default withStyles(styles)(MarkLabel);
@@ -0,0 +1,45 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`DotPlot snapshot renders 1`] = `
4
+ <Plot
5
+ CustomBarElement={[Function]}
6
+ className="className"
7
+ classes={Object {}}
8
+ graphProps={
9
+ Object {
10
+ "domain": Object {
11
+ "max": 1,
12
+ "min": 0,
13
+ "step": 1,
14
+ },
15
+ "range": Object {
16
+ "max": 1,
17
+ "min": 0,
18
+ "step": 1,
19
+ },
20
+ "scale": Object {
21
+ "x": [MockFunction],
22
+ "y": [MockFunction],
23
+ },
24
+ "size": Object {
25
+ "height": 400,
26
+ "width": 400,
27
+ },
28
+ "snap": Object {
29
+ "x": [MockFunction],
30
+ "y": [MockFunction],
31
+ },
32
+ }
33
+ }
34
+ xBand={[Function]}
35
+ />
36
+ `;
37
+
38
+ exports[`DotPlot snapshot renders without graphProps 1`] = `
39
+ <Plot
40
+ CustomBarElement={[Function]}
41
+ className="className"
42
+ classes={Object {}}
43
+ xBand={[Function]}
44
+ />
45
+ `;
@@ -0,0 +1,45 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`LinePlot snapshot renders 1`] = `
4
+ <Plot
5
+ CustomBarElement={[Function]}
6
+ className="className"
7
+ classes={Object {}}
8
+ graphProps={
9
+ Object {
10
+ "domain": Object {
11
+ "max": 1,
12
+ "min": 0,
13
+ "step": 1,
14
+ },
15
+ "range": Object {
16
+ "max": 1,
17
+ "min": 0,
18
+ "step": 1,
19
+ },
20
+ "scale": Object {
21
+ "x": [MockFunction],
22
+ "y": [MockFunction],
23
+ },
24
+ "size": Object {
25
+ "height": 400,
26
+ "width": 400,
27
+ },
28
+ "snap": Object {
29
+ "x": [MockFunction],
30
+ "y": [MockFunction],
31
+ },
32
+ }
33
+ }
34
+ xBand={[Function]}
35
+ />
36
+ `;
37
+
38
+ exports[`LinePlot snapshot renders without graphProps 1`] = `
39
+ <Plot
40
+ CustomBarElement={[Function]}
41
+ className="className"
42
+ classes={Object {}}
43
+ xBand={[Function]}
44
+ />
45
+ `;
@@ -0,0 +1,38 @@
1
+ import { shallow } from 'enzyme';
2
+ import React from 'react';
3
+ import Dot, { DotPlot } from '../dot';
4
+ import { graphProps } from './utils';
5
+ import { Bar as BarChart } from '../../bars/bar';
6
+
7
+ describe('DotPlot', () => {
8
+ const wrapper = (extras) => {
9
+ const defaults = {
10
+ classes: {},
11
+ className: 'className',
12
+ graphProps: graphProps(),
13
+ xBand: () => {
14
+ return {
15
+ bandwidth: () => {},
16
+ };
17
+ },
18
+ };
19
+ const props = { ...defaults, ...extras };
20
+ return shallow(<DotPlot {...props} />);
21
+ };
22
+
23
+ describe('snapshot', () => {
24
+ it('renders', () => expect(wrapper()).toMatchSnapshot());
25
+
26
+ it('renders without graphProps', () => expect(wrapper({ graphProps: undefined })).toMatchSnapshot());
27
+ });
28
+
29
+ describe('component', () => {
30
+ const chart = Dot();
31
+
32
+ expect(chart).toEqual({
33
+ type: 'dotPlot',
34
+ Component: DotPlot,
35
+ name: 'Dot Plot',
36
+ });
37
+ });
38
+ });
@@ -0,0 +1,38 @@
1
+ import { shallow } from 'enzyme';
2
+ import React from 'react';
3
+ import Line, { LinePlot } from '../line';
4
+ import { graphProps } from './utils';
5
+ import { Bar as BarChart } from '../../bars/bar';
6
+
7
+ describe('LinePlot', () => {
8
+ const wrapper = (extras) => {
9
+ const defaults = {
10
+ classes: {},
11
+ className: 'className',
12
+ graphProps: graphProps(),
13
+ xBand: () => {
14
+ return {
15
+ bandwidth: () => {},
16
+ };
17
+ },
18
+ };
19
+ const props = { ...defaults, ...extras };
20
+ return shallow(<LinePlot {...props} />);
21
+ };
22
+
23
+ describe('snapshot', () => {
24
+ it('renders', () => expect(wrapper()).toMatchSnapshot());
25
+
26
+ it('renders without graphProps', () => expect(wrapper({ graphProps: undefined })).toMatchSnapshot());
27
+ });
28
+
29
+ describe('component', () => {
30
+ const chart = Line();
31
+
32
+ expect(chart).toEqual({
33
+ type: 'linePlot',
34
+ Component: LinePlot,
35
+ name: 'Line Plot',
36
+ });
37
+ });
38
+ });
@@ -0,0 +1,30 @@
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
+ });
@@ -0,0 +1,97 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Plot snapshot renders 1`] = `
4
+ <t>
5
+ <WithStyles(RawPlot)
6
+ graphProps={
7
+ Object {
8
+ "domain": Object {
9
+ "max": 1,
10
+ "min": 0,
11
+ "step": 1,
12
+ },
13
+ "range": Object {
14
+ "max": 1,
15
+ "min": 0,
16
+ "step": 1,
17
+ },
18
+ "scale": Object {
19
+ "x": [MockFunction],
20
+ "y": [MockFunction],
21
+ },
22
+ "size": Object {
23
+ "height": 400,
24
+ "width": 400,
25
+ },
26
+ "snap": Object {
27
+ "x": [MockFunction],
28
+ "y": [MockFunction],
29
+ },
30
+ }
31
+ }
32
+ index={0}
33
+ key="bar-0-0-0"
34
+ label="0"
35
+ onChangeCategory={[Function]}
36
+ value={0}
37
+ xBand={[Function]}
38
+ />
39
+ </t>
40
+ `;
41
+
42
+ exports[`RawPlot snapshot renders 1`] = `
43
+ <Fragment>
44
+ <g
45
+ onMouseEnter={[Function]}
46
+ onMouseLeave={[Function]}
47
+ onTouchEnd={[Function]}
48
+ onTouchStart={[Function]}
49
+ >
50
+ <WithStyles(RawDragHandle)
51
+ color="var(--pie-primary-dark, #283593)"
52
+ graphProps={
53
+ Object {
54
+ "domain": Object {
55
+ "max": 1,
56
+ "min": 0,
57
+ "step": 1,
58
+ },
59
+ "range": Object {
60
+ "max": 1,
61
+ "min": 0,
62
+ "step": 1,
63
+ },
64
+ "scale": Object {
65
+ "x": [MockFunction],
66
+ "y": [MockFunction] {
67
+ "calls": Array [
68
+ Array [
69
+ NaN,
70
+ ],
71
+ ],
72
+ "results": Array [
73
+ Object {
74
+ "type": "return",
75
+ "value": NaN,
76
+ },
77
+ ],
78
+ },
79
+ },
80
+ "size": Object {
81
+ "height": 400,
82
+ "width": 400,
83
+ },
84
+ "snap": Object {
85
+ "x": [MockFunction],
86
+ "y": [MockFunction],
87
+ },
88
+ }
89
+ }
90
+ isHovered={false}
91
+ isPlot={true}
92
+ onDrag={[Function]}
93
+ onDragStop={[Function]}
94
+ />
95
+ </g>
96
+ </Fragment>
97
+ `;
@@ -0,0 +1,70 @@
1
+ import { shallow } from 'enzyme';
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 wrapper = (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 shallow(<Plot {...props} />);
22
+ };
23
+
24
+ describe('snapshot', () => {
25
+ it('renders', () => expect(wrapper()).toMatchSnapshot());
26
+ });
27
+ });
28
+
29
+ describe('RawPlot', () => {
30
+ const xBand = () => {};
31
+ xBand.bandwidth = () => {};
32
+ const onChangeCategory = jest.fn();
33
+
34
+ const wrapper = (extras) => {
35
+ const defaults = {
36
+ classes: {},
37
+ className: 'className',
38
+ graphProps: graphProps(),
39
+ xBand,
40
+ onChangeCategory,
41
+ data: [],
42
+ label: 'label',
43
+ CustomBarElement: () => <div />,
44
+ };
45
+ const props = { ...defaults, ...extras };
46
+ return shallow(<RawPlot {...props} />);
47
+ };
48
+
49
+ describe('snapshot', () => {
50
+ it('renders', () => expect(wrapper()).toMatchSnapshot());
51
+ });
52
+
53
+ describe('logic', () => {
54
+ const w = wrapper();
55
+
56
+ it('dragStop', () => {
57
+ w.instance().dragStop();
58
+
59
+ expect(onChangeCategory).not.toHaveBeenCalled();
60
+
61
+ w.instance().setState({
62
+ dragValue: 2,
63
+ });
64
+
65
+ w.instance().dragStop();
66
+
67
+ expect(onChangeCategory).toHaveBeenCalledWith({ label: 'label', value: 2 });
68
+ });
69
+ });
70
+ });
@@ -0,0 +1,30 @@
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
+ });