@gravity-ui/chartkit 7.41.4 → 7.42.2

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 (25) hide show
  1. package/build/components/ErrorBoundary/ErrorBoundary.d.ts +3 -2
  2. package/build/components/ErrorBoundary/ErrorBoundary.js +7 -7
  3. package/build/plugins/highcharts/renderer/components/HighchartsReact.js +1 -1
  4. package/build/types/index.d.ts +1 -1
  5. package/package.json +25 -17
  6. package/build/plugins/highcharts/renderer/helpers/config/utils/addShowInNavigatorToSeries.test.d.ts +0 -1
  7. package/build/plugins/highcharts/renderer/helpers/config/utils/addShowInNavigatorToSeries.test.js +0 -99
  8. package/build/plugins/highcharts/renderer/helpers/config/utils/buildNavigatorFallback.test.d.ts +0 -1
  9. package/build/plugins/highcharts/renderer/helpers/config/utils/buildNavigatorFallback.test.js +0 -28
  10. package/build/plugins/highcharts/renderer/helpers/config/utils/calculatePrecision.test.d.ts +0 -1
  11. package/build/plugins/highcharts/renderer/helpers/config/utils/calculatePrecision.test.js +0 -27
  12. package/build/plugins/highcharts/renderer/helpers/config/utils/getFormatOptionsFromLine.test.d.ts +0 -1
  13. package/build/plugins/highcharts/renderer/helpers/config/utils/getFormatOptionsFromLine.test.js +0 -11
  14. package/build/plugins/highcharts/renderer/helpers/config/utils/getXAxisThresholdValue.test.d.ts +0 -1
  15. package/build/plugins/highcharts/renderer/helpers/config/utils/getXAxisThresholdValue.test.js +0 -20
  16. package/build/plugins/highcharts/renderer/helpers/config/utils/numberFormat.test.d.ts +0 -1
  17. package/build/plugins/highcharts/renderer/helpers/config/utils/numberFormat.test.js +0 -20
  18. package/build/plugins/highcharts/renderer/helpers/config/utils/setNavigatorDefaultPeriod.test.d.ts +0 -1
  19. package/build/plugins/highcharts/renderer/helpers/config/utils/setNavigatorDefaultPeriod.test.js +0 -45
  20. package/build/plugins/highcharts/renderer/helpers/config/utils/tooltip.test.d.ts +0 -1
  21. package/build/plugins/highcharts/renderer/helpers/config/utils/tooltip.test.js +0 -45
  22. package/build/plugins/highcharts/renderer/helpers/highcharts/utils/calculateClosestPointManually.test.d.ts +0 -1
  23. package/build/plugins/highcharts/renderer/helpers/highcharts/utils/calculateClosestPointManually.test.js +0 -42
  24. package/build/plugins/shared/format-number/format-number.test.d.ts +0 -1
  25. package/build/plugins/shared/format-number/format-number.test.js +0 -14
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import type { ChartKitError } from '../../libs';
3
3
  import type { ChartKitOnError, ChartKitType, ChartKitWidget, RenderError } from '../../types';
4
4
  type Props = {
5
+ children: React.ReactNode;
5
6
  onError?: ChartKitOnError;
6
7
  data: ChartKitWidget[ChartKitType]['data'];
7
8
  renderError?: RenderError;
@@ -14,9 +15,9 @@ export declare class ErrorBoundary extends React.Component<Props, State> {
14
15
  error: Error;
15
16
  };
16
17
  state: State;
17
- componentDidCatch(): void;
18
18
  componentDidUpdate(prevProps: Readonly<Props>): void;
19
- render(): React.ReactNode;
19
+ componentDidCatch(): void;
20
+ render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
20
21
  resetError: () => void;
21
22
  }
22
23
  export {};
