@pie-lib/graphing-solution-set 4.0.4-next.3 → 4.0.4-next.30
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/autosize-input.d.ts +10 -0
- package/dist/autosize-input.js +66 -0
- package/dist/axis/arrow.d.ts +13 -0
- package/dist/axis/arrow.js +34 -0
- package/dist/axis/axes.d.ts +132 -0
- package/dist/axis/axes.js +214 -0
- package/dist/axis/index.d.ts +10 -0
- package/dist/bg.d.ts +51 -0
- package/dist/bg.js +44 -0
- package/dist/container/actions.d.ts +15 -0
- package/dist/container/actions.js +7 -0
- package/dist/container/index.d.ts +58 -0
- package/dist/container/index.js +48 -0
- package/dist/container/marks.d.ts +10 -0
- package/dist/container/marks.js +11 -0
- package/dist/container/middleware.d.ts +10 -0
- package/dist/container/middleware.js +4 -0
- package/dist/container/reducer.d.ts +14 -0
- package/dist/container/reducer.js +7 -0
- package/dist/coordinates-label.d.ts +50 -0
- package/dist/coordinates-label.js +46 -0
- package/dist/graph-with-controls.d.ts +85 -0
- package/dist/graph-with-controls.js +155 -0
- package/dist/graph.d.ts +119 -0
- package/dist/graph.js +221 -0
- package/dist/grid-setup.d.ts +27 -0
- package/dist/grid-setup.js +307 -0
- package/dist/grid.d.ts +43 -0
- package/dist/grid.js +59 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +6 -0
- package/dist/labels.d.ts +73 -0
- package/dist/labels.js +134 -0
- package/dist/mark-label.d.ts +50 -0
- package/dist/mark-label.js +84 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Axis.js +101 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +63 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Ticks.js +44 -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/Grid.js +79 -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 +50 -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/utils/coerceNumber.js +10 -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/toString.js +6 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Line.js +47 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/lib/shapes/Line.js +53 -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/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/classnames@2.5.1/node_modules/classnames/index.js +32 -0
- package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -0
- package/dist/node_modules/.bun/invariant@2.2.4/node_modules/invariant/browser.js +28 -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-redux@9.3.0_9e2203c65d1d5fa1/node_modules/react-redux/dist/react-redux.js +471 -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/node_modules/.bun/redux-undo@1.1.0/node_modules/redux-undo/dist/redux-undo.js +185 -0
- package/dist/node_modules/.bun/redux@5.0.1/node_modules/redux/dist/redux.js +198 -0
- package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js +53 -0
- package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.js +51 -0
- package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/with-selector.js +10 -0
- package/dist/toggle-bar.d.ts +40 -0
- package/dist/tool-menu.d.ts +21 -0
- package/dist/tool-menu.js +188 -0
- package/dist/tools/index.d.ts +17 -0
- package/dist/tools/index.js +12 -0
- package/dist/tools/line/component.d.ts +113 -0
- package/dist/tools/line/component.js +58 -0
- package/dist/tools/line/index.d.ts +13 -0
- package/dist/tools/line/index.js +6 -0
- package/dist/tools/polygon/component.d.ts +117 -0
- package/dist/tools/polygon/component.js +194 -0
- package/dist/tools/polygon/index.d.ts +19 -0
- package/dist/tools/polygon/index.js +55 -0
- package/dist/tools/polygon/line.d.ts +125 -0
- package/dist/tools/polygon/polygon.d.ts +122 -0
- package/dist/tools/polygon/polygon.js +62 -0
- package/dist/tools/shared/arrow-head.d.ts +43 -0
- package/dist/tools/shared/arrow-head.js +37 -0
- package/dist/tools/shared/line/index.d.ts +240 -0
- package/dist/tools/shared/line/index.js +320 -0
- package/dist/tools/shared/line/line-path.d.ts +57 -0
- package/dist/tools/shared/line/with-root-edge.d.ts +143 -0
- package/dist/tools/shared/point/arrow-point.d.ts +57 -0
- package/dist/tools/shared/point/arrow-point.js +47 -0
- package/dist/tools/shared/point/arrow.d.ts +46 -0
- package/dist/tools/shared/point/arrow.js +36 -0
- package/dist/tools/shared/point/base-point.d.ts +50 -0
- package/dist/tools/shared/point/base-point.js +88 -0
- package/dist/tools/shared/point/index.d.ts +217 -0
- package/dist/tools/shared/point/index.js +51 -0
- package/dist/tools/shared/styles.d.ts +24 -0
- package/dist/tools/shared/styles.js +17 -0
- package/dist/tools/shared/types.d.ts +15 -0
- package/dist/tools/shared/types.js +10 -0
- package/dist/undo-redo.d.ts +20 -0
- package/dist/undo-redo.js +33 -0
- package/dist/use-debounce.d.ts +9 -0
- package/dist/use-debounce.js +13 -0
- package/dist/utils.d.ts +58 -0
- package/dist/utils.js +72 -0
- package/package.json +46 -34
- package/CHANGELOG.json +0 -1
- package/CHANGELOG.md +0 -449
- package/LICENSE.md +0 -5
- package/lib/axis/arrow.js +0 -79
- package/lib/axis/arrow.js.map +0 -1
- package/lib/axis/axes.js +0 -327
- package/lib/axis/axes.js.map +0 -1
- package/lib/axis/index.js +0 -21
- package/lib/axis/index.js.map +0 -1
- package/lib/bg.js +0 -114
- package/lib/bg.js.map +0 -1
- package/lib/container/actions.js +0 -18
- package/lib/container/actions.js.map +0 -1
- package/lib/container/index.js +0 -120
- package/lib/container/index.js.map +0 -1
- package/lib/container/marks.js +0 -22
- package/lib/container/marks.js.map +0 -1
- package/lib/container/middleware.js +0 -19
- package/lib/container/middleware.js.map +0 -1
- package/lib/container/reducer.js +0 -18
- package/lib/container/reducer.js.map +0 -1
- package/lib/coordinates-label.js +0 -77
- package/lib/coordinates-label.js.map +0 -1
- package/lib/graph-with-controls.js +0 -297
- package/lib/graph-with-controls.js.map +0 -1
- package/lib/graph.js +0 -353
- package/lib/graph.js.map +0 -1
- package/lib/grid-setup.js +0 -414
- package/lib/grid-setup.js.map +0 -1
- package/lib/grid.js +0 -131
- package/lib/grid.js.map +0 -1
- package/lib/index.js +0 -40
- package/lib/index.js.map +0 -1
- package/lib/labels.js +0 -199
- package/lib/labels.js.map +0 -1
- package/lib/mark-label.js +0 -159
- package/lib/mark-label.js.map +0 -1
- package/lib/toggle-bar.js +0 -248
- package/lib/toggle-bar.js.map +0 -1
- package/lib/tool-menu.js +0 -218
- package/lib/tool-menu.js.map +0 -1
- package/lib/tools/index.js +0 -24
- package/lib/tools/index.js.map +0 -1
- package/lib/tools/line/component.js +0 -92
- package/lib/tools/line/component.js.map +0 -1
- package/lib/tools/line/index.js +0 -11
- package/lib/tools/line/index.js.map +0 -1
- package/lib/tools/polygon/component.js +0 -358
- package/lib/tools/polygon/component.js.map +0 -1
- package/lib/tools/polygon/index.js +0 -89
- package/lib/tools/polygon/index.js.map +0 -1
- package/lib/tools/polygon/line.js +0 -114
- package/lib/tools/polygon/line.js.map +0 -1
- package/lib/tools/polygon/polygon.js +0 -128
- package/lib/tools/polygon/polygon.js.map +0 -1
- package/lib/tools/shared/arrow-head.js +0 -62
- package/lib/tools/shared/arrow-head.js.map +0 -1
- package/lib/tools/shared/line/index.js +0 -539
- package/lib/tools/shared/line/index.js.map +0 -1
- package/lib/tools/shared/line/line-path.js +0 -121
- package/lib/tools/shared/line/line-path.js.map +0 -1
- package/lib/tools/shared/line/with-root-edge.js +0 -121
- package/lib/tools/shared/line/with-root-edge.js.map +0 -1
- package/lib/tools/shared/point/arrow-point.js +0 -86
- package/lib/tools/shared/point/arrow-point.js.map +0 -1
- package/lib/tools/shared/point/arrow.js +0 -70
- package/lib/tools/shared/point/arrow.js.map +0 -1
- package/lib/tools/shared/point/base-point.js +0 -137
- package/lib/tools/shared/point/base-point.js.map +0 -1
- package/lib/tools/shared/point/index.js +0 -80
- package/lib/tools/shared/point/index.js.map +0 -1
- package/lib/tools/shared/styles.js +0 -26
- package/lib/tools/shared/styles.js.map +0 -1
- package/lib/tools/shared/types.js +0 -15
- package/lib/tools/shared/types.js.map +0 -1
- package/lib/undo-redo.js +0 -67
- package/lib/undo-redo.js.map +0 -1
- package/lib/use-debounce.js +0 -25
- package/lib/use-debounce.js.map +0 -1
- package/lib/utils.js +0 -235
- package/lib/utils.js.map +0 -1
- package/src/__tests__/bg.test.jsx +0 -250
- package/src/__tests__/coordinates-label.test.jsx +0 -243
- package/src/__tests__/graph-with-controls.test.jsx +0 -184
- package/src/__tests__/graph.test.jsx +0 -93
- package/src/__tests__/grid-setup.test.jsx +0 -645
- package/src/__tests__/grid.test.jsx +0 -23
- package/src/__tests__/labels.test.jsx +0 -41
- package/src/__tests__/mark-label.test.jsx +0 -66
- package/src/__tests__/toggle-bar.test.jsx +0 -106
- package/src/__tests__/tool-menu.test.jsx +0 -453
- package/src/__tests__/undo-redo.test.jsx +0 -26
- package/src/__tests__/use-debounce.test.js +0 -21
- package/src/__tests__/utils.js +0 -41
- package/src/__tests__/utils.test.js +0 -105
- package/src/axis/__tests__/arrow.test.jsx +0 -43
- package/src/axis/__tests__/axes.test.jsx +0 -182
- package/src/axis/arrow.jsx +0 -57
- package/src/axis/axes.jsx +0 -284
- package/src/axis/index.js +0 -3
- package/src/bg.jsx +0 -96
- package/src/container/__tests__/actions.test.js +0 -105
- package/src/container/__tests__/index.test.jsx +0 -227
- package/src/container/__tests__/marks.test.js +0 -172
- package/src/container/__tests__/middleware.test.js +0 -235
- package/src/container/__tests__/reducer.test.js +0 -324
- package/src/container/actions.js +0 -8
- package/src/container/index.jsx +0 -85
- package/src/container/marks.js +0 -14
- package/src/container/middleware.js +0 -7
- package/src/container/reducer.js +0 -5
- package/src/coordinates-label.jsx +0 -62
- package/src/graph-with-controls.jsx +0 -242
- package/src/graph.jsx +0 -333
- package/src/grid-setup.jsx +0 -432
- package/src/grid.jsx +0 -133
- package/src/index.js +0 -7
- package/src/labels.jsx +0 -173
- package/src/mark-label.jsx +0 -125
- package/src/toggle-bar.jsx +0 -221
- package/src/tool-menu.jsx +0 -235
- package/src/tools/index.js +0 -8
- package/src/tools/line/__tests__/component.test.jsx +0 -37
- package/src/tools/line/component.jsx +0 -77
- package/src/tools/line/index.js +0 -4
- package/src/tools/polygon/__tests__/component.test.jsx +0 -487
- package/src/tools/polygon/__tests__/index.test.js +0 -65
- package/src/tools/polygon/__tests__/line.test.jsx +0 -23
- package/src/tools/polygon/__tests__/polygon.test.jsx +0 -44
- package/src/tools/polygon/component.jsx +0 -324
- package/src/tools/polygon/index.js +0 -52
- package/src/tools/polygon/line.jsx +0 -80
- package/src/tools/polygon/polygon.jsx +0 -93
- package/src/tools/shared/__tests__/arrow-head.test.jsx +0 -33
- package/src/tools/shared/arrow-head.jsx +0 -46
- package/src/tools/shared/line/__tests__/index.test.jsx +0 -553
- package/src/tools/shared/line/__tests__/line-path.test.jsx +0 -56
- package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +0 -488
- package/src/tools/shared/line/index.jsx +0 -471
- package/src/tools/shared/line/line-path.jsx +0 -85
- package/src/tools/shared/line/with-root-edge.jsx +0 -97
- package/src/tools/shared/point/__tests__/arrow-point.test.jsx +0 -91
- package/src/tools/shared/point/__tests__/arrow.test.jsx +0 -469
- package/src/tools/shared/point/__tests__/base-point.test.jsx +0 -87
- package/src/tools/shared/point/arrow-point.jsx +0 -60
- package/src/tools/shared/point/arrow.jsx +0 -40
- package/src/tools/shared/point/base-point.jsx +0 -113
- package/src/tools/shared/point/index.jsx +0 -58
- package/src/tools/shared/styles.js +0 -20
- package/src/tools/shared/types.js +0 -8
- package/src/undo-redo.jsx +0 -37
- package/src/use-debounce.js +0 -13
- package/src/utils.js +0 -230
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { render } from '@pie-lib/test-utils';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { coordinates, MarkLabel, position } from '../mark-label';
|
|
4
|
-
import { graphProps as getGraphProps } from './utils';
|
|
5
|
-
|
|
6
|
-
describe('MarkLabel', () => {
|
|
7
|
-
let onChange = jest.fn();
|
|
8
|
-
let inputRef = jest.fn();
|
|
9
|
-
|
|
10
|
-
const renderComponent = (extras) => {
|
|
11
|
-
const defaults = {
|
|
12
|
-
classes: {},
|
|
13
|
-
className: 'className',
|
|
14
|
-
onChange,
|
|
15
|
-
inputRef,
|
|
16
|
-
mark: { x: 1, y: 1 },
|
|
17
|
-
graphProps: getGraphProps(0, 10, 0, 10),
|
|
18
|
-
};
|
|
19
|
-
const props = { ...defaults, ...extras };
|
|
20
|
-
return render(<MarkLabel {...props} />);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
describe('rendering', () => {
|
|
24
|
-
it('renders without crashing', () => {
|
|
25
|
-
const { container } = renderComponent();
|
|
26
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('renders with different mark position', () => {
|
|
30
|
-
const { container } = renderComponent({ mark: { x: 10, y: 10 } });
|
|
31
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
describe('position', () => {
|
|
37
|
-
const assertPosition = (mark, rect, expected) => {
|
|
38
|
-
it(`${mark.x},${mark.y} + ${rect.width},${rect.height} => ${expected}`, () => {
|
|
39
|
-
// we set range.min to a value because in pixels - the greater the Y the lower down on the screen.
|
|
40
|
-
const graphProps = getGraphProps(0, 12, 12, 0);
|
|
41
|
-
const result = position(graphProps, mark, rect);
|
|
42
|
-
expect(result).toEqual(expected);
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
assertPosition({ x: 0, y: 0 }, { width: 10, height: 10 }, 'top-left');
|
|
47
|
-
assertPosition({ x: 0, y: 0 }, { width: 1, height: 1 }, 'bottom-right');
|
|
48
|
-
assertPosition({ x: 0, y: 0 }, { width: 10, height: 0 }, 'bottom-left');
|
|
49
|
-
assertPosition({ x: 0, y: 0 }, { width: 0, height: 10 }, 'top-right');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe('coordinates', () => {
|
|
53
|
-
const assertCoordinates = (mark, rect, pos, expected) => {
|
|
54
|
-
it(`${mark.x}, ${mark.y} -> ${pos} = ${expected.left}, ${expected.top}`, () => {
|
|
55
|
-
const result = coordinates(getGraphProps(), mark, rect, pos);
|
|
56
|
-
expect(result).toEqual(expected);
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
assertCoordinates({ x: 0, y: 0 }, { width: 0, height: 0 }, 'top-left', { left: -10, top: -10 });
|
|
60
|
-
assertCoordinates({ x: 0, y: 0 }, { width: 0, height: 0 }, 'bottom-left', { left: -10, top: 10 });
|
|
61
|
-
assertCoordinates({ x: 0, y: 0 }, { width: 0, height: 0 }, 'top-right', { left: 10, top: -10 });
|
|
62
|
-
assertCoordinates({ x: 0, y: 0 }, { width: 0, height: 0 }, 'bottom-right', {
|
|
63
|
-
left: 10,
|
|
64
|
-
top: 10,
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@pie-lib/test-utils';
|
|
2
|
-
import userEvent from '@testing-library/user-event';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
import { ToggleBar } from '../toggle-bar';
|
|
6
|
-
|
|
7
|
-
// Mock DragProvider to avoid @dnd-kit React version conflicts
|
|
8
|
-
jest.mock('@pie-lib/drag', () => ({
|
|
9
|
-
DragProvider: ({ children }) => <div data-testid="drag-provider">{children}</div>,
|
|
10
|
-
}));
|
|
11
|
-
|
|
12
|
-
// Mock @dnd-kit/core hooks to avoid DndContext requirement
|
|
13
|
-
jest.mock('@dnd-kit/core', () => ({
|
|
14
|
-
useDraggable: jest.fn(() => ({
|
|
15
|
-
attributes: {
|
|
16
|
-
role: 'button',
|
|
17
|
-
tabIndex: 0,
|
|
18
|
-
},
|
|
19
|
-
listeners: {
|
|
20
|
-
onPointerDown: jest.fn(),
|
|
21
|
-
},
|
|
22
|
-
setNodeRef: jest.fn(),
|
|
23
|
-
transform: null,
|
|
24
|
-
transition: null,
|
|
25
|
-
isDragging: false,
|
|
26
|
-
})),
|
|
27
|
-
useDroppable: jest.fn(() => ({
|
|
28
|
-
setNodeRef: jest.fn(),
|
|
29
|
-
isOver: false,
|
|
30
|
-
active: null,
|
|
31
|
-
})),
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
// Mock @dnd-kit/utilities for CSS transform
|
|
35
|
-
jest.mock('@dnd-kit/utilities', () => ({
|
|
36
|
-
CSS: {
|
|
37
|
-
Transform: {
|
|
38
|
-
toString: jest.fn((transform) => (transform ? 'translate3d(0, 0, 0)' : '')),
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
}));
|
|
42
|
-
|
|
43
|
-
// Mock @dnd-kit/sortable for arrayMove
|
|
44
|
-
jest.mock('@dnd-kit/sortable', () => ({
|
|
45
|
-
arrayMove: jest.fn((array, from, to) => {
|
|
46
|
-
const newArray = [...array];
|
|
47
|
-
const [removed] = newArray.splice(from, 1);
|
|
48
|
-
newArray.splice(to, 0, removed);
|
|
49
|
-
return newArray;
|
|
50
|
-
}),
|
|
51
|
-
}));
|
|
52
|
-
|
|
53
|
-
// Mock Translator to return the key as-is for testing
|
|
54
|
-
jest.mock('@pie-lib/translator', () => ({
|
|
55
|
-
translator: {
|
|
56
|
-
t: (key) => {
|
|
57
|
-
// Extract tool name from key like "graphing.point" -> "point"
|
|
58
|
-
const parts = key.split('.');
|
|
59
|
-
return parts[parts.length - 1];
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
}));
|
|
63
|
-
|
|
64
|
-
describe('ToggleBar', () => {
|
|
65
|
-
let onChange = jest.fn();
|
|
66
|
-
|
|
67
|
-
beforeEach(() => {
|
|
68
|
-
onChange.mockClear();
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const renderComponent = (extras) => {
|
|
72
|
-
const defaults = {
|
|
73
|
-
className: 'className',
|
|
74
|
-
onChange,
|
|
75
|
-
options: ['line', 'polygon'],
|
|
76
|
-
language: 'en',
|
|
77
|
-
};
|
|
78
|
-
const props = { ...defaults, ...extras };
|
|
79
|
-
return render(<ToggleBar {...props} />);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
describe('rendering', () => {
|
|
83
|
-
it('renders without crashing', () => {
|
|
84
|
-
const { container } = renderComponent();
|
|
85
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('renders tool buttons for valid tools', () => {
|
|
89
|
-
renderComponent({ options: ['line', 'polygon'] });
|
|
90
|
-
expect(screen.getByText(/line/i)).toBeInTheDocument();
|
|
91
|
-
expect(screen.getByText(/polygon/i)).toBeInTheDocument();
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
describe('interactions', () => {
|
|
96
|
-
it('calls onChange when tool button is clicked', async () => {
|
|
97
|
-
const user = userEvent.setup();
|
|
98
|
-
renderComponent({ options: ['line', 'polygon'] });
|
|
99
|
-
|
|
100
|
-
const lineButton = screen.getByText(/line/i).closest('button');
|
|
101
|
-
await user.click(lineButton);
|
|
102
|
-
|
|
103
|
-
expect(onChange).toHaveBeenCalledWith('line');
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
});
|
|
@@ -1,453 +0,0 @@
|
|
|
1
|
-
import { fireEvent, render } from '@pie-lib/test-utils';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
import ToolMenu from '../tool-menu';
|
|
5
|
-
|
|
6
|
-
describe('ToolMenu', () => {
|
|
7
|
-
let onChange;
|
|
8
|
-
const tools = ['one', 'two'];
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
onChange = jest.fn();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const renderComponent = (extras) => {
|
|
15
|
-
const defaults = {
|
|
16
|
-
classes: {},
|
|
17
|
-
className: 'className',
|
|
18
|
-
onChange,
|
|
19
|
-
currentTool: tools[0],
|
|
20
|
-
tools,
|
|
21
|
-
gssLineData: {
|
|
22
|
-
selectedTool: 'lineA',
|
|
23
|
-
numberOfLines: 2,
|
|
24
|
-
lineA: { lineType: 'Solid' },
|
|
25
|
-
lineB: { lineType: 'Solid' },
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
const props = { ...defaults, ...extras };
|
|
29
|
-
return render(<ToolMenu {...props} />);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
describe('rendering', () => {
|
|
33
|
-
it('renders without crashing', () => {
|
|
34
|
-
const { container } = renderComponent();
|
|
35
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('renders Line A radio button', () => {
|
|
39
|
-
const { getByText } = renderComponent();
|
|
40
|
-
expect(getByText('Line A')).toBeInTheDocument();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('renders Line B radio button when numberOfLines is 2', () => {
|
|
44
|
-
const { getByText } = renderComponent();
|
|
45
|
-
expect(getByText('Line B')).toBeInTheDocument();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('does not render Line B radio button when numberOfLines is 1', () => {
|
|
49
|
-
const { queryByText } = renderComponent({
|
|
50
|
-
gssLineData: {
|
|
51
|
-
selectedTool: 'lineA',
|
|
52
|
-
numberOfLines: 1,
|
|
53
|
-
lineA: { lineType: 'Solid' },
|
|
54
|
-
lineB: { lineType: 'Solid' },
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
expect(queryByText('Line B')).not.toBeInTheDocument();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('renders Solution Set radio button', () => {
|
|
61
|
-
const { getByText } = renderComponent();
|
|
62
|
-
expect(getByText('Solution Set')).toBeInTheDocument();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('renders Solid and Dashed buttons for Line A', () => {
|
|
66
|
-
const { getAllByText } = renderComponent();
|
|
67
|
-
const solidButtons = getAllByText(/Solid/);
|
|
68
|
-
const dashedButtons = getAllByText(/Dashed/);
|
|
69
|
-
expect(solidButtons.length).toBeGreaterThan(0);
|
|
70
|
-
expect(dashedButtons.length).toBeGreaterThan(0);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('shows checkmark on selected line type for Line A', () => {
|
|
74
|
-
const { getAllByText } = renderComponent({
|
|
75
|
-
gssLineData: {
|
|
76
|
-
selectedTool: 'lineA',
|
|
77
|
-
numberOfLines: 2,
|
|
78
|
-
lineA: { lineType: 'Solid' },
|
|
79
|
-
lineB: { lineType: 'Dashed' },
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
const solidButtons = getAllByText(/✔ Solid/);
|
|
83
|
-
expect(solidButtons.length).toBeGreaterThan(0);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('disables all controls when disabled prop is true', () => {
|
|
87
|
-
const { getAllByRole } = renderComponent({ disabled: true });
|
|
88
|
-
const radios = getAllByRole('radio');
|
|
89
|
-
const buttons = getAllByRole('button');
|
|
90
|
-
|
|
91
|
-
radios.forEach((radio) => {
|
|
92
|
-
expect(radio).toBeDisabled();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
buttons.forEach((button) => {
|
|
96
|
-
expect(button).toBeDisabled();
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
describe('onChangeRadioValue', () => {
|
|
102
|
-
it('calls onChange with updated selectedTool when lineA radio is clicked', () => {
|
|
103
|
-
const { getAllByRole } = renderComponent({
|
|
104
|
-
gssLineData: {
|
|
105
|
-
selectedTool: 'solutionSet',
|
|
106
|
-
numberOfLines: 2,
|
|
107
|
-
lineA: { lineType: 'Solid' },
|
|
108
|
-
lineB: { lineType: 'Solid' },
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
const radios = getAllByRole('radio');
|
|
113
|
-
const lineARadio = radios.find((r) => r.value === 'lineA');
|
|
114
|
-
|
|
115
|
-
fireEvent.click(lineARadio);
|
|
116
|
-
|
|
117
|
-
expect(onChange).toHaveBeenCalledTimes(1);
|
|
118
|
-
const [updatedData, oldSelectedTool] = onChange.mock.calls[0];
|
|
119
|
-
expect(updatedData.selectedTool).toBe('lineA');
|
|
120
|
-
expect(oldSelectedTool).toBe('solutionSet');
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('calls onChange with updated selectedTool when lineB radio is clicked', () => {
|
|
124
|
-
const { getAllByRole } = renderComponent({
|
|
125
|
-
gssLineData: {
|
|
126
|
-
selectedTool: 'lineA',
|
|
127
|
-
numberOfLines: 2,
|
|
128
|
-
lineA: { lineType: 'Solid' },
|
|
129
|
-
lineB: { lineType: 'Solid' },
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
const radios = getAllByRole('radio');
|
|
134
|
-
const lineBRadio = radios.find((r) => r.value === 'lineB');
|
|
135
|
-
|
|
136
|
-
fireEvent.click(lineBRadio);
|
|
137
|
-
|
|
138
|
-
expect(onChange).toHaveBeenCalledTimes(1);
|
|
139
|
-
const [updatedData, oldSelectedTool] = onChange.mock.calls[0];
|
|
140
|
-
expect(updatedData.selectedTool).toBe('lineB');
|
|
141
|
-
expect(oldSelectedTool).toBe('lineA');
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('calls onChange with updated selectedTool when solutionSet radio is clicked', () => {
|
|
145
|
-
const { getAllByRole } = renderComponent({
|
|
146
|
-
gssLineData: {
|
|
147
|
-
selectedTool: 'lineA',
|
|
148
|
-
numberOfLines: 2,
|
|
149
|
-
lineA: { lineType: 'Solid' },
|
|
150
|
-
lineB: { lineType: 'Solid' },
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
const radios = getAllByRole('radio');
|
|
155
|
-
const solutionSetRadio = radios.find((r) => r.value === 'solutionSet');
|
|
156
|
-
|
|
157
|
-
fireEvent.click(solutionSetRadio);
|
|
158
|
-
|
|
159
|
-
expect(onChange).toHaveBeenCalledTimes(1);
|
|
160
|
-
const [updatedData, oldSelectedTool] = onChange.mock.calls[0];
|
|
161
|
-
expect(updatedData.selectedTool).toBe('solutionSet');
|
|
162
|
-
expect(oldSelectedTool).toBe('lineA');
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('preserves other gssLineData properties when changing selectedTool', () => {
|
|
166
|
-
const { getAllByRole } = renderComponent({
|
|
167
|
-
gssLineData: {
|
|
168
|
-
selectedTool: 'lineA',
|
|
169
|
-
numberOfLines: 2,
|
|
170
|
-
lineA: { lineType: 'Dashed' },
|
|
171
|
-
lineB: { lineType: 'Solid' },
|
|
172
|
-
},
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
const radios = getAllByRole('radio');
|
|
176
|
-
const lineBRadio = radios.find((r) => r.value === 'lineB');
|
|
177
|
-
|
|
178
|
-
fireEvent.click(lineBRadio);
|
|
179
|
-
|
|
180
|
-
const [updatedData] = onChange.mock.calls[0];
|
|
181
|
-
expect(updatedData.lineA.lineType).toBe('Dashed');
|
|
182
|
-
expect(updatedData.lineB.lineType).toBe('Solid');
|
|
183
|
-
expect(updatedData.numberOfLines).toBe(2);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it('does not call onChange when disabled', () => {
|
|
187
|
-
const { getAllByRole } = renderComponent({
|
|
188
|
-
disabled: true,
|
|
189
|
-
gssLineData: {
|
|
190
|
-
selectedTool: 'lineA',
|
|
191
|
-
numberOfLines: 2,
|
|
192
|
-
lineA: { lineType: 'Solid' },
|
|
193
|
-
lineB: { lineType: 'Solid' },
|
|
194
|
-
},
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
const radios = getAllByRole('radio');
|
|
198
|
-
const lineBRadio = radios.find((r) => r.value === 'lineB');
|
|
199
|
-
|
|
200
|
-
// Disabled radios should not fire change events
|
|
201
|
-
expect(lineBRadio).toBeDisabled();
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
describe('lineTypeChange', () => {
|
|
206
|
-
it('calls onChange with updated lineType for Line A when Solid button is clicked', () => {
|
|
207
|
-
const { getAllByText } = renderComponent({
|
|
208
|
-
gssLineData: {
|
|
209
|
-
selectedTool: 'lineA',
|
|
210
|
-
numberOfLines: 2,
|
|
211
|
-
lineA: { lineType: 'Dashed' },
|
|
212
|
-
lineB: { lineType: 'Solid' },
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
const solidButtons = getAllByText(/Solid/);
|
|
217
|
-
// First solid button should be for Line A
|
|
218
|
-
fireEvent.click(solidButtons[0]);
|
|
219
|
-
|
|
220
|
-
expect(onChange).toHaveBeenCalledTimes(1);
|
|
221
|
-
const [updatedData, oldSelectedTool] = onChange.mock.calls[0];
|
|
222
|
-
expect(updatedData.lineA.lineType).toBe('Solid');
|
|
223
|
-
expect(oldSelectedTool).toBe('lineA');
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it('calls onChange with updated lineType for Line A when Dashed button is clicked', () => {
|
|
227
|
-
const { getAllByText } = renderComponent({
|
|
228
|
-
gssLineData: {
|
|
229
|
-
selectedTool: 'lineA',
|
|
230
|
-
numberOfLines: 2,
|
|
231
|
-
lineA: { lineType: 'Solid' },
|
|
232
|
-
lineB: { lineType: 'Solid' },
|
|
233
|
-
},
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
const dashedButtons = getAllByText(/Dashed/);
|
|
237
|
-
// First dashed button should be for Line A
|
|
238
|
-
fireEvent.click(dashedButtons[0]);
|
|
239
|
-
|
|
240
|
-
expect(onChange).toHaveBeenCalledTimes(1);
|
|
241
|
-
const [updatedData, oldSelectedTool] = onChange.mock.calls[0];
|
|
242
|
-
expect(updatedData.lineA.lineType).toBe('Dashed');
|
|
243
|
-
expect(oldSelectedTool).toBe('lineA');
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('calls onChange with updated lineType for Line B when Solid button is clicked', () => {
|
|
247
|
-
const { getAllByText } = renderComponent({
|
|
248
|
-
gssLineData: {
|
|
249
|
-
selectedTool: 'lineB',
|
|
250
|
-
numberOfLines: 2,
|
|
251
|
-
lineA: { lineType: 'Solid' },
|
|
252
|
-
lineB: { lineType: 'Dashed' },
|
|
253
|
-
},
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
const solidButtons = getAllByText(/Solid/);
|
|
257
|
-
// Second solid button should be for Line B
|
|
258
|
-
fireEvent.click(solidButtons[1]);
|
|
259
|
-
|
|
260
|
-
expect(onChange).toHaveBeenCalledTimes(1);
|
|
261
|
-
const [updatedData, oldSelectedTool] = onChange.mock.calls[0];
|
|
262
|
-
expect(updatedData.lineB.lineType).toBe('Solid');
|
|
263
|
-
expect(oldSelectedTool).toBe('lineB');
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
it('calls onChange with updated lineType for Line B when Dashed button is clicked', () => {
|
|
267
|
-
const { getAllByText } = renderComponent({
|
|
268
|
-
gssLineData: {
|
|
269
|
-
selectedTool: 'lineB',
|
|
270
|
-
numberOfLines: 2,
|
|
271
|
-
lineA: { lineType: 'Solid' },
|
|
272
|
-
lineB: { lineType: 'Solid' },
|
|
273
|
-
},
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
const dashedButtons = getAllByText(/Dashed/);
|
|
277
|
-
// Second dashed button should be for Line B
|
|
278
|
-
fireEvent.click(dashedButtons[1]);
|
|
279
|
-
|
|
280
|
-
expect(onChange).toHaveBeenCalledTimes(1);
|
|
281
|
-
const [updatedData, oldSelectedTool] = onChange.mock.calls[0];
|
|
282
|
-
expect(updatedData.lineB.lineType).toBe('Dashed');
|
|
283
|
-
expect(oldSelectedTool).toBe('lineB');
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
it('preserves other line properties when changing Line A lineType', () => {
|
|
287
|
-
const { getAllByText } = renderComponent({
|
|
288
|
-
gssLineData: {
|
|
289
|
-
selectedTool: 'lineA',
|
|
290
|
-
numberOfLines: 2,
|
|
291
|
-
lineA: { lineType: 'Solid' },
|
|
292
|
-
lineB: { lineType: 'Dashed' },
|
|
293
|
-
},
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
const dashedButtons = getAllByText(/Dashed/);
|
|
297
|
-
fireEvent.click(dashedButtons[0]);
|
|
298
|
-
|
|
299
|
-
const [updatedData] = onChange.mock.calls[0];
|
|
300
|
-
expect(updatedData.lineA.lineType).toBe('Dashed');
|
|
301
|
-
expect(updatedData.lineB.lineType).toBe('Dashed');
|
|
302
|
-
expect(updatedData.selectedTool).toBe('lineA');
|
|
303
|
-
expect(updatedData.numberOfLines).toBe(2);
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
it('preserves other line properties when changing Line B lineType', () => {
|
|
307
|
-
const { getAllByText } = renderComponent({
|
|
308
|
-
gssLineData: {
|
|
309
|
-
selectedTool: 'lineB',
|
|
310
|
-
numberOfLines: 2,
|
|
311
|
-
lineA: { lineType: 'Dashed' },
|
|
312
|
-
lineB: { lineType: 'Solid' },
|
|
313
|
-
},
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
const dashedButtons = getAllByText(/Dashed/);
|
|
317
|
-
fireEvent.click(dashedButtons[1]);
|
|
318
|
-
|
|
319
|
-
const [updatedData] = onChange.mock.calls[0];
|
|
320
|
-
expect(updatedData.lineA.lineType).toBe('Dashed');
|
|
321
|
-
expect(updatedData.lineB.lineType).toBe('Dashed');
|
|
322
|
-
expect(updatedData.selectedTool).toBe('lineB');
|
|
323
|
-
expect(updatedData.numberOfLines).toBe(2);
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
it('handles multiple line type changes correctly', () => {
|
|
327
|
-
const { getAllByText } = renderComponent({
|
|
328
|
-
gssLineData: {
|
|
329
|
-
selectedTool: 'lineA',
|
|
330
|
-
numberOfLines: 2,
|
|
331
|
-
lineA: { lineType: 'Solid' },
|
|
332
|
-
lineB: { lineType: 'Solid' },
|
|
333
|
-
},
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
// Change Line A to Dashed
|
|
337
|
-
let dashedButtons = getAllByText(/Dashed/);
|
|
338
|
-
fireEvent.click(dashedButtons[0]);
|
|
339
|
-
|
|
340
|
-
expect(onChange).toHaveBeenCalledTimes(1);
|
|
341
|
-
let [updatedData] = onChange.mock.calls[0];
|
|
342
|
-
expect(updatedData.lineA.lineType).toBe('Dashed');
|
|
343
|
-
|
|
344
|
-
// Change Line B to Dashed
|
|
345
|
-
dashedButtons = getAllByText(/Dashed/);
|
|
346
|
-
fireEvent.click(dashedButtons[1]);
|
|
347
|
-
|
|
348
|
-
expect(onChange).toHaveBeenCalledTimes(2);
|
|
349
|
-
[updatedData] = onChange.mock.calls[1];
|
|
350
|
-
expect(updatedData.lineB.lineType).toBe('Dashed');
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
it('does not call onChange when line type button is disabled', () => {
|
|
354
|
-
const { getAllByRole } = renderComponent({
|
|
355
|
-
disabled: true,
|
|
356
|
-
gssLineData: {
|
|
357
|
-
selectedTool: 'lineA',
|
|
358
|
-
numberOfLines: 2,
|
|
359
|
-
lineA: { lineType: 'Solid' },
|
|
360
|
-
lineB: { lineType: 'Solid' },
|
|
361
|
-
},
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
const buttons = getAllByRole('button');
|
|
365
|
-
|
|
366
|
-
buttons.forEach((button) => {
|
|
367
|
-
expect(button).toBeDisabled();
|
|
368
|
-
});
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
it('maintains correct state when clicking same line type that is already selected', () => {
|
|
372
|
-
const { getAllByText } = renderComponent({
|
|
373
|
-
gssLineData: {
|
|
374
|
-
selectedTool: 'lineA',
|
|
375
|
-
numberOfLines: 2,
|
|
376
|
-
lineA: { lineType: 'Solid' },
|
|
377
|
-
lineB: { lineType: 'Solid' },
|
|
378
|
-
},
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
const solidButtons = getAllByText(/Solid/);
|
|
382
|
-
fireEvent.click(solidButtons[0]); // Click Solid when already Solid
|
|
383
|
-
|
|
384
|
-
expect(onChange).toHaveBeenCalledTimes(1);
|
|
385
|
-
const [updatedData] = onChange.mock.calls[0];
|
|
386
|
-
expect(updatedData.lineA.lineType).toBe('Solid');
|
|
387
|
-
});
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
describe('integration tests', () => {
|
|
391
|
-
it('allows switching selected tool and changing line type in sequence', () => {
|
|
392
|
-
const { getAllByRole, getAllByText } = renderComponent({
|
|
393
|
-
gssLineData: {
|
|
394
|
-
selectedTool: 'lineA',
|
|
395
|
-
numberOfLines: 2,
|
|
396
|
-
lineA: { lineType: 'Solid' },
|
|
397
|
-
lineB: { lineType: 'Solid' },
|
|
398
|
-
},
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
// Switch to Line B
|
|
402
|
-
const radios = getAllByRole('radio');
|
|
403
|
-
const lineBRadio = radios.find((r) => r.value === 'lineB');
|
|
404
|
-
fireEvent.click(lineBRadio);
|
|
405
|
-
|
|
406
|
-
expect(onChange).toHaveBeenCalledTimes(1);
|
|
407
|
-
let [updatedData] = onChange.mock.calls[0];
|
|
408
|
-
expect(updatedData.selectedTool).toBe('lineB');
|
|
409
|
-
|
|
410
|
-
// Change Line B to Dashed
|
|
411
|
-
const dashedButtons = getAllByText(/Dashed/);
|
|
412
|
-
fireEvent.click(dashedButtons[1]);
|
|
413
|
-
|
|
414
|
-
expect(onChange).toHaveBeenCalledTimes(2);
|
|
415
|
-
[updatedData] = onChange.mock.calls[1];
|
|
416
|
-
expect(updatedData.lineB.lineType).toBe('Dashed');
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
it('handles complete workflow of switching between all tools and changing line types', () => {
|
|
420
|
-
const { getAllByRole, getAllByText } = renderComponent({
|
|
421
|
-
gssLineData: {
|
|
422
|
-
selectedTool: 'lineA',
|
|
423
|
-
numberOfLines: 2,
|
|
424
|
-
lineA: { lineType: 'Solid' },
|
|
425
|
-
lineB: { lineType: 'Solid' },
|
|
426
|
-
},
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
// Change Line A to Dashed
|
|
430
|
-
let dashedButtons = getAllByText(/Dashed/);
|
|
431
|
-
fireEvent.click(dashedButtons[0]);
|
|
432
|
-
expect(onChange.mock.calls[0][0].lineA.lineType).toBe('Dashed');
|
|
433
|
-
|
|
434
|
-
// Switch to Line B
|
|
435
|
-
const radios = getAllByRole('radio');
|
|
436
|
-
const lineBRadio = radios.find((r) => r.value === 'lineB');
|
|
437
|
-
fireEvent.click(lineBRadio);
|
|
438
|
-
expect(onChange.mock.calls[1][0].selectedTool).toBe('lineB');
|
|
439
|
-
|
|
440
|
-
// Change Line B to Dashed
|
|
441
|
-
dashedButtons = getAllByText(/Dashed/);
|
|
442
|
-
fireEvent.click(dashedButtons[1]);
|
|
443
|
-
expect(onChange.mock.calls[2][0].lineB.lineType).toBe('Dashed');
|
|
444
|
-
|
|
445
|
-
// Switch to Solution Set
|
|
446
|
-
const solutionSetRadio = radios.find((r) => r.value === 'solutionSet');
|
|
447
|
-
fireEvent.click(solutionSetRadio);
|
|
448
|
-
expect(onChange.mock.calls[3][0].selectedTool).toBe('solutionSet');
|
|
449
|
-
|
|
450
|
-
expect(onChange).toHaveBeenCalledTimes(4);
|
|
451
|
-
});
|
|
452
|
-
});
|
|
453
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { render } from '@pie-lib/test-utils';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import UndoRedo from '../undo-redo';
|
|
4
|
-
|
|
5
|
-
describe('UndoRedo', () => {
|
|
6
|
-
let onUndo = jest.fn();
|
|
7
|
-
let onRedo = jest.fn();
|
|
8
|
-
let onReset = jest.fn();
|
|
9
|
-
|
|
10
|
-
const renderComponent = (extras) => {
|
|
11
|
-
const defaults = {
|
|
12
|
-
onUndo,
|
|
13
|
-
onRedo,
|
|
14
|
-
onReset,
|
|
15
|
-
};
|
|
16
|
-
const props = { ...defaults, ...extras };
|
|
17
|
-
return render(<UndoRedo {...props} />);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
describe('rendering', () => {
|
|
21
|
-
it('renders without crashing', () => {
|
|
22
|
-
const { container } = renderComponent();
|
|
23
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { useDebounce } from '../use-debounce';
|
|
3
|
-
|
|
4
|
-
jest.useFakeTimers();
|
|
5
|
-
|
|
6
|
-
jest.mock('react', () => ({
|
|
7
|
-
useState: jest.fn(),
|
|
8
|
-
useEffect: jest.fn((fn, deps) => fn()),
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
describe('useDebounce', () => {
|
|
12
|
-
it('..', () => {
|
|
13
|
-
const debouncedValue = null;
|
|
14
|
-
const setDebouncedValue = jest.fn();
|
|
15
|
-
|
|
16
|
-
useState.mockReturnValue([debouncedValue, setDebouncedValue]);
|
|
17
|
-
useDebounce('foo', 1000);
|
|
18
|
-
jest.runAllTimers();
|
|
19
|
-
expect(setDebouncedValue).toHaveBeenCalledWith('foo');
|
|
20
|
-
});
|
|
21
|
-
});
|