@pie-lib/charting 7.0.3-next.3 → 7.0.4-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/dist/_virtual/_rolldown/runtime.js +23 -0
- package/dist/actions-button.d.ts +26 -0
- package/dist/actions-button.js +84 -0
- package/dist/axes.d.ts +84 -0
- package/dist/axes.js +376 -0
- package/dist/bars/bar.d.ts +47 -0
- package/dist/bars/bar.js +27 -0
- package/dist/bars/common/bars.d.ts +98 -0
- package/dist/bars/common/bars.js +174 -0
- package/dist/bars/common/correct-check-icon.d.ts +18 -0
- package/dist/bars/common/correct-check-icon.js +50 -0
- package/dist/bars/histogram.d.ts +47 -0
- package/dist/bars/histogram.js +28 -0
- package/dist/chart-setup.d.ts +29 -0
- package/dist/chart-setup.js +231 -0
- package/dist/chart-type.d.ts +32 -0
- package/dist/chart-type.js +68 -0
- package/dist/chart-types.d.ts +41 -0
- package/dist/chart-types.js +17 -0
- package/dist/chart.d.ts +88 -0
- package/dist/chart.js +250 -0
- package/dist/common/correctness-indicators.d.ts +70 -0
- package/dist/common/correctness-indicators.js +106 -0
- package/dist/common/drag-handle.d.ts +129 -0
- package/dist/common/drag-handle.js +120 -0
- package/dist/common/drag-icon.d.ts +23 -0
- package/dist/common/drag-icon.js +45 -0
- package/dist/common/styles.d.ts +23 -0
- package/dist/common/styles.js +17 -0
- package/dist/grid.d.ts +45 -0
- package/dist/grid.js +56 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +6 -0
- package/dist/key-legend.d.ts +19 -0
- package/dist/key-legend.js +46 -0
- package/dist/line/common/drag-handle.d.ts +120 -0
- package/dist/line/common/drag-handle.js +92 -0
- package/dist/line/common/line.d.ts +96 -0
- package/dist/line/common/line.js +114 -0
- package/dist/line/line-cross.d.ts +47 -0
- package/dist/line/line-cross.js +133 -0
- package/dist/line/line-dot.d.ts +47 -0
- package/dist/line/line-dot.js +101 -0
- package/dist/mark-label.d.ts +55 -0
- package/dist/mark-label.js +139 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Axis.js +100 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisBottom.js +45 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisLeft.js +46 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +61 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Ticks.js +42 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/constants/orientation.js +9 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/createPoint.js +14 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getAxisRangePaddingConfig.js +21 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getLabelTransform.js +16 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickFormatter.js +8 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickPosition.js +15 -0
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridColumns.js +79 -0
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridRows.js +79 -0
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/utils/getScaleBandwidth.js +6 -0
- package/dist/node_modules/.bun/@visx_group@3.12.0_f4eacebf2041cd4f/node_modules/@visx/group/esm/Group.js +49 -0
- package/dist/node_modules/.bun/@visx_point@3.12.0/node_modules/@visx/point/esm/Point.js +18 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/align.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/base.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/clamp.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/constant.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/domain.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/exponent.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/interpolate.js +10 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/nice.js +37 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/padding.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/range.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/reverse.js +9 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/round.js +7 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/scaleOperator.js +58 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/unknown.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/zero.js +9 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/scales/band.js +9 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/scales/point.js +9 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/coerceNumber.js +10 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/createColorInterpolator.js +29 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/getTicks.js +9 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/isUtcScale.js +7 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/toString.js +6 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Bar.js +28 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Circle.js +28 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Line.js +46 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/LinePath.js +49 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/D3ShapeFactories.js +9 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/setNumberOrNumberAccessor.js +6 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/lib/shapes/Line.js +52 -0
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/Text.js +57 -0
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/hooks/useText.js +91 -0
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/util/getStringWidth.js +21 -0
- package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-interpolate.js +8 -0
- package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-scale.js +8 -0
- package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-time.js +8 -0
- package/dist/node_modules/.bun/balanced-match@0.4.2/node_modules/balanced-match/index.js +32 -0
- package/dist/node_modules/.bun/balanced-match@1.0.2/node_modules/balanced-match/index.js +33 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Hash.js +21 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_ListCache.js +21 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Map.js +10 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_MapCache.js +21 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Symbol.js +9 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_assocIndexOf.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_baseGetTag.js +15 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_baseIsNative.js +16 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_coreJsData.js +9 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_freeGlobal.js +8 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getMapData.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getNative.js +15 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getRawTag.js +19 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getValue.js +11 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashClear.js +13 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashDelete.js +12 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashGet.js +18 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashHas.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashSet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_isKeyable.js +12 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_isMasked.js +16 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheClear.js +11 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheDelete.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheGet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheHas.js +13 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheSet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheClear.js +19 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheDelete.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheGet.js +13 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheHas.js +13 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheSet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_nativeCreate.js +9 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_objectToString.js +12 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_root.js +10 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_toSource.js +20 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/eq.js +11 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/isFunction.js +16 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/isObject.js +12 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/memoize.js +20 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/formula_evaluator.js +37 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/lexer.js +509 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/math_function.js +108 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix.js +31 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix_evaluator.js +45 -0
- package/dist/node_modules/.bun/react-input-autosize@2.2.2_f4eacebf2041cd4f/node_modules/react-input-autosize/lib/AutosizeInput.js +216 -0
- package/dist/node_modules/.bun/reduce-css-calc@1.3.0/node_modules/reduce-css-calc/index.js +49 -0
- package/dist/node_modules/.bun/reduce-function-call@1.0.3/node_modules/reduce-function-call/index.js +34 -0
- package/dist/plot/common/plot.d.ts +103 -0
- package/dist/plot/common/plot.js +227 -0
- package/dist/plot/dot.d.ts +47 -0
- package/dist/plot/dot.js +62 -0
- package/dist/plot/line.d.ts +47 -0
- package/dist/plot/line.js +84 -0
- package/dist/tool-menu.d.ts +31 -0
- package/dist/utils.d.ts +39 -0
- package/dist/utils.js +101 -0
- package/package.json +35 -25
- package/CHANGELOG.json +0 -17
- package/CHANGELOG.md +0 -1110
- package/LICENSE.md +0 -5
- package/lib/actions-button.js +0 -145
- package/lib/actions-button.js.map +0 -1
- package/lib/axes.js +0 -643
- package/lib/axes.js.map +0 -1
- package/lib/bars/bar.js +0 -58
- package/lib/bars/bar.js.map +0 -1
- package/lib/bars/common/bars.js +0 -277
- package/lib/bars/common/bars.js.map +0 -1
- package/lib/bars/common/correct-check-icon.js +0 -54
- package/lib/bars/common/correct-check-icon.js.map +0 -1
- package/lib/bars/histogram.js +0 -59
- package/lib/bars/histogram.js.map +0 -1
- package/lib/chart-setup.js +0 -382
- package/lib/chart-setup.js.map +0 -1
- package/lib/chart-type.js +0 -80
- package/lib/chart-type.js.map +0 -1
- package/lib/chart-types.js +0 -22
- package/lib/chart-types.js.map +0 -1
- package/lib/chart.js +0 -384
- package/lib/chart.js.map +0 -1
- package/lib/common/correctness-indicators.js +0 -156
- package/lib/common/correctness-indicators.js.map +0 -1
- package/lib/common/drag-handle.js +0 -160
- package/lib/common/drag-handle.js.map +0 -1
- package/lib/common/drag-icon.js +0 -52
- package/lib/common/drag-icon.js.map +0 -1
- package/lib/common/styles.js +0 -22
- package/lib/common/styles.js.map +0 -1
- package/lib/grid.js +0 -101
- package/lib/grid.js.map +0 -1
- package/lib/index.js +0 -42
- package/lib/index.js.map +0 -1
- package/lib/key-legend.js +0 -87
- package/lib/key-legend.js.map +0 -1
- package/lib/line/common/drag-handle.js +0 -146
- package/lib/line/common/drag-handle.js.map +0 -1
- package/lib/line/common/line.js +0 -214
- package/lib/line/common/line.js.map +0 -1
- package/lib/line/line-cross.js +0 -214
- package/lib/line/line-cross.js.map +0 -1
- package/lib/line/line-dot.js +0 -158
- package/lib/line/line-dot.js.map +0 -1
- package/lib/mark-label.js +0 -237
- package/lib/mark-label.js.map +0 -1
- package/lib/plot/common/plot.js +0 -349
- package/lib/plot/common/plot.js.map +0 -1
- package/lib/plot/dot.js +0 -110
- package/lib/plot/dot.js.map +0 -1
- package/lib/plot/line.js +0 -140
- package/lib/plot/line.js.map +0 -1
- package/lib/tool-menu.js +0 -106
- package/lib/tool-menu.js.map +0 -1
- package/lib/utils.js +0 -189
- package/lib/utils.js.map +0 -1
- 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/actions-button.jsx +0 -115
- package/src/axes.jsx +0 -594
- 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/bar.js +0 -28
- package/src/bars/common/__tests__/bars.test.jsx +0 -68
- package/src/bars/common/__tests__/utils.js +0 -30
- package/src/bars/common/bars.jsx +0 -249
- package/src/bars/common/correct-check-icon.jsx +0 -25
- package/src/bars/histogram.js +0 -28
- package/src/chart-setup.jsx +0 -356
- package/src/chart-type.js +0 -59
- package/src/chart-types.js +0 -8
- package/src/chart.jsx +0 -357
- 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/common/correctness-indicators.jsx +0 -128
- package/src/common/drag-handle.jsx +0 -125
- package/src/common/drag-icon.jsx +0 -36
- package/src/common/styles.js +0 -19
- package/src/grid.jsx +0 -68
- package/src/index.js +0 -7
- package/src/key-legend.jsx +0 -77
- 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/line/common/drag-handle.jsx +0 -114
- package/src/line/common/line.jsx +0 -171
- package/src/line/line-cross.js +0 -144
- package/src/line/line-dot.js +0 -111
- package/src/mark-label.jsx +0 -238
- 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
- package/src/plot/common/plot.jsx +0 -358
- package/src/plot/dot.js +0 -74
- package/src/plot/line.js +0 -98
- package/src/tool-menu.jsx +0 -85
- package/src/utils.js +0 -201
|
@@ -1,667 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { fireEvent, render } from '@pie-lib/test-utils';
|
|
3
|
-
import { createTheme, ThemeProvider } from '@mui/material/styles';
|
|
4
|
-
import ChartAxes, { RawChartAxes, TickComponent } from '../axes';
|
|
5
|
-
import { createBandScale, graphProps } from './utils';
|
|
6
|
-
|
|
7
|
-
jest.mock('@visx/axis', () => ({
|
|
8
|
-
AxisLeft: ({ children, ...props }) => (
|
|
9
|
-
<g data-testid="axis-left" {...props}>
|
|
10
|
-
{typeof children === 'function' ? children({ formattedValue: '5' }) : children}
|
|
11
|
-
</g>
|
|
12
|
-
),
|
|
13
|
-
AxisBottom: ({ children, tickValues, ...props }) => (
|
|
14
|
-
<g data-testid="axis-bottom" {...props}>
|
|
15
|
-
{typeof children === 'function'
|
|
16
|
-
? (tickValues || ['0-A', '1-B', '2-C']).map((v, i) => children({ formattedValue: v, index: i }))
|
|
17
|
-
: children}
|
|
18
|
-
</g>
|
|
19
|
-
),
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
jest.mock('../mark-label', () => {
|
|
23
|
-
return function MarkLabel({ mark, disabled, onChange, error, autoFocus, inputRef, correctnessIndicator }) {
|
|
24
|
-
return (
|
|
25
|
-
<div data-testid="mark-label">
|
|
26
|
-
<input
|
|
27
|
-
data-testid="mark-label-input"
|
|
28
|
-
ref={inputRef}
|
|
29
|
-
value={mark?.label || ''}
|
|
30
|
-
disabled={disabled}
|
|
31
|
-
onChange={(e) => onChange && onChange(e.target.value)}
|
|
32
|
-
autoFocus={autoFocus}
|
|
33
|
-
/>
|
|
34
|
-
{error && <span data-testid="mark-label-error">{error}</span>}
|
|
35
|
-
{correctnessIndicator}
|
|
36
|
-
</div>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
jest.mock('@pie-lib/config-ui', () => ({
|
|
42
|
-
AlertDialog: ({ open, title, text, onClose, onConfirm }) =>
|
|
43
|
-
open ? (
|
|
44
|
-
<div data-testid="alert-dialog">
|
|
45
|
-
<h2>{title}</h2>
|
|
46
|
-
<p>{text}</p>
|
|
47
|
-
<button data-testid="alert-cancel" onClick={onClose}>
|
|
48
|
-
Cancel
|
|
49
|
-
</button>
|
|
50
|
-
<button data-testid="alert-confirm" onClick={onConfirm}>
|
|
51
|
-
Confirm
|
|
52
|
-
</button>
|
|
53
|
-
</div>
|
|
54
|
-
) : null,
|
|
55
|
-
}));
|
|
56
|
-
|
|
57
|
-
jest.mock('../common/correctness-indicators', () => ({
|
|
58
|
-
TickCorrectnessIndicator: ({ correctness, interactive }) =>
|
|
59
|
-
correctness && interactive ? (
|
|
60
|
-
<div data-testid="tick-correctness-indicator">{correctness.value === 'correct' ? '✓' : '✗'}</div>
|
|
61
|
-
) : null,
|
|
62
|
-
}));
|
|
63
|
-
|
|
64
|
-
jest.mock('@pie-lib/math-rendering', () => ({
|
|
65
|
-
renderMath: jest.fn((text) => text),
|
|
66
|
-
}));
|
|
67
|
-
|
|
68
|
-
const theme = createTheme();
|
|
69
|
-
|
|
70
|
-
describe('ChartAxes', () => {
|
|
71
|
-
const renderComponent = (extras) => {
|
|
72
|
-
const defaults = {
|
|
73
|
-
classes: {},
|
|
74
|
-
className: 'className',
|
|
75
|
-
graphProps: graphProps(),
|
|
76
|
-
xBand: createBandScale(['a', 'b', 'c'], [0, 400]),
|
|
77
|
-
categories: [],
|
|
78
|
-
};
|
|
79
|
-
const props = { ...defaults, ...extras };
|
|
80
|
-
return render(
|
|
81
|
-
<ThemeProvider theme={theme}>
|
|
82
|
-
<svg>
|
|
83
|
-
<ChartAxes {...props} />
|
|
84
|
-
</svg>
|
|
85
|
-
</ThemeProvider>,
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
describe('rendering', () => {
|
|
90
|
-
it('renders axes container', () => {
|
|
91
|
-
const { container } = renderComponent();
|
|
92
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('renders SVG with axes group', () => {
|
|
96
|
-
const { container } = renderComponent();
|
|
97
|
-
const svg = container.querySelector('svg');
|
|
98
|
-
expect(svg).toBeInTheDocument();
|
|
99
|
-
const axesGroup = container.querySelector('g');
|
|
100
|
-
expect(axesGroup).toBeInTheDocument();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('renders axes elements', () => {
|
|
104
|
-
const { container } = renderComponent();
|
|
105
|
-
const groups = container.querySelectorAll('g');
|
|
106
|
-
expect(groups.length).toBeGreaterThan(0);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
describe('edge cases', () => {
|
|
111
|
-
it('handles missing xBand', () => {
|
|
112
|
-
const { container } = renderComponent({ xBand: undefined });
|
|
113
|
-
expect(container).toBeInTheDocument();
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('handles empty categories', () => {
|
|
117
|
-
const { container } = renderComponent({ categories: [] });
|
|
118
|
-
expect(container).toBeInTheDocument();
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('handles null categories', () => {
|
|
122
|
-
const { container } = renderComponent({ categories: null });
|
|
123
|
-
expect(container).toBeInTheDocument();
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
describe('RawChartAxes', () => {
|
|
129
|
-
const renderComponent = (extras) => {
|
|
130
|
-
const defaults = {
|
|
131
|
-
classes: {},
|
|
132
|
-
className: 'className',
|
|
133
|
-
graphProps: graphProps(),
|
|
134
|
-
xBand: createBandScale(['a', 'b', 'c'], [0, 400]),
|
|
135
|
-
categories: [],
|
|
136
|
-
};
|
|
137
|
-
const props = { ...defaults, ...extras };
|
|
138
|
-
return render(
|
|
139
|
-
<ThemeProvider theme={theme}>
|
|
140
|
-
<svg>
|
|
141
|
-
<RawChartAxes {...props} />
|
|
142
|
-
</svg>
|
|
143
|
-
</ThemeProvider>,
|
|
144
|
-
);
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
describe('rendering', () => {
|
|
148
|
-
it('renders raw axes container', () => {
|
|
149
|
-
const { container } = renderComponent();
|
|
150
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('renders SVG with axes group', () => {
|
|
154
|
-
const { container } = renderComponent();
|
|
155
|
-
const svg = container.querySelector('svg');
|
|
156
|
-
expect(svg).toBeInTheDocument();
|
|
157
|
-
const axesGroup = container.querySelector('g');
|
|
158
|
-
expect(axesGroup).toBeInTheDocument();
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it('renders both axes when leftAxis is true', () => {
|
|
162
|
-
const { getByTestId } = renderComponent({ leftAxis: true });
|
|
163
|
-
expect(getByTestId('axis-left')).toBeInTheDocument();
|
|
164
|
-
expect(getByTestId('axis-bottom')).toBeInTheDocument();
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it('renders only bottom axis when leftAxis is false', () => {
|
|
168
|
-
const { queryByTestId, getByTestId } = renderComponent({ leftAxis: false });
|
|
169
|
-
expect(queryByTestId('axis-left')).not.toBeInTheDocument();
|
|
170
|
-
expect(getByTestId('axis-bottom')).toBeInTheDocument();
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
describe('TickComponent', () => {
|
|
176
|
-
const defaultCategories = [
|
|
177
|
-
{ value: 1, label: 'Category A', editable: true, interactive: true },
|
|
178
|
-
{ value: 2, label: 'Category B', editable: true, interactive: true },
|
|
179
|
-
];
|
|
180
|
-
|
|
181
|
-
const renderComponent = (extras) => {
|
|
182
|
-
const defaults = {
|
|
183
|
-
graphProps: graphProps(),
|
|
184
|
-
xBand: createBandScale(['a', 'b', 'c'], [0, 400]),
|
|
185
|
-
categories: defaultCategories,
|
|
186
|
-
formattedValue: '0-Category A',
|
|
187
|
-
bandWidth: 100,
|
|
188
|
-
barWidth: 100,
|
|
189
|
-
x: 50,
|
|
190
|
-
y: 50,
|
|
191
|
-
top: 0,
|
|
192
|
-
onChangeCategory: jest.fn(),
|
|
193
|
-
};
|
|
194
|
-
const props = { ...defaults, ...extras };
|
|
195
|
-
return render(
|
|
196
|
-
<ThemeProvider theme={theme}>
|
|
197
|
-
<svg>
|
|
198
|
-
<TickComponent {...props} />
|
|
199
|
-
</svg>
|
|
200
|
-
</ThemeProvider>,
|
|
201
|
-
);
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
describe('rendering', () => {
|
|
205
|
-
it('renders tick component', () => {
|
|
206
|
-
const { container } = renderComponent();
|
|
207
|
-
const svg = container.querySelector('svg');
|
|
208
|
-
expect(svg).toBeInTheDocument();
|
|
209
|
-
expect(container.querySelector('g')).toBeInTheDocument();
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it('renders with categories', () => {
|
|
213
|
-
const { container } = renderComponent({
|
|
214
|
-
formattedValue: '0-test',
|
|
215
|
-
categories: [{ value: 1, label: 'test', editable: false, interactive: false }],
|
|
216
|
-
});
|
|
217
|
-
const svg = container.querySelector('svg');
|
|
218
|
-
expect(svg).toBeInTheDocument();
|
|
219
|
-
expect(container.querySelector('g')).toBeInTheDocument();
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it('renders MarkLabel component', () => {
|
|
223
|
-
const { getAllByTestId } = renderComponent();
|
|
224
|
-
const markLabels = getAllByTestId('mark-label');
|
|
225
|
-
expect(markLabels.length).toBeGreaterThan(0);
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('renders foreignObject for labels', () => {
|
|
229
|
-
const { container } = renderComponent();
|
|
230
|
-
const foreignObject = container.querySelector('foreignObject');
|
|
231
|
-
expect(foreignObject).toBeInTheDocument();
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('does not render when formattedValue is null', () => {
|
|
235
|
-
const { container } = renderComponent({ formattedValue: null });
|
|
236
|
-
const foreignObject = container.querySelector('foreignObject');
|
|
237
|
-
expect(foreignObject).not.toBeInTheDocument();
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
it('does not render when formattedValue is undefined', () => {
|
|
241
|
-
const { container } = renderComponent({ formattedValue: undefined });
|
|
242
|
-
const foreignObject = container.querySelector('foreignObject');
|
|
243
|
-
expect(foreignObject).not.toBeInTheDocument();
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('renders hidden label for longest category', () => {
|
|
247
|
-
const { getAllByTestId } = renderComponent();
|
|
248
|
-
const markLabels = getAllByTestId('mark-label');
|
|
249
|
-
expect(markLabels.length).toBeGreaterThan(0);
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
describe('category label editing', () => {
|
|
254
|
-
it('allows editing category label', () => {
|
|
255
|
-
const onChangeCategory = jest.fn();
|
|
256
|
-
const { getAllByTestId } = renderComponent({ onChangeCategory });
|
|
257
|
-
|
|
258
|
-
const inputs = getAllByTestId('mark-label-input');
|
|
259
|
-
const input = inputs[inputs.length - 1];
|
|
260
|
-
fireEvent.change(input, { target: { value: 'New Label' } });
|
|
261
|
-
|
|
262
|
-
expect(onChangeCategory).toHaveBeenCalled();
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
it('calls changeCategory with correct parameters', () => {
|
|
266
|
-
const onChangeCategory = jest.fn();
|
|
267
|
-
const { getAllByTestId } = renderComponent({ onChangeCategory });
|
|
268
|
-
|
|
269
|
-
const inputs = getAllByTestId('mark-label-input');
|
|
270
|
-
const input = inputs[inputs.length - 1];
|
|
271
|
-
fireEvent.change(input, { target: { value: 'Updated' } });
|
|
272
|
-
|
|
273
|
-
expect(onChangeCategory).toHaveBeenCalledWith(0, expect.objectContaining({ label: 'Updated' }));
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
it('disables editing when editable is false', () => {
|
|
277
|
-
const categories = [{ value: 1, label: 'test', editable: false, interactive: true }];
|
|
278
|
-
const { getAllByTestId } = renderComponent({ categories, formattedValue: '0-test' });
|
|
279
|
-
|
|
280
|
-
const inputs = getAllByTestId('mark-label-input');
|
|
281
|
-
const input = inputs[inputs.length - 1];
|
|
282
|
-
expect(input).toBeDisabled();
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
it('enables editing in define chart mode', () => {
|
|
286
|
-
const categories = [{ value: 1, label: 'test', editable: true, interactive: true }];
|
|
287
|
-
const { getAllByTestId } = renderComponent({
|
|
288
|
-
categories,
|
|
289
|
-
formattedValue: '0-test',
|
|
290
|
-
defineChart: true,
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
const inputs = getAllByTestId('mark-label-input');
|
|
294
|
-
const input = inputs[inputs.length - 1];
|
|
295
|
-
expect(input).not.toBeDisabled();
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
it('respects editable property when not in define chart mode', () => {
|
|
299
|
-
const categories = [{ value: 1, label: 'test', editable: true, interactive: true }];
|
|
300
|
-
const { getAllByTestId } = renderComponent({
|
|
301
|
-
categories,
|
|
302
|
-
formattedValue: '0-test',
|
|
303
|
-
defineChart: false,
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
const inputs = getAllByTestId('mark-label-input');
|
|
307
|
-
const input = inputs[inputs.length - 1];
|
|
308
|
-
expect(input).not.toBeDisabled();
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
describe('interactive checkbox', () => {
|
|
313
|
-
it('shows warning when disabling interactive with correct answer', () => {
|
|
314
|
-
const categories = [
|
|
315
|
-
{
|
|
316
|
-
value: 1,
|
|
317
|
-
label: 'test',
|
|
318
|
-
editable: true,
|
|
319
|
-
interactive: true,
|
|
320
|
-
correctness: { value: 'correct' },
|
|
321
|
-
},
|
|
322
|
-
];
|
|
323
|
-
const component = new TickComponent({
|
|
324
|
-
categories,
|
|
325
|
-
onChangeCategory: jest.fn(),
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
component.setState = jest.fn();
|
|
329
|
-
component.changeInteractive(0, false);
|
|
330
|
-
|
|
331
|
-
expect(component.setState).toHaveBeenCalledWith(
|
|
332
|
-
expect.objectContaining({
|
|
333
|
-
dialog: expect.objectContaining({
|
|
334
|
-
open: true,
|
|
335
|
-
title: 'Warning',
|
|
336
|
-
}),
|
|
337
|
-
}),
|
|
338
|
-
);
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
it('changes interactive without warning when enabling', () => {
|
|
342
|
-
const onChangeCategory = jest.fn();
|
|
343
|
-
const categories = [{ value: 1, label: 'test', editable: true, interactive: false }];
|
|
344
|
-
const component = new TickComponent({
|
|
345
|
-
categories,
|
|
346
|
-
onChangeCategory,
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
component.changeInteractive(0, true);
|
|
350
|
-
|
|
351
|
-
expect(onChangeCategory).toHaveBeenCalledWith(0, expect.objectContaining({ interactive: true }));
|
|
352
|
-
});
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
describe('editable checkbox', () => {
|
|
356
|
-
it('shows warning when disabling editable with correct answer name', () => {
|
|
357
|
-
const categories = [
|
|
358
|
-
{
|
|
359
|
-
value: 1,
|
|
360
|
-
label: 'test',
|
|
361
|
-
editable: true,
|
|
362
|
-
interactive: true,
|
|
363
|
-
correctness: { value: 'correct' },
|
|
364
|
-
},
|
|
365
|
-
];
|
|
366
|
-
const component = new TickComponent({
|
|
367
|
-
categories,
|
|
368
|
-
onChangeCategory: jest.fn(),
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
component.setState = jest.fn();
|
|
372
|
-
component.changeEditable(0, false);
|
|
373
|
-
|
|
374
|
-
expect(component.setState).toHaveBeenCalledWith(
|
|
375
|
-
expect.objectContaining({
|
|
376
|
-
dialog: expect.objectContaining({
|
|
377
|
-
open: true,
|
|
378
|
-
title: 'Warning',
|
|
379
|
-
}),
|
|
380
|
-
}),
|
|
381
|
-
);
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
it('changes editable without warning when enabling', () => {
|
|
385
|
-
const onChangeCategory = jest.fn();
|
|
386
|
-
const categories = [{ value: 1, label: 'test', editable: false, interactive: true }];
|
|
387
|
-
const component = new TickComponent({
|
|
388
|
-
categories,
|
|
389
|
-
onChangeCategory,
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
component.changeEditable(0, true);
|
|
393
|
-
|
|
394
|
-
expect(onChangeCategory).toHaveBeenCalledWith(0, expect.objectContaining({ editable: true }));
|
|
395
|
-
});
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
describe('splitText method', () => {
|
|
399
|
-
it('splits text into chunks', () => {
|
|
400
|
-
const component = new TickComponent({ categories: [] });
|
|
401
|
-
const result = component.splitText('This is a long text', 10);
|
|
402
|
-
|
|
403
|
-
expect(result.length).toBeGreaterThan(1);
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
it('splits at word boundaries', () => {
|
|
407
|
-
const component = new TickComponent({ categories: [] });
|
|
408
|
-
const result = component.splitText('Hello world test', 11);
|
|
409
|
-
|
|
410
|
-
expect(result[0]).toBe('Hello world');
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
it('handles text shorter than max', () => {
|
|
414
|
-
const component = new TickComponent({ categories: [] });
|
|
415
|
-
const result = component.splitText('Short', 20);
|
|
416
|
-
|
|
417
|
-
expect(result).toEqual(['Short']);
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
it('handles empty text', () => {
|
|
421
|
-
const component = new TickComponent({ categories: [] });
|
|
422
|
-
const result = component.splitText('', 10);
|
|
423
|
-
|
|
424
|
-
expect(result).toEqual([]);
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
it('handles null text', () => {
|
|
428
|
-
const component = new TickComponent({ categories: [] });
|
|
429
|
-
const result = component.splitText(null, 10);
|
|
430
|
-
|
|
431
|
-
expect(result).toEqual([]);
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
it('forces split when no spaces', () => {
|
|
435
|
-
const component = new TickComponent({ categories: [] });
|
|
436
|
-
const result = component.splitText('verylongwordwithoutspaces', 10);
|
|
437
|
-
|
|
438
|
-
expect(result.length).toBeGreaterThan(1);
|
|
439
|
-
expect(result[0].length).toBeLessThanOrEqual(10);
|
|
440
|
-
});
|
|
441
|
-
});
|
|
442
|
-
|
|
443
|
-
describe('correctness display', () => {
|
|
444
|
-
it('renders correctness indicator when showCorrectness is true', () => {
|
|
445
|
-
const categories = [
|
|
446
|
-
{
|
|
447
|
-
value: 1,
|
|
448
|
-
label: 'test',
|
|
449
|
-
editable: true,
|
|
450
|
-
interactive: true,
|
|
451
|
-
correctness: { value: 'correct', label: 'Correct!' },
|
|
452
|
-
},
|
|
453
|
-
];
|
|
454
|
-
const { getByTestId } = renderComponent({
|
|
455
|
-
categories,
|
|
456
|
-
formattedValue: '0-test',
|
|
457
|
-
showCorrectness: true,
|
|
458
|
-
});
|
|
459
|
-
|
|
460
|
-
expect(getByTestId('tick-correctness-indicator')).toBeInTheDocument();
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
it('does not render correctness indicator when showCorrectness is false', () => {
|
|
464
|
-
const categories = [
|
|
465
|
-
{
|
|
466
|
-
value: 1,
|
|
467
|
-
label: 'test',
|
|
468
|
-
editable: true,
|
|
469
|
-
interactive: true,
|
|
470
|
-
correctness: { value: 'correct', label: 'Correct!' },
|
|
471
|
-
},
|
|
472
|
-
];
|
|
473
|
-
const { queryByTestId } = renderComponent({
|
|
474
|
-
categories,
|
|
475
|
-
formattedValue: '0-test',
|
|
476
|
-
showCorrectness: false,
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
expect(queryByTestId('tick-correctness-indicator')).not.toBeInTheDocument();
|
|
480
|
-
});
|
|
481
|
-
|
|
482
|
-
it('does not render correctness indicator when not interactive', () => {
|
|
483
|
-
const categories = [
|
|
484
|
-
{
|
|
485
|
-
value: 1,
|
|
486
|
-
label: 'test',
|
|
487
|
-
editable: true,
|
|
488
|
-
interactive: false,
|
|
489
|
-
correctness: { value: 'correct', label: 'Correct!' },
|
|
490
|
-
},
|
|
491
|
-
];
|
|
492
|
-
const { queryByTestId } = renderComponent({
|
|
493
|
-
categories,
|
|
494
|
-
formattedValue: '0-test',
|
|
495
|
-
showCorrectness: true,
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
expect(queryByTestId('tick-correctness-indicator')).not.toBeInTheDocument();
|
|
499
|
-
});
|
|
500
|
-
});
|
|
501
|
-
|
|
502
|
-
describe('error display', () => {
|
|
503
|
-
it('renders error message for first category', () => {
|
|
504
|
-
const error = { 0: 'Error message' };
|
|
505
|
-
const { getByTestId } = renderComponent({
|
|
506
|
-
error,
|
|
507
|
-
formattedValue: '0-test',
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
expect(getByTestId('mark-label-error')).toBeInTheDocument();
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
it('renders distinct error messages', () => {
|
|
514
|
-
const error = { 0: 'Error 1', 1: 'Error 1', 2: 'Error 2' };
|
|
515
|
-
const { container } = renderComponent({
|
|
516
|
-
error,
|
|
517
|
-
formattedValue: '0-test',
|
|
518
|
-
});
|
|
519
|
-
|
|
520
|
-
const errorText = container.querySelector('text');
|
|
521
|
-
expect(errorText).toBeInTheDocument();
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
it('does not render error when no error prop', () => {
|
|
525
|
-
const { queryByTestId } = renderComponent({ error: null });
|
|
526
|
-
expect(queryByTestId('mark-label-error')).not.toBeInTheDocument();
|
|
527
|
-
});
|
|
528
|
-
});
|
|
529
|
-
|
|
530
|
-
describe('autoFocus handling', () => {
|
|
531
|
-
it('handles autoFocus prop', () => {
|
|
532
|
-
const onAutoFocusUsed = jest.fn();
|
|
533
|
-
const { rerender } = renderComponent({
|
|
534
|
-
autoFocus: false,
|
|
535
|
-
onAutoFocusUsed,
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
rerender(
|
|
539
|
-
<ThemeProvider theme={theme}>
|
|
540
|
-
<svg>
|
|
541
|
-
<TickComponent
|
|
542
|
-
{...{
|
|
543
|
-
graphProps: graphProps(),
|
|
544
|
-
xBand: createBandScale(['a', 'b', 'c'], [0, 400]),
|
|
545
|
-
categories: defaultCategories,
|
|
546
|
-
formattedValue: '0-Category A',
|
|
547
|
-
bandWidth: 100,
|
|
548
|
-
barWidth: 100,
|
|
549
|
-
x: 50,
|
|
550
|
-
y: 50,
|
|
551
|
-
top: 0,
|
|
552
|
-
onChangeCategory: jest.fn(),
|
|
553
|
-
autoFocus: true,
|
|
554
|
-
onAutoFocusUsed,
|
|
555
|
-
}}
|
|
556
|
-
/>
|
|
557
|
-
</svg>
|
|
558
|
-
</ThemeProvider>,
|
|
559
|
-
);
|
|
560
|
-
|
|
561
|
-
expect(onAutoFocusUsed).toHaveBeenCalled();
|
|
562
|
-
});
|
|
563
|
-
});
|
|
564
|
-
|
|
565
|
-
describe('define chart mode', () => {
|
|
566
|
-
it('renders interactive checkboxes when changeInteractiveEnabled', () => {
|
|
567
|
-
const chartingOptions = {
|
|
568
|
-
changeInteractive: { authoringLabel: 'Allow students to change' },
|
|
569
|
-
};
|
|
570
|
-
const { container } = renderComponent({
|
|
571
|
-
defineChart: true,
|
|
572
|
-
chartingOptions,
|
|
573
|
-
changeInteractiveEnabled: true,
|
|
574
|
-
formattedValue: '0-test',
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
const text = container.querySelector('text');
|
|
578
|
-
expect(text).toBeInTheDocument();
|
|
579
|
-
});
|
|
580
|
-
|
|
581
|
-
it('renders editable checkboxes when changeEditableEnabled', () => {
|
|
582
|
-
const chartingOptions = {
|
|
583
|
-
changeEditable: { authoringLabel: 'Allow label editing' },
|
|
584
|
-
};
|
|
585
|
-
const { container } = renderComponent({
|
|
586
|
-
defineChart: true,
|
|
587
|
-
chartingOptions,
|
|
588
|
-
changeEditableEnabled: true,
|
|
589
|
-
formattedValue: '0-test',
|
|
590
|
-
});
|
|
591
|
-
|
|
592
|
-
const text = container.querySelector('text');
|
|
593
|
-
expect(text).toBeInTheDocument();
|
|
594
|
-
});
|
|
595
|
-
|
|
596
|
-
it('splits long authoring labels', () => {
|
|
597
|
-
const chartingOptions = {
|
|
598
|
-
changeInteractive: { authoringLabel: 'This is a very long label that needs to be split' },
|
|
599
|
-
};
|
|
600
|
-
const { container } = renderComponent({
|
|
601
|
-
defineChart: true,
|
|
602
|
-
chartingOptions,
|
|
603
|
-
changeInteractiveEnabled: true,
|
|
604
|
-
formattedValue: '0-test',
|
|
605
|
-
});
|
|
606
|
-
|
|
607
|
-
const tspans = container.querySelectorAll('tspan');
|
|
608
|
-
expect(tspans.length).toBeGreaterThan(1);
|
|
609
|
-
});
|
|
610
|
-
});
|
|
611
|
-
|
|
612
|
-
describe('edge cases', () => {
|
|
613
|
-
it('handles missing category', () => {
|
|
614
|
-
const { container } = renderComponent({
|
|
615
|
-
categories: [],
|
|
616
|
-
formattedValue: '0-missing',
|
|
617
|
-
});
|
|
618
|
-
expect(container).toBeInTheDocument();
|
|
619
|
-
});
|
|
620
|
-
|
|
621
|
-
it('handles invalid formattedValue format', () => {
|
|
622
|
-
const { container } = renderComponent({
|
|
623
|
-
formattedValue: 'invalid',
|
|
624
|
-
});
|
|
625
|
-
expect(container).toBeInTheDocument();
|
|
626
|
-
});
|
|
627
|
-
|
|
628
|
-
it('handles missing graphProps', () => {
|
|
629
|
-
const { container } = renderComponent({
|
|
630
|
-
graphProps: null,
|
|
631
|
-
});
|
|
632
|
-
expect(container).toBeInTheDocument();
|
|
633
|
-
});
|
|
634
|
-
|
|
635
|
-
it('handles zero barWidth', () => {
|
|
636
|
-
const { container } = renderComponent({
|
|
637
|
-
barWidth: 0,
|
|
638
|
-
});
|
|
639
|
-
expect(container).toBeInTheDocument();
|
|
640
|
-
});
|
|
641
|
-
|
|
642
|
-
it('handles negative coordinates', () => {
|
|
643
|
-
const { container } = renderComponent({
|
|
644
|
-
x: -10,
|
|
645
|
-
y: -20,
|
|
646
|
-
});
|
|
647
|
-
expect(container).toBeInTheDocument();
|
|
648
|
-
});
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
describe('componentDidUpdate', () => {
|
|
652
|
-
it('calls onAutoFocusUsed when autoFocus changes to true', () => {
|
|
653
|
-
const onAutoFocusUsed = jest.fn();
|
|
654
|
-
const component = new TickComponent({
|
|
655
|
-
autoFocus: false,
|
|
656
|
-
onAutoFocusUsed,
|
|
657
|
-
});
|
|
658
|
-
|
|
659
|
-
component.componentDidUpdate({ autoFocus: false });
|
|
660
|
-
expect(onAutoFocusUsed).not.toHaveBeenCalled();
|
|
661
|
-
|
|
662
|
-
component.props = { autoFocus: true, onAutoFocusUsed };
|
|
663
|
-
component.componentDidUpdate({ autoFocus: false });
|
|
664
|
-
expect(onAutoFocusUsed).toHaveBeenCalled();
|
|
665
|
-
});
|
|
666
|
-
});
|
|
667
|
-
});
|