You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/03/31 08:02:24 UTC
[echarts] branch enhance-missing-components-log updated (68f2a55 ->
4719d54)
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a change to branch enhance-missing-components-log
in repository https://gitbox.apache.org/repos/asf/echarts.git.
from 68f2a55 test: fix ut
new af9f776 fix(timeline): remove deprecated usage
new ac49c2b fix(option): optimize component missing error
new b8c6add test: add missing component ut. fix some warnings
new 4719d54 chore: enable unit test checking in pull request
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.github/workflows/nodejs.yml | 2 +-
src/component/timeline/SliderTimelineView.ts | 11 +--
src/model/Global.ts | 30 ++++---
test/ut/core/extendExpect.ts | 4 +-
test/ut/core/utHelper.ts | 14 +++-
test/ut/index.d.ts | 13 +++
test/ut/spec/model/componentMissing.test.ts | 118 +++++++++++++++++++++++++++
test/ut/spec/scale/interval.test.ts | 10 +--
8 files changed, 174 insertions(+), 28 deletions(-)
create mode 100644 test/ut/index.d.ts
create mode 100644 test/ut/spec/model/componentMissing.test.ts
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[echarts] 01/04: fix(timeline): remove deprecated usage
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch enhance-missing-components-log
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit af9f7761c8465860e495068a3d060b438f3cb142
Author: pissang <bm...@gmail.com>
AuthorDate: Wed Mar 31 15:13:27 2021 +0800
fix(timeline): remove deprecated usage
---
src/component/timeline/SliderTimelineView.ts | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/component/timeline/SliderTimelineView.ts b/src/component/timeline/SliderTimelineView.ts
index ee46521..163e335 100644
--- a/src/component/timeline/SliderTimelineView.ts
+++ b/src/component/timeline/SliderTimelineView.ts
@@ -550,15 +550,16 @@ class SliderTimelineView extends TimelineView {
controlSize
);
const rect = [0, -iconSize / 2, iconSize, iconSize];
- const opt = {
- position: position,
- origin: [controlSize / 2, 0],
+ const btn = makeControlIcon(timelineModel, iconName + 'Icon' as ControlIconName, rect, {
+ x: position[0],
+ y: position[1],
+ originX: controlSize / 2,
+ originY: 0,
rotation: willRotate ? -rotation : 0,
rectHover: true,
style: itemStyle,
onclick: onclick
- };
- const btn = makeControlIcon(timelineModel, iconName + 'Icon' as ControlIconName, rect, opt);
+ });
btn.ensureState('emphasis').style = hoverStyle;
group.add(btn);
enableHoverEmphasis(btn);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[echarts] 03/04: test: add missing component ut. fix some warnings
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch enhance-missing-components-log
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit b8c6add10f3ceefe08c4ae6e3cfaa830372106e9
Author: pissang <bm...@gmail.com>
AuthorDate: Wed Mar 31 15:41:52 2021 +0800
test: add missing component ut. fix some warnings
---
test/ut/core/extendExpect.ts | 4 +-
test/ut/core/utHelper.ts | 14 +++-
test/ut/index.d.ts | 13 +++
test/ut/spec/model/componentMissing.test.ts | 118 ++++++++++++++++++++++++++++
test/ut/spec/scale/interval.test.ts | 10 +--
5 files changed, 149 insertions(+), 10 deletions(-)
diff --git a/test/ut/core/extendExpect.ts b/test/ut/core/extendExpect.ts
index c71b53e..5f89c18 100644
--- a/test/ut/core/extendExpect.ts
+++ b/test/ut/core/extendExpect.ts
@@ -18,7 +18,9 @@
* under the License.
*/
-import { isValueFinite } from './utHelper';
+function isValueFinite(val: unknown): boolean {
+ return val != null && val !== '' && isFinite(val as number);
+}
// Setup expectes
diff --git a/test/ut/core/utHelper.ts b/test/ut/core/utHelper.ts
index ae23689..d933feb 100755
--- a/test/ut/core/utHelper.ts
+++ b/test/ut/core/utHelper.ts
@@ -46,6 +46,16 @@ export function createChart(params?: {
'bottom:0',
'right:0'
].join(';');
+ Object.defineProperty(el, 'clientWidth', {
+ get() {
+ return params.width || 500;
+ }
+ });
+ Object.defineProperty(el, 'clientHeight', {
+ get() {
+ return params.height || 400;
+ }
+ });
const chart = init(el, params.theme, params.opts);
return chart;
};
@@ -80,10 +90,6 @@ export const curry = zrUtilCurry;
export const bind = zrUtilBind;
-export function isValueFinite(val: unknown): boolean {
- return val != null && val !== '' && isFinite(val as number);
-}
-
// /**
// * @public
// * @param {Array.<string>} deps
diff --git a/test/ut/index.d.ts b/test/ut/index.d.ts
new file mode 100644
index 0000000..0d3604a
--- /dev/null
+++ b/test/ut/index.d.ts
@@ -0,0 +1,13 @@
+export {};
+declare global {
+ namespace jest {
+ interface Matchers<R> {
+ toBeFinite(): R
+ // Greater than or equal
+ toBeGeaterThanOrEqualTo(bound: number): R
+ // Greater than
+ toBeGreaterThan(bound: number): R
+ toBeEmptyArray(): R
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/ut/spec/model/componentMissing.test.ts b/test/ut/spec/model/componentMissing.test.ts
new file mode 100644
index 0000000..70a6aa4
--- /dev/null
+++ b/test/ut/spec/model/componentMissing.test.ts
@@ -0,0 +1,118 @@
+import { init, use, EChartsType } from '../../../../src/export/core';
+import {
+ PieChart
+} from '../../../../src/export/charts';
+import {
+ TitleComponent
+} from '../../../../src/export/components';
+import {
+ CanvasRenderer
+} from '../../../../src/export/renderers';
+use([PieChart, TitleComponent, CanvasRenderer]);
+import { EChartsOption } from '../../../../src/export/option';
+
+
+function createChart(): EChartsType {
+ const el = document.createElement('div');
+ Object.defineProperty(el, 'clientWidth', {
+ get() {
+ return 500;
+ }
+ });
+ Object.defineProperty(el, 'clientHeight', {
+ get() {
+ return 400;
+ }
+ });
+ const chart = init(el);
+ return chart;
+};
+
+function makeComponentError(componentName: string, componentImportName: string) {
+ return `[ECharts] Component ${componentName} is used but not imported.
+import { ${componentImportName} } from 'echarts/components';
+echarts.use([${componentImportName}]);`;
+}
+
+function makeSerieError(seriesName: string, seriesImportName: string) {
+ return `[ECharts] Series ${seriesName} is used but not imported.
+import { ${seriesImportName} } from 'echarts/charts';
+echarts.use([${seriesImportName}]);`;
+}
+
+
+
+describe('model_componentMissing', function () {
+ it('Should report grid component missing error', function () {
+ const chart = createChart();
+ const oldConsoleErr = console.error;
+ console.error = jest.fn();
+ chart.setOption<EChartsOption>({
+ xAxis: {},
+ yAxis: {},
+ series: []
+ });
+ expect(console.error).toHaveBeenCalledWith(
+ makeComponentError('xAxis', 'GridComponent')
+ );
+
+ console.error = oldConsoleErr;
+ });
+
+ it('Should report dataZoom component missing error', function () {
+ const chart = createChart();
+ const oldConsoleErr = console.error;
+ console.error = jest.fn();
+ chart.setOption<EChartsOption>({
+ dataZoom: {}
+ });
+ expect(console.error).toHaveBeenCalledWith(
+ makeComponentError('dataZoom', 'DataZoomComponent')
+ );
+
+ console.error = oldConsoleErr;
+ });
+
+ it('Should not report title component missing error', function () {
+ const chart = createChart();
+ const oldConsoleErr = console.error;
+ console.error = jest.fn();
+ chart.setOption<EChartsOption>({
+ title: {},
+ series: []
+ });
+ expect(console.error).not.toBeCalled();
+
+ console.error = oldConsoleErr;
+ });
+
+ it('Should report funnel series missing error', function () {
+ const chart = createChart();
+ const oldConsoleErr = console.error;
+ console.error = jest.fn();
+ chart.setOption<EChartsOption>({
+ series: [{
+ type: 'funnel'
+ }]
+ });
+ expect(console.error).toHaveBeenCalledWith(
+ makeSerieError('funnel', 'FunnelChart')
+ );
+
+ console.error = oldConsoleErr;
+ });
+
+ it('Should not report pie series missing error', function () {
+ const chart = createChart();
+ const oldConsoleErr = console.error;
+ console.error = jest.fn();
+ chart.setOption<EChartsOption>({
+ series: [{
+ type: 'pie'
+ }]
+ });
+ expect(console.error).not.toBeCalled();
+
+ console.error = oldConsoleErr;
+ });
+});
\ No newline at end of file
diff --git a/test/ut/spec/scale/interval.test.ts b/test/ut/spec/scale/interval.test.ts
index 81aed8f..aec5999 100755
--- a/test/ut/spec/scale/interval.test.ts
+++ b/test/ut/spec/scale/interval.test.ts
@@ -18,7 +18,7 @@
* under the License.
*/
-import { createChart, isValueFinite, getECModel } from '../../core/utHelper';
+import { createChart, getECModel } from '../../core/utHelper';
import { EChartsType } from '../../../../src/echarts';
import CartesianAxisModel from '../../../../src/coord/cartesian/AxisModel';
import IntervalScale from '../../../../src/scale/Interval';
@@ -124,10 +124,10 @@ describe('scale_interval', function () {
const resultInterval = result.interval;
const niceTickExtent = result.niceTickExtent;
- expect(isValueFinite(resultInterval)).toEqual(true);
- expect(isValueFinite(intervalPrecision)).toEqual(true);
- expect(isValueFinite(niceTickExtent[0])).toEqual(true);
- expect(isValueFinite(niceTickExtent[1])).toEqual(true);
+ expect(resultInterval).toBeFinite();
+ expect(intervalPrecision).toBeFinite();
+ expect(niceTickExtent[0]).toBeFinite();
+ expect(niceTickExtent[1]).toBeFinite();
expect(niceTickExtent[0]).toBeGreaterThanOrEqual(extent[0]);
expect(niceTickExtent[1]).not.toBeGreaterThan(extent[1]);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[echarts] 04/04: chore: enable unit test checking in pull request
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch enhance-missing-components-log
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 4719d54cc7cb2faf14e9e2facd355383408392a7
Author: pissang <bm...@gmail.com>
AuthorDate: Wed Mar 31 16:01:23 2021 +0800
chore: enable unit test checking in pull request
---
.github/workflows/nodejs.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml
index ab188d5..56bc96a 100644
--- a/.github/workflows/nodejs.yml
+++ b/.github/workflows/nodejs.yml
@@ -40,7 +40,7 @@ jobs:
runs-on: ubuntu-latest
needs: build
- if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/release'
+ if: ${{ github.base_ref == 'refs/heads/master' || github.base_ref == 'refs/heads/release' }}
steps:
- name: unit test
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[echarts] 02/04: fix(option): optimize component missing error
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch enhance-missing-components-log
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit ac49c2b2e385cdc98a6f7144e20b6f6d7c0784e3
Author: pissang <bm...@gmail.com>
AuthorDate: Wed Mar 31 15:41:00 2021 +0800
fix(option): optimize component missing error
---
src/model/Global.ts | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/src/model/Global.ts b/src/model/Global.ts
index 3cfbc24..5a35ff3 100644
--- a/src/model/Global.ts
+++ b/src/model/Global.ts
@@ -99,9 +99,15 @@ const BUITIN_COMPONENTS_MAP = {
markArea: 'MarkAreaComponent',
legend: 'LegendComponent',
dataZoom: 'DataZoomComponent',
- visualMap: 'VisualMapComponent'
+ visualMap: 'VisualMapComponent',
// aria: 'AriaComponent',
- // dataset: 'DatasetComponent'
+ // dataset: 'DatasetComponent',
+
+ // Dependencies
+ xAxis: 'GridComponent',
+ yAxis: 'GridComponent',
+ angleAxis: 'PolarComponent',
+ radiusAxis: 'PolarComponent'
} as const;
const BUILTIN_CHARTS_MAP = {
@@ -303,12 +309,12 @@ class GlobalModel extends Model<ECUnitOption> {
if (!ComponentModel.hasClass(mainType)) {
if (__DEV__) {
- const namedComponents = BUITIN_COMPONENTS_MAP[mainType as keyof typeof BUITIN_COMPONENTS_MAP];
- if (namedComponents && !componetsMissingLogPrinted[namedComponents]) {
+ const componentImportName = BUITIN_COMPONENTS_MAP[mainType as keyof typeof BUITIN_COMPONENTS_MAP];
+ if (componentImportName && !componetsMissingLogPrinted[componentImportName]) {
error(`Component ${mainType} is used but not imported.
-import { ${namedComponents} } from 'echarts/components';
-echarts.use([${namedComponents}]);`);
- componetsMissingLogPrinted[namedComponents] = true;
+import { ${componentImportName} } from 'echarts/components';
+echarts.use([${componentImportName}]);`);
+ componetsMissingLogPrinted[componentImportName] = true;
}
}
@@ -393,19 +399,19 @@ echarts.use([${namedComponents}]);`);
const isSeriesType = mainType === 'series';
const ComponentModelClass = (ComponentModel as ComponentModelConstructor).getClass(
mainType, resultItem.keyInfo.subType,
- isSeriesType // Give a more detailed warn if series don't exists
+ !isSeriesType // Give a more detailed warn later if series don't exists
);
if (!ComponentModelClass) {
if (__DEV__) {
const subType = resultItem.keyInfo.subType;
- const namedSeries = BUILTIN_CHARTS_MAP[subType as keyof typeof BUILTIN_CHARTS_MAP];
+ const seriesImportName = BUILTIN_CHARTS_MAP[subType as keyof typeof BUILTIN_CHARTS_MAP];
if (!componetsMissingLogPrinted[subType]) {
componetsMissingLogPrinted[subType] = true;
- if (namedSeries) {
+ if (seriesImportName) {
error(`Series ${subType} is used but not imported.
-import { ${namedSeries} } from 'echarts/charts';
-echarts.use([${namedSeries}]);`);
+import { ${seriesImportName} } from 'echarts/charts';
+echarts.use([${seriesImportName}]);`);
}
else {
error(`Unkown series ${subType}`);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org