@@ -16,13 +16,6 @@ export class ErrorBoundary extends React.Component {
16
16
  static getDerivedStateFromError(error) {
17
17
  return { error };
18
18
  }
19
- componentDidCatch() {
20
- var _a, _b;
21
- const { error } = this.state;
22
- if (error) {
23
- (_b = (_a = this.props).onError) === null || _b === void 0 ? void 0 : _b.call(_a, { error });
24
- }
25
- }
26
19
  componentDidUpdate(prevProps) {
27
20
  if (prevProps.data !== this.props.data) {
28
21
  const { error } = this.state;
@@ -33,6 +26,13 @@ export class ErrorBoundary extends React.Component {
33
26
  }
34
27
  }
35
28
  }
29
+ componentDidCatch() {
30
+ var _a, _b;
31
+ const { error } = this.state;
32
+ if (error) {
33
+ (_b = (_a = this.props).onError) === null || _b === void 0 ? void 0 : _b.call(_a, { error });
34
+ }
35
+ }
36
36
  render() {
37
37
  const { error } = this.state;
38
38
  if (error) {
@@ -22,7 +22,7 @@ export const HighchartsReact = React.memo(React.forwardRef(function HighchartsRe
22
22
  'required module is not imported.');
23
23
  }
24
24
  else if (props.options) {
25
- // @ts-expect-error
25
+ // @ts-ignore
26
26
  chartRef.current = HighchartsComponent[constructorType](containerRef.current, props.options, props.callback);
27
27
  }
28
28
  else {
@@ -56,7 +56,7 @@ export type ChartKitProps<T extends ChartKitType> = {
56
56
  };
57
57
  export type ChartKitPlugin = {
58
58
  type: ChartKitType;
59
- renderer: React.LazyExoticComponent<any>;
59
+ renderer: React.LazyExoticComponent<React.ComponentType<any>>;
60
60
  };
61
61
  export type RenderErrorOpts = {
62
62
  message: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/chartkit",
3
- "version": "7.41.4",
3
+ "version": "7.42.2",
4
4
  "description": "React component used to render charts based on any sources you need",
5
5
  "license": "MIT",
6
6
  "repository": "git@github.com:gravity-ui/ChartKit.git",
@@ -47,7 +47,7 @@
47
47
  ],
48
48
  "dependencies": {
49
49
  "@bem-react/classname": "^1.6.0",
50
- "@gravity-ui/charts": "^1.38.6",
50
+ "@gravity-ui/charts": "^1.40.0",
51
51
  "@gravity-ui/date-utils": "^2.1.0",
52
52
  "@gravity-ui/i18n": "^1.0.0",
53
53
  "@gravity-ui/yagr": "^4.11.0",
@@ -61,18 +61,20 @@
61
61
  "@gravity-ui/stylelint-config": "^4.0.1",
62
62
  "@gravity-ui/tsconfig": "^1.0.0",
63
63
  "@gravity-ui/uikit": "^7.4.0",
64
- "@jest/types": "^29.6.3",
65
- "@playwright/experimental-ct-react17": "^1.41.1",
66
64
  "@storybook/addon-docs": "^10.2.0",
65
+ "@storybook/addon-vitest": "^10.2.7",
67
66
  "@storybook/react": "^10.2.0",
68
67
  "@storybook/react-vite": "^10.2.0",
69
68
  "@types/d3": "^7.4.0",
70
69
  "@types/d3-selection": "^3.0.10",
71
- "@types/jest": "^28.1.3",
72
70
  "@types/lodash": "^4.14.177",
73
71
  "@types/node": "^18.0.0",
74
- "@types/react": "^17.0.48",
75
- "@types/react-dom": "^17.0.17",
72
+ "@types/react": "^18.3.28",
73
+ "@types/react-dom": "^18.3.7",
74
+ "@vitejs/plugin-react": "^5.1.4",
75
+ "@vitest/browser-playwright": "^4.0.18",
76
+ "@vitest/coverage-v8": "^4.0.18",
77
+ "@vitest/ui": "^4.0.18",
76
78
  "cross-env": "^7.0.3",
77
79
  "d3": "^7.9.0",
78
80
  "esbuild": "^0.25.0",
@@ -86,29 +88,36 @@
86
88
  "gulp-typescript": "^5.0.1",
87
89
  "highcharts": "^8.2.2",
88
90
  "husky": "^4.2.5",
89
- "jest": "^29.7.0",
90
- "jest-environment-jsdom": "^29.7.0",
91
91
  "lint-staged": "^10.2.7",
92
92
  "npm-run-all": "^4.1.5",
93
+ "playwright": "^1.58.2",
93
94
  "prettier": "^3.2.5",
94
- "react": "^17.0.2",
95
- "react-dom": "^17.0.2",
95
+ "react": "^18.3.1",
96
+ "react-dom": "^18.3.1",
96
97
  "rimraf": "^5.0.5",
97
98
  "sass": "^1.56.2",
98
99
  "storybook": "^10.2.0",
99
100
  "stylelint": "^15.11.0",
100
- "ts-jest": "^29.1.2",
101
101
  "ts-node": "^10.2.1",
102
102
  "typescript": "^5.8.3",
103
- "vite": "^6.0.0"
103
+ "vite": "^6.0.0",
104
+ "vitest": "^4.0.18",
105
+ "vitest-browser-react": "^2.0.5"
104
106
  },
105
107
  "peerDependencies": {
106
108
  "@gravity-ui/uikit": "^7.0.0",
107
109
  "react": "^16.0.0 || ^17.0.0 || ^18.0.0"
108
110
  },
109
111
  "scripts": {
110
- "test": "jest",
111
- "test:watch": "jest --watchAll",
112
+ "test": "vitest run --project unit",
113
+ "test:watch": "vitest --project unit",
114
+ "test:coverage": "vitest run --project unit --coverage",
115
+ "test:storybook": "vitest run --project storybook",
116
+ "test:unit": "vitest run --project unit",
117
+ "test:visual": "vitest run --project visual",
118
+ "test:docker": "./scripts/playwright-docker.sh npm run test:visual --",
119
+ "test:docker:update": "./scripts/playwright-docker.sh npm run test:visual -- --update",
120
+ "test:docker:clear-cache": "./scripts/playwright-docker.sh clear-cache",
112
121
  "clean": "gulp clean",
113
122
  "start": "storybook dev -p 7007",
114
123
  "build": "gulp",
@@ -121,8 +130,7 @@
121
130
  "lint": "run-p lint:*",
122
131
  "typecheck": "tsc --noEmit",
123
132
  "prepublishOnly": "npm run build",
124
- "build-storybook": "storybook build -o storybook-static",
125
- "test:playwright": "playwright test -c tests/playwright.config.ts"
133
+ "build-storybook": "storybook build -o storybook-static"
126
134
  },
127
135
  "husky": {
128
136
  "hooks": {
@@ -1,99 +0,0 @@
1
- import { NavigatorLinesMode } from '../../constants';
2
- import { addShowInNavigatorToSeries } from './addShowInNavigatorToSeries';
3
- describe('plugins/highcharts/config/addShowInNavigatorToSeries', () => {
4
- let MOCKED_SERIES;
5
- let MOCKED_PARAMS;
6
- beforeEach(() => {
7
- MOCKED_SERIES = [{ name: 'Test1' }, { name: 'Test2' }, { name: 'Test3' }];
8
- MOCKED_PARAMS = { navigator: {} };
9
- });
10
- it("should set {showInNavigator: true} to all series in case of {linesMode: 'all'}", () => {
11
- const linesMode = NavigatorLinesMode.All;
12
- addShowInNavigatorToSeries({
13
- linesMode,
14
- graphs: MOCKED_SERIES,
15
- params: MOCKED_PARAMS,
16
- selectedLines: [],
17
- baseSeriesName: '',
18
- });
19
- const expectedResult = [
20
- { name: 'Test1', showInNavigator: true },
21
- { name: 'Test2', showInNavigator: true },
22
- { name: 'Test3', showInNavigator: true },
23
- ];
24
- expect(MOCKED_SERIES).toEqual(expectedResult);
25
- });
26
- it("should set {showInNavigator: false} to all series in case of {linesMode: 'selected'} and add min & max to params.navigator.xAxis", () => {
27
- const linesMode = NavigatorLinesMode.Selected;
28
- addShowInNavigatorToSeries({
29
- linesMode,
30
- graphs: MOCKED_SERIES,
31
- params: MOCKED_PARAMS,
32
- selectedLines: [],
33
- baseSeriesName: '',
34
- });
35
- const expectedSeries = [
36
- { name: 'Test1', showInNavigator: false },
37
- { name: 'Test2', showInNavigator: false },
38
- { name: 'Test3', showInNavigator: false },
39
- ];
40
- const expectedParams = {
41
- navigator: {
42
- xAxis: {
43
- max: null,
44
- min: null,
45
- },
46
- },
47
- };
48
- expect(MOCKED_SERIES).toEqual(expectedSeries);
49
- expect(MOCKED_PARAMS).toEqual(expectedParams);
50
- });
51
- it('should set {showInNavigator: true} in case of selectedLines contains series', () => {
52
- const linesMode = NavigatorLinesMode.Selected;
53
- addShowInNavigatorToSeries({
54
- linesMode,
55
- graphs: MOCKED_SERIES,
56
- params: MOCKED_PARAMS,
57
- selectedLines: ['Test3'],
58
- baseSeriesName: '',
59
- });
60
- const expectedSeries = [
61
- { name: 'Test1', showInNavigator: false },
62
- { name: 'Test2', showInNavigator: false },
63
- { name: 'Test3', showInNavigator: true },
64
- ];
65
- expect(MOCKED_SERIES).toEqual(expectedSeries);
66
- });
67
- it('should set {showInNavigator: true} in case of series equals to baseSeriesName', () => {
68
- const linesMode = NavigatorLinesMode.Selected;
69
- addShowInNavigatorToSeries({
70
- linesMode,
71
- graphs: MOCKED_SERIES,
72
- params: MOCKED_PARAMS,
73
- selectedLines: [],
74
- baseSeriesName: 'Test2',
75
- });
76
- const expectedSeries = [
77
- { name: 'Test1', showInNavigator: false },
78
- { name: 'Test2', showInNavigator: true },
79
- { name: 'Test3', showInNavigator: false },
80
- ];
81
- expect(MOCKED_SERIES).toEqual(expectedSeries);
82
- });
83
- it('should set {showInNavigator: true} in case of selectedLines and baseSeriesName', () => {
84
- const linesMode = NavigatorLinesMode.Selected;
85
- addShowInNavigatorToSeries({
86
- linesMode,
87
- graphs: MOCKED_SERIES,
88
- params: MOCKED_PARAMS,
89
- selectedLines: ['Test1'],
90
- baseSeriesName: 'Test2',
91
- });
92
- const expectedSeries = [
93
- { name: 'Test1', showInNavigator: true },
94
- { name: 'Test2', showInNavigator: true },
95
- { name: 'Test3', showInNavigator: false },
96
- ];
97
- expect(MOCKED_SERIES).toEqual(expectedSeries);
98
- });
99
- });
@@ -1,28 +0,0 @@
1
- import { buildNavigatorFallback } from './buildNavigatorFallback';
2
- const MOCKED_GRAPHS = [{ name: 'Test' }, { name: 'Test1' }, { name: 'Test2' }];
3
- const baseSeriesName = 'Test2';
4
- const missedSeriesName = 'Test3';
5
- describe('plugins/highcharts/config/buildNavigatorFallback', () => {
6
- it('should set {showInNavigator: true} to current series in case of initialized baseSeriesName', () => {
7
- const expectedResult = [
8
- { name: 'Test', showInNavigator: false },
9
- { name: 'Test1', showInNavigator: false },
10
- { name: 'Test2', showInNavigator: true },
11
- ];
12
- buildNavigatorFallback(MOCKED_GRAPHS, baseSeriesName);
13
- expect(MOCKED_GRAPHS).toEqual(expectedResult);
14
- });
15
- it('should set {showInNavigator: true} to all series in case of baseSeriesName are not initialized', () => {
16
- const expectedResult = [
17
- { name: 'Test', showInNavigator: true },
18
- { name: 'Test1', showInNavigator: true },
19
- { name: 'Test2', showInNavigator: true },
20
- ];
21
- buildNavigatorFallback(MOCKED_GRAPHS);
22
- expect(MOCKED_GRAPHS).toEqual(expectedResult);
23
- });
24
- it('should not set {showInNavigator: true} to current series in case of baseSeriesName are not finded in graphs', () => {
25
- buildNavigatorFallback(MOCKED_GRAPHS, missedSeriesName);
26
- expect(MOCKED_GRAPHS).toEqual(MOCKED_GRAPHS);
27
- });
28
- });
@@ -1,27 +0,0 @@
1
- import { calculatePrecision } from './calculatePrecision';
2
- describe('plugins/highcharts/config/calculatePrecision', () => {
3
- test('should return undefined', () => {
4
- expect(calculatePrecision(null, { normalizeDiv: false, normalizeSub: false })).toEqual(undefined);
5
- expect(calculatePrecision(null, { normalizeDiv: false, normalizeSub: false }, 1)).toEqual(undefined);
6
- });
7
- test('should return 2 in case of some of normalized options are initialized', () => {
8
- expect(calculatePrecision(null, { normalizeDiv: true, normalizeSub: false }, 99)).toEqual(2);
9
- expect(calculatePrecision(null, { normalizeDiv: false, normalizeSub: true }, 99.99)).toEqual(2);
10
- expect(calculatePrecision(null, { normalizeDiv: false, normalizeSub: true })).toEqual(2);
11
- expect(calculatePrecision(10, { normalizeDiv: true, normalizeSub: true })).toEqual(2);
12
- });
13
- test('should return precision value from func arguments', () => {
14
- expect(calculatePrecision(null, { normalizeDiv: false, normalizeSub: false, precision: 3 })).toEqual(3);
15
- expect(calculatePrecision(null, { normalizeDiv: true, normalizeSub: false, precision: 4 }, 99.99)).toEqual(4);
16
- expect(calculatePrecision(null, { normalizeDiv: false, normalizeSub: true, precision: 5 }, 99)).toEqual(5);
17
- expect(calculatePrecision(10, { normalizeDiv: false, normalizeSub: false, precision: 3 })).toEqual(3);
18
- });
19
- test('should return alternativePrecision value from func arguments', () => {
20
- expect(calculatePrecision(10, { normalizeDiv: false, normalizeSub: false })).toEqual(10);
21
- expect(calculatePrecision(10, { normalizeDiv: false, normalizeSub: false }, 99)).toEqual(10);
22
- expect(calculatePrecision(10, { normalizeDiv: false, normalizeSub: false }, 99.99)).toEqual(10);
23
- });
24
- test('should return 2 for decimal number by default', () => {
25
- expect(calculatePrecision(null, { normalizeDiv: false, normalizeSub: false }, 0.1111111)).toEqual(2);
26
- });
27
- });
@@ -1,11 +0,0 @@
1
- import { getFormatOptionsFromLine } from './getFormatOptionsFromLine';
2
- describe('plugins/highcharts/config', () => {
3
- test.each([
4
- [{ chartKitFormat: 'percent' }, { format: 'percent' }],
5
- [{}, undefined],
6
- [undefined, undefined],
7
- ])('getFormatOptionsFromLine (line: %j)', (line, expected) => {
8
- const result = getFormatOptionsFromLine(line);
9
- expect(result).toEqual(expected);
10
- });
11
- });
@@ -1,20 +0,0 @@
1
- import { getXAxisThresholdValue } from './getXAxisThresholdValue';
2
- const MOCKED_SERIES = [
3
- { data: [{ x: 1 }, { x: 2 }, { x: -11 }, { x: 0 }, { x: 1 }] },
4
- { data: [{ x: 100 }, { x: -1232 }] },
5
- { data: [] },
6
- ];
7
- describe('plugins/highcharts/config/getXAxisThresholdValue', () => {
8
- it("should return maximun value from x axis in case of 'max' operation", () => {
9
- const result = getXAxisThresholdValue(MOCKED_SERIES, 'max');
10
- expect(result).toEqual(100);
11
- });
12
- it("should return minimum value from x axis in case of 'min' operation", () => {
13
- const result = getXAxisThresholdValue(MOCKED_SERIES, 'min');
14
- expect(result).toEqual(-1232);
15
- });
16
- it.each([['min'], ['max']])('should return null in case of empty series array', (operation) => {
17
- const result = getXAxisThresholdValue([], operation);
18
- expect(result).toBeNull();
19
- });
20
- });
@@ -1,20 +0,0 @@
1
- import { i18nInstance } from '../../../../../shared/format-number/i18n/i18n';
2
- import { numberFormat } from './numberFormat';
3
- i18nInstance.setLang('en');
4
- describe('plugins/highcharts/config', () => {
5
- test.each([
6
- [100, undefined, undefined, '100'],
7
- [100, 0, undefined, '100'],
8
- [100, 2, undefined, '100.00'],
9
- [100, 21, undefined, '100.00000000000000000000'],
10
- [NaN, 0, undefined, null],
11
- [100, undefined, undefined, '100'],
12
- [100, 2, { precision: 3 }, '100.000'],
13
- [100.234, 2, { precision: 3 }, '100.234'],
14
- [100000, undefined, { unit: 'k' }, '100K'],
15
- [100000, 2, { unit: 'k' }, '100.00K'],
16
- ])('numberFormat (args: {value: %p, round: %p})', (value, round, options, expected) => {
17
- const result = numberFormat(value, round, options);
18
- expect(result).toEqual(expected);
19
- });
20
- });
@@ -1,45 +0,0 @@
1
- import { getDefaultPeriodInMS } from './setNavigatorDefaultPeriod';
2
- const date1 = new Date('2021-01-01');
3
- const date2 = new Date('2021-01-02');
4
- const date3 = new Date('2021-01-03');
5
- const MOCKED_SERIES = [
6
- {
7
- data: [{ x: date1.valueOf() }, { x: date3.valueOf() }],
8
- },
9
- {
10
- data: [{ x: date2.valueOf() }],
11
- },
12
- ];
13
- const DAY_MIN_RANGE = 60 * 60 * 1000 * 24;
14
- const HOUR_MIN_RANGE = 60 * 60 * 1000;
15
- describe('plugins/highcharts/config/getDefaultPeriodInMS', () => {
16
- let settings;
17
- beforeEach(() => {
18
- settings = {
19
- type: 'date',
20
- value: '2',
21
- period: 'day',
22
- };
23
- });
24
- it('should return range & minRange for date in ms', () => {
25
- const result = getDefaultPeriodInMS(settings, MOCKED_SERIES);
26
- const expectedResult = {
27
- minRange: DAY_MIN_RANGE,
28
- range: date3.valueOf() - date1.valueOf(),
29
- };
30
- expect(result).toEqual(expectedResult);
31
- });
32
- it(`should set {minRange: ${HOUR_MIN_RANGE}} in case of settings.type !== 'date'`, () => {
33
- settings.type = 'datetime';
34
- const result = getDefaultPeriodInMS(settings, MOCKED_SERIES);
35
- const expectedResult = {
36
- minRange: HOUR_MIN_RANGE,
37
- range: date3.valueOf() - date1.valueOf(),
38
- };
39
- expect(result).toEqual(expectedResult);
40
- });
41
- it('should return null in case of empty series', () => {
42
- const result = getDefaultPeriodInMS(settings, []);
43
- expect(result).toBeNull();
44
- });
45
- });
@@ -1,45 +0,0 @@
1
- import { HighchartsType } from '../../constants';
2
- import { checkTooltipPinningAvailability, isTooltipShared } from './tooltip';
3
- const chartTypes = [
4
- [HighchartsType.Sankey, false],
5
- [HighchartsType.Xrange, false],
6
- [HighchartsType.Line, true],
7
- [HighchartsType.Area, true],
8
- [HighchartsType.Arearange, true],
9
- [HighchartsType.Bar, true],
10
- [HighchartsType.Column, true],
11
- [HighchartsType.Columnrange, true],
12
- [HighchartsType.Funnel, true],
13
- [HighchartsType.Pie, true],
14
- [HighchartsType.Map, true],
15
- [HighchartsType.Scatter, true],
16
- [HighchartsType.Bubble, true],
17
- [HighchartsType.Heatmap, true],
18
- [HighchartsType.Treemap, true],
19
- [HighchartsType.Networkgraph, true],
20
- [HighchartsType.Variwide, true],
21
- [HighchartsType.Waterfall, true],
22
- [HighchartsType.Streamgraph, true],
23
- [HighchartsType.Wordcloud, true],
24
- [HighchartsType.Boxplot, true],
25
- [HighchartsType.Timeline, true],
26
- ];
27
- describe('plugins/highcharts/config', () => {
28
- test.each(chartTypes)(`calculatePrecision for %s return %s`, (chartType, expected) => {
29
- expect(isTooltipShared(chartType)).toBe(expected);
30
- });
31
- test.each([
32
- [undefined, true],
33
- [{ tooltip: { pin: { altKey: true } }, altKey: true }, true],
34
- [{ tooltip: { pin: { metaKey: true } }, metaKey: true }, true],
35
- [{ tooltip: { pin: { altKey: true, metaKey: true } }, altKey: true, metaKey: true }, true],
36
- [{ tooltip: { pin: { enabled: false } } }, false],
37
- [{ tooltip: { pin: { altKey: true } }, altKey: false }, false],
38
- [{ tooltip: { pin: { metaKey: true } }, metaKey: false }, false],
39
- [{ tooltip: { pin: { altKey: true, metaKey: true } }, altKey: false, metaKey: true }, false],
40
- [{ tooltip: { pin: { altKey: true, metaKey: true } }, altKey: true, metaKey: false }, false],
41
- ])(`checkTooltipPinningAvailability (args: %j)`, (args, expected) => {
42
- const result = checkTooltipPinningAvailability(args);
43
- expect(result).toBe(expected);
44
- });
45
- });
@@ -1,42 +0,0 @@
1
- import { calculateClosestPointManually } from './calcucalteClosestPointManually';
2
- describe('calculateClosestPointManually', () => {
3
- it('Должна вернуть наименьшее расстояние между точками и если оно больше 0', () => {
4
- const MOCKED_SERIES = [
5
- {
6
- processedXData: [1, 5, 12],
7
- },
8
- {
9
- processedXData: [12, 65],
10
- },
11
- {
12
- processedXData: [3, 140],
13
- },
14
- ];
15
- const MOCKED_CONTEXT = {
16
- series: MOCKED_SERIES,
17
- };
18
- const expectedResult = 2;
19
- const result = calculateClosestPointManually.apply(MOCKED_CONTEXT);
20
- expect(result).toEqual(expectedResult);
21
- });
22
- it('Должна вернуть undefined, если передан пустой массив', () => {
23
- const MOCKED_CONTEXT = { series: [] };
24
- const result = calculateClosestPointManually.apply(MOCKED_CONTEXT);
25
- expect(result).toBeUndefined();
26
- });
27
- it('Должна вернуть undefined, если наименьшее расстояние это 0', () => {
28
- const MOCKED_SERIES = [
29
- {
30
- processedXData: [12],
31
- },
32
- {
33
- processedXData: [12],
34
- },
35
- ];
36
- const MOCKED_CONTEXT = {
37
- series: MOCKED_SERIES,
38
- };
39
- const result = calculateClosestPointManually.apply(MOCKED_CONTEXT);
40
- expect(result).toBeUndefined();
41
- });
42
- });
@@ -1,14 +0,0 @@
1
- import { formatNumber } from './format-number';
2
- import { i18nInstance } from './i18n/i18n';
3
- i18nInstance.setLang('en');
4
- describe('plugins/shared', () => {
5
- test.each([
6
- ['not-a-number', undefined, 'NaN'],
7
- [NaN, undefined, 'NaN'],
8
- ['0.2211556', undefined, '0.2211556'],
9
- ['0.2211556', { precision: 4 }, '0.2212'],
10
- ])('formatNumber (args: {value: %p, options: %p})', (value, options, expected) => {
11
- const result = formatNumber(value, options);
12
- expect(result).toEqual(expected);
13
- });
14
- });