You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2020/10/15 16:48:35 UTC
[incubator-echarts] 04/08: test: fix ut code to ts.
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a commit to branch fix-ut
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
commit 346cccdfd72f8dbb1b9bc15cf104383ad2cb203f
Author: 100pah <su...@gmail.com>
AuthorDate: Thu Oct 15 16:19:29 2020 +0800
test: fix ut code to ts.
---
test/ut/spec/api/containPixel.test.ts | 3 +-
test/ut/spec/component/helper/sliderMove.test.ts | 9 +-
test/ut/spec/component/visualMap/setOption.test.ts | 135 ++++++-----
test/ut/spec/data/completeDimensions.test.ts | 2 +-
test/ut/spec/model/Component.test.ts | 265 +++++++++++++--------
5 files changed, 245 insertions(+), 169 deletions(-)
diff --git a/test/ut/spec/api/containPixel.test.ts b/test/ut/spec/api/containPixel.test.ts
index ec99628..0eee5f0 100755
--- a/test/ut/spec/api/containPixel.test.ts
+++ b/test/ut/spec/api/containPixel.test.ts
@@ -23,7 +23,6 @@ import { EChartsType, registerMap } from '../../../../src/echarts';
import { GeoJSON } from '../../../../src/coord/geo/geoTypes';
-
describe('api/containPixel', function () {
const testGeoJson1: GeoJSON = {
'type': 'FeatureCollection',
@@ -150,7 +149,7 @@ describe('api/containPixel', function () {
});
const width = chart.getWidth();
- const height = chart.getWidth();
+ // const height = chart.getWidth();
expect(chart.containPixel('geo', [15, 30])).toEqual(true);
expect(chart.containPixel('geo', [9.5, 30])).toEqual(false);
diff --git a/test/ut/spec/component/helper/sliderMove.test.ts b/test/ut/spec/component/helper/sliderMove.test.ts
index 5ad85e8..ae86fa8 100644
--- a/test/ut/spec/component/helper/sliderMove.test.ts
+++ b/test/ut/spec/component/helper/sliderMove.test.ts
@@ -17,15 +17,18 @@
* specific language governing permissions and limitations
* under the License.
*/
-const sliderMove = require('../../../../../lib/component/helper/sliderMove');
+
+import sliderMove from '../../../../../src/component/helper/sliderMove';
+
+
describe('component/helper/sliderMove', function () {
describe('sliderMove', function () {
it('normalize', function () {
// Return input handleEnds
- var inputHandleEnds = [22, 50];
- var outputHandleEnds = sliderMove(0, inputHandleEnds, [20, 50], 0);
+ const inputHandleEnds = [22, 50];
+ const outputHandleEnds = sliderMove(0, inputHandleEnds, [20, 50], 0);
expect(inputHandleEnds === outputHandleEnds).toEqual(true);
expect(outputHandleEnds).toEqual([22, 50]);
diff --git a/test/ut/spec/component/visualMap/setOption.test.ts b/test/ut/spec/component/visualMap/setOption.test.ts
index fe91478..3fe1488 100755
--- a/test/ut/spec/component/visualMap/setOption.test.ts
+++ b/test/ut/spec/component/visualMap/setOption.test.ts
@@ -17,12 +17,19 @@
* specific language governing permissions and limitations
* under the License.
*/
-const utHelper = require('../../../core/utHelper');
+
+import { createChart } from '../../../core/utHelper';
+import { EChartsType } from '../../../../../src/echarts';
+import { EChartsFullOption } from '../../../../../src/option';
+import { ContinousVisualMapOption } from '../../../../../src/component/visualMap/ContinuousModel';
+import { PiecewiseVisualMapOption } from '../../../../../src/component/visualMap/PiecewiseModel';
+import VisualMapModel from '../../../../../src/component/visualMap/VisualMapModel';
+
describe('vsiaulMap_setOption', function () {
- var chart;
+ let chart: EChartsType;
beforeEach(function () {
- chart = utHelper.createChart();
+ chart = createChart();
});
afterEach(function () {
@@ -41,12 +48,13 @@ describe('vsiaulMap_setOption', function () {
}
});
- var option = chart.getOption();
+ const option = chart.getOption();
+ const visualMapOptionGotten = option.visualMap as (ContinousVisualMapOption | PiecewiseVisualMapOption)[];
- expect(option.visualMap.length).toEqual(1);
- expect(option.visualMap[0].inRange.color).toEqual(['red', 'blue', 'yellow']);
- expect(option.visualMap[0].target.inRange.color).toEqual(['red', 'blue', 'yellow']);
- expect(option.visualMap[0].controller.inRange.color).toEqual(['red', 'blue', 'yellow']);
+ expect(visualMapOptionGotten.length).toEqual(1);
+ expect(visualMapOptionGotten[0].inRange.color).toEqual(['red', 'blue', 'yellow']);
+ expect(visualMapOptionGotten[0].target.inRange.color).toEqual(['red', 'blue', 'yellow']);
+ expect(visualMapOptionGotten[0].controller.inRange.color).toEqual(['red', 'blue', 'yellow']);
done();
});
@@ -60,12 +68,13 @@ describe('vsiaulMap_setOption', function () {
}
});
- var option = chart.getOption();
+ const option = chart.getOption();
+ const visualMapOptionGotten = option.visualMap as (ContinousVisualMapOption | PiecewiseVisualMapOption)[];
- expect(option.visualMap.length).toEqual(1);
- expect(option.visualMap[0].color).toEqual(['yellow', 'blue', 'red']);
- expect(option.visualMap[0].target.inRange.color).toEqual(['red', 'blue', 'yellow']);
- expect(option.visualMap[0].controller.inRange.color).toEqual(['red', 'blue', 'yellow']);
+ expect(visualMapOptionGotten.length).toEqual(1);
+ expect(visualMapOptionGotten[0].color).toEqual(['yellow', 'blue', 'red']);
+ expect(visualMapOptionGotten[0].target.inRange.color).toEqual(['red', 'blue', 'yellow']);
+ expect(visualMapOptionGotten[0].controller.inRange.color).toEqual(['red', 'blue', 'yellow']);
done();
});
@@ -93,11 +102,12 @@ describe('vsiaulMap_setOption', function () {
expectTheSame(chart.getOption());
- function expectTheSame(option) {
- expect(option.visualMap.length).toEqual(1);
- expect(option.visualMap[0].inRange.color).toEqual(['red', 'blue', 'yellow']);
- expect(option.visualMap[0].target.inRange.color).toEqual(['red', 'blue', 'yellow']);
- expect(option.visualMap[0].controller.inRange.color).toEqual(['red', 'blue', 'yellow']);
+ function expectTheSame(option: EChartsFullOption) {
+ const visualMapOptionGotten = option.visualMap as (ContinousVisualMapOption | PiecewiseVisualMapOption)[];
+ expect(visualMapOptionGotten.length).toEqual(1);
+ expect(visualMapOptionGotten[0].inRange.color).toEqual(['red', 'blue', 'yellow']);
+ expect(visualMapOptionGotten[0].target.inRange.color).toEqual(['red', 'blue', 'yellow']);
+ expect(visualMapOptionGotten[0].controller.inRange.color).toEqual(['red', 'blue', 'yellow']);
done();
}
});
@@ -115,7 +125,7 @@ describe('vsiaulMap_setOption', function () {
}
});
- var option = chart.getOption();
+ // const option = chart.getOption();
chart.setOption({
visualMap: {
@@ -125,14 +135,15 @@ describe('vsiaulMap_setOption', function () {
}
});
- var option = chart.getOption();
+ const option = chart.getOption();
+ const visualMapOptionGotten = option.visualMap as (ContinousVisualMapOption | PiecewiseVisualMapOption)[];
- expect(option.visualMap.length).toEqual(1);
- expect(option.visualMap[0].inRange.hasOwnProperty('color')).toEqual(false);
- expect(option.visualMap[0].target.inRange.hasOwnProperty('color')).toEqual(false);
- expect(option.visualMap[0].controller.inRange.hasOwnProperty('color')).toEqual(false);
- expect(option.visualMap[0].inRange.symbolSize).toEqual([0.4, 0.6]);
- expect(option.visualMap[0].target.inRange.symbolSize).toEqual([0.4, 0.6]);
+ expect(visualMapOptionGotten.length).toEqual(1);
+ expect(visualMapOptionGotten[0].inRange.hasOwnProperty('color')).toEqual(false);
+ expect(visualMapOptionGotten[0].target.inRange.hasOwnProperty('color')).toEqual(false);
+ expect(visualMapOptionGotten[0].controller.inRange.hasOwnProperty('color')).toEqual(false);
+ expect(visualMapOptionGotten[0].inRange.symbolSize).toEqual([0.4, 0.6]);
+ expect(visualMapOptionGotten[0].target.inRange.symbolSize).toEqual([0.4, 0.6]);
done();
// Do not compare controller.inRange.symbolSize, which will be amplified to controller size.
// expect(option.visualMap[0].controller.inRange.symbolSize).toEqual([?, ?]);
@@ -159,15 +170,15 @@ describe('vsiaulMap_setOption', function () {
}
});
- var option = chart.getOption();
-
- expect(option.visualMap.length).toEqual(1);
- expect(option.visualMap[0].inRange.hasOwnProperty('color')).toEqual(false);
- expect(option.visualMap[0].target.inRange.hasOwnProperty('color')).toEqual(false);
- expect(option.visualMap[0].controller.inRange.hasOwnProperty('color')).toEqual(false);
- expect(option.visualMap[0].inRange.colorAlpha).toEqual([0.4, 0.6]);
- expect(option.visualMap[0].target.inRange.colorAlpha).toEqual([0.4, 0.6]);
- expect(option.visualMap[0].controller.inRange.colorAlpha).toEqual([0.4, 0.6]);
+ let visualMapOptionGotten: (ContinousVisualMapOption | PiecewiseVisualMapOption)[];
+ visualMapOptionGotten = chart.getOption().visualMap as typeof visualMapOptionGotten;
+ expect(visualMapOptionGotten.length).toEqual(1);
+ expect(visualMapOptionGotten[0].inRange.hasOwnProperty('color')).toEqual(false);
+ expect(visualMapOptionGotten[0].target.inRange.hasOwnProperty('color')).toEqual(false);
+ expect(visualMapOptionGotten[0].controller.inRange.hasOwnProperty('color')).toEqual(false);
+ expect(visualMapOptionGotten[0].inRange.colorAlpha).toEqual([0.4, 0.6]);
+ expect(visualMapOptionGotten[0].target.inRange.colorAlpha).toEqual([0.4, 0.6]);
+ expect(visualMapOptionGotten[0].controller.inRange.colorAlpha).toEqual([0.4, 0.6]);
chart.setOption({
visualMap: {
@@ -175,13 +186,12 @@ describe('vsiaulMap_setOption', function () {
}
});
- var option = chart.getOption();
-
- expect(option.visualMap.length).toEqual(1);
- expect(option.visualMap[0].target.inRange.hasOwnProperty('colorAlpha')).toEqual(false);
- expect(option.visualMap[0].controller.inRange.hasOwnProperty('colorAlpha')).toEqual(false);
- expect(option.visualMap[0].target.inRange.color).toEqual(['green', 'blue', 'red']);
- expect(option.visualMap[0].controller.inRange.color).toEqual(['green', 'blue', 'red']);
+ visualMapOptionGotten = chart.getOption().visualMap as typeof visualMapOptionGotten;
+ expect(visualMapOptionGotten.length).toEqual(1);
+ expect(visualMapOptionGotten[0].target.inRange.hasOwnProperty('colorAlpha')).toEqual(false);
+ expect(visualMapOptionGotten[0].controller.inRange.hasOwnProperty('colorAlpha')).toEqual(false);
+ expect(visualMapOptionGotten[0].target.inRange.color).toEqual(['green', 'blue', 'red']);
+ expect(visualMapOptionGotten[0].controller.inRange.color).toEqual(['green', 'blue', 'red']);
chart.setOption({
visualMap: {
@@ -193,20 +203,20 @@ describe('vsiaulMap_setOption', function () {
}
});
- var option = chart.getOption();
+ visualMapOptionGotten = chart.getOption().visualMap as typeof visualMapOptionGotten;
- expect(option.visualMap.length).toEqual(1);
- expect(!!option.visualMap[0].target.inRange).toEqual(true);
- var onlyColor = true;
- for (var i in option.visualMap[0].target.inRange) {
+ expect(visualMapOptionGotten.length).toEqual(1);
+ expect(!!visualMapOptionGotten[0].target.inRange).toEqual(true);
+ let onlyColor = true;
+ for (const i in visualMapOptionGotten[0].target.inRange) {
if (i !== 'color') {
onlyColor = false;
}
}
- var inRangeColor = option.visualMap[0].target.inRange.color;
+ const inRangeColor = visualMapOptionGotten[0].target.inRange.color;
expect(onlyColor).toEqual(true);
expect(inRangeColor).toEqual(['#f6efa6', '#d88273', '#bf444c']);
- expect(option.visualMap[0].controller.outOfRange.symbol).toEqual(['diamond']);
+ expect(visualMapOptionGotten[0].controller.outOfRange.symbol).toEqual(['diamond']);
done();
});
@@ -222,9 +232,10 @@ describe('vsiaulMap_setOption', function () {
}
});
- var option = chart.getOption();
-
- expect(!!option.visualMap[0].target.outOfRange.opacity).toEqual(true);
+ const visualMapOptionGotten = chart.getOption().visualMap as (
+ ContinousVisualMapOption | PiecewiseVisualMapOption
+ )[];
+ expect(!!visualMapOptionGotten[0].target.outOfRange.opacity).toEqual(true);
done();
});
@@ -245,21 +256,21 @@ describe('vsiaulMap_setOption', function () {
]
});
- var ecModel = chart.getModel();
+ const ecModel = chart.getModel();
- function getVisual(idx, visualType) {
- return ecModel.getComponent('visualMap', idx)
+ function getVisual(idx: number, visualType: 'color' | 'opacity' | 'symbol') {
+ return (ecModel.getComponent('visualMap', idx) as VisualMapModel)
.targetVisuals.inRange[visualType].option.visual;
}
- function makeCategoryVisual(val) {
- var CATEGORY_DEFAULT_VISUAL_INDEX = -1;
- var arr = [];
- if (val != null) {
- arr[CATEGORY_DEFAULT_VISUAL_INDEX] = val;
+ function makeCategoryVisual(...args: unknown[]) {
+ const CATEGORY_DEFAULT_VISUAL_INDEX = -1;
+ const arr = [];
+ if (args[0] != null) {
+ arr[CATEGORY_DEFAULT_VISUAL_INDEX] = args[0];
}
- for (var i = 1; i < arguments.length; i++) {
- arr.push(arguments[i]);
+ for (let i = 1; i < args.length; i++) {
+ arr.push(args[i]);
}
return arr;
}
diff --git a/test/ut/spec/data/completeDimensions.test.ts b/test/ut/spec/data/completeDimensions.test.ts
index 9395d0c..24efc4b 100644
--- a/test/ut/spec/data/completeDimensions.test.ts
+++ b/test/ut/spec/data/completeDimensions.test.ts
@@ -79,7 +79,7 @@ describe('completeDimensions', function () {
},
SOURCE_FORMAT_ARRAY_ROWS,
null
- )
+ );
const opt = {
'dimsDef': [
diff --git a/test/ut/spec/model/Component.test.ts b/test/ut/spec/model/Component.test.ts
index f06c6e1..c6799c7 100755
--- a/test/ut/spec/model/Component.test.ts
+++ b/test/ut/spec/model/Component.test.ts
@@ -17,155 +17,218 @@
* specific language governing permissions and limitations
* under the License.
*/
-const ComponentModel = require('../../../../lib/model/Component');
+
+import ComponentModel, { ComponentModelConstructor } from '../../../../src/model/Component';
+import { ComponentMainType } from '../../../../src/util/types';
+
+const componentModelConstructor = ComponentModel as ComponentModelConstructor;
+
describe('Component', function () {
let idx = 0;
- function makeTypes(count) {
- let arr = [];
+ function makeTypes(count: number): string[] {
+ const arr = [];
for (let i = 0; i < count; i++) {
arr.push('type_' + idx++);
}
return arr;
}
+ type TopoResultItem = [ComponentMainType, ComponentMainType[]];
+
describe('topologicalTravel', function () {
it('topologicalTravel_base', function () {
- var [m1, a1, a2] = makeTypes(3);
- ComponentModel.extend({type: m1, dependencies: [a1, a2]});
- ComponentModel.extend({type: a1});
- ComponentModel.extend({type: a2});
- var result = [];
- var allList = ComponentModel.getAllClassMainTypes();
- ComponentModel.topologicalTravel([m1, a1, a2], allList, function (componentType, dependencies) {
- result.push([componentType, dependencies]);
- });
+ const [m1, a1, a2] = makeTypes(3);
+ componentModelConstructor.extend({type: m1, dependencies: [a1, a2]});
+ componentModelConstructor.extend({type: a1});
+ componentModelConstructor.extend({type: a2});
+ const result: TopoResultItem[] = [];
+ const allList = componentModelConstructor.getAllClassMainTypes();
+ componentModelConstructor.topologicalTravel(
+ [m1, a1, a2],
+ allList,
+ function (componentType, dependencies) {
+ result.push([componentType, dependencies]);
+ }
+ );
expect(result).toEqual([[a2, ['dataset']], [a1, ['dataset']], [m1, ['dataset', a1, a2]]]);
});
it('topologicalTravel_a1IsAbsent', function () {
- var [m1, a1, a2] = makeTypes(3);
- ComponentModel.extend({type: m1, dependencies: [a1, a2]});
- ComponentModel.extend({type: a2});
- var allList = ComponentModel.getAllClassMainTypes();
- var result = [];
- ComponentModel.topologicalTravel([m1, a2], allList, function (componentType, dependencies) {
- result.push([componentType, dependencies]);
- });
+ const [m1, a1, a2] = makeTypes(3);
+ componentModelConstructor.extend({type: m1, dependencies: [a1, a2]});
+ componentModelConstructor.extend({type: a2});
+ const allList = componentModelConstructor.getAllClassMainTypes();
+ const result: TopoResultItem[] = [];
+ componentModelConstructor.topologicalTravel(
+ [m1, a2],
+ allList,
+ function (componentType, dependencies) {
+ result.push([componentType, dependencies]);
+ }
+ );
expect(result).toEqual([[a2, ['dataset']], [m1, ['dataset', a1, a2]]]);
});
it('topologicalTravel_empty', function () {
- var [m1, a1, a2] = makeTypes(3);
- ComponentModel.extend({type: m1, dependencies: [a1, a2]});
- ComponentModel.extend({type: a1});
- ComponentModel.extend({type: a2});
- var allList = ComponentModel.getAllClassMainTypes();
- var result = [];
- ComponentModel.topologicalTravel([], allList, function (componentType, dependencies) {
- result.push([componentType, dependencies]);
- });
+ const [m1, a1, a2] = makeTypes(3);
+ componentModelConstructor.extend({type: m1, dependencies: [a1, a2]});
+ componentModelConstructor.extend({type: a1});
+ componentModelConstructor.extend({type: a2});
+ const allList = componentModelConstructor.getAllClassMainTypes();
+ const result: TopoResultItem[] = [];
+ componentModelConstructor.topologicalTravel(
+ [],
+ allList,
+ function (componentType, dependencies) {
+ result.push([componentType, dependencies]);
+ }
+ );
expect(result).toEqual([]);
});
it('topologicalTravel_isolate', function () {
- var [m1, a1, a2] = makeTypes(3);
- ComponentModel.extend({type: a2});
- ComponentModel.extend({type: a1});
- ComponentModel.extend({type: m1, dependencies: [a2]});
- var allList = ComponentModel.getAllClassMainTypes();
- var result = [];
- ComponentModel.topologicalTravel([a1, a2, m1], allList, function (componentType, dependencies) {
- result.push([componentType, dependencies]);
- });
- expect(result).toEqual([[a1, ['dataset']], [a2, ['dataset']], [m1, ['dataset',a2]]]);
+ const [m1, a1, a2] = makeTypes(3);
+ componentModelConstructor.extend({type: a2});
+ componentModelConstructor.extend({type: a1});
+ componentModelConstructor.extend({type: m1, dependencies: [a2]});
+ const allList = componentModelConstructor.getAllClassMainTypes();
+ const result: TopoResultItem[] = [];
+ componentModelConstructor.topologicalTravel(
+ [a1, a2, m1],
+ allList,
+ function (componentType, dependencies) {
+ result.push([componentType, dependencies]);
+ }
+ );
+ expect(result).toEqual([[a1, ['dataset']], [a2, ['dataset']], [m1, ['dataset', a2]]]);
});
it('topologicalTravel_diamond', function () {
- var [m1, a1, a2, a3] = makeTypes(4);
- ComponentModel.extend({type: a1, dependencies: []});
- ComponentModel.extend({type: a2, dependencies: [a1]});
- ComponentModel.extend({type: a3, dependencies: [a1]});
- ComponentModel.extend({type: m1, dependencies: [a2, a3]});
- var allList = ComponentModel.getAllClassMainTypes();
- var result = [];
- ComponentModel.topologicalTravel([m1, a1, a2, a3], allList, function (componentType, dependencies) {
- result.push([componentType, dependencies]);
- });
- expect(result).toEqual([[a1, ['dataset']], [a3, ['dataset', a1]], [a2, ['dataset', a1]], [m1, ['dataset', a2, a3]]]);
+ const [m1, a1, a2, a3] = makeTypes(4);
+ componentModelConstructor.extend({type: a1, dependencies: []});
+ componentModelConstructor.extend({type: a2, dependencies: [a1]});
+ componentModelConstructor.extend({type: a3, dependencies: [a1]});
+ componentModelConstructor.extend({type: m1, dependencies: [a2, a3]});
+ const allList = componentModelConstructor.getAllClassMainTypes();
+ const result: TopoResultItem[] = [];
+ componentModelConstructor.topologicalTravel(
+ [m1, a1, a2, a3],
+ allList,
+ function (componentType, dependencies) {
+ result.push([componentType, dependencies]);
+ }
+ );
+ expect(result).toEqual(
+ [[a1, ['dataset']],
+ [a3, ['dataset', a1]],
+ [a2, ['dataset', a1]],
+ [m1, ['dataset', a2, a3]]
+ ]);
});
it('topologicalTravel_loop', function () {
- var [m1, m2, a1, a2, a3] = makeTypes(5);
- ComponentModel.extend({type: m1, dependencies: [a1, a2]});
- ComponentModel.extend({type: m2, dependencies: [m1, a2]});
- ComponentModel.extend({type: a1, dependencies: [m2, a2, a3]});
- ComponentModel.extend({type: a2});
- ComponentModel.extend({type: a3});
- var allList = ComponentModel.getAllClassMainTypes();
+ const [m1, m2, a1, a2, a3] = makeTypes(5);
+ componentModelConstructor.extend({type: m1, dependencies: [a1, a2]});
+ componentModelConstructor.extend({type: m2, dependencies: [m1, a2]});
+ componentModelConstructor.extend({type: a1, dependencies: [m2, a2, a3]});
+ componentModelConstructor.extend({type: a2});
+ componentModelConstructor.extend({type: a3});
+ const allList = componentModelConstructor.getAllClassMainTypes();
expect(function () {
- ComponentModel.topologicalTravel([m1, m2, a1], allList);
+ componentModelConstructor.topologicalTravel(
+ [m1, m2, a1],
+ allList,
+ () => {}
+ );
}).toThrowError(/Circl/);
});
it('topologicalTravel_multipleEchartsInstance', function () {
- var [m1, m2, a1, a2] = makeTypes(4);
- ComponentModel.extend({type: m1, dependencies: [a1, a2]});
- ComponentModel.extend({type: a1});
- ComponentModel.extend({type: a2});
- var allList = ComponentModel.getAllClassMainTypes();
- var result = [];
- ComponentModel.topologicalTravel([m1, a1, a2], allList, function (componentType, dependencies) {
- result.push([componentType, dependencies]);
- });
+ const [m1, m2, a1, a2] = makeTypes(4);
+ componentModelConstructor.extend({type: m1, dependencies: [a1, a2]});
+ componentModelConstructor.extend({type: a1});
+ componentModelConstructor.extend({type: a2});
+ let allList = componentModelConstructor.getAllClassMainTypes();
+ let result: TopoResultItem[] = [];
+ componentModelConstructor.topologicalTravel(
+ [m1, a1, a2],
+ allList,
+ function (componentType, dependencies) {
+ result.push([componentType, dependencies]);
+ }
+ );
expect(result).toEqual([[a2, ['dataset']], [a1, ['dataset']], [m1, ['dataset', a1, a2]]]);
result = [];
- ComponentModel.extend({type: m2, dependencies: [a1, m1]});
- var allList = ComponentModel.getAllClassMainTypes();
- ComponentModel.topologicalTravel([m2, m1, a1, a2], allList, function (componentType, dependencies) {
- result.push([componentType, dependencies]);
- });
- expect(result).toEqual([[a2, ['dataset']], [a1, ['dataset']], [m1, ['dataset', a1, a2]], [m2, ['dataset', a1, m1]]]);
+ componentModelConstructor.extend({type: m2, dependencies: [a1, m1]});
+ allList = componentModelConstructor.getAllClassMainTypes();
+ componentModelConstructor.topologicalTravel(
+ [m2, m1, a1, a2],
+ allList,
+ function (componentType, dependencies) {
+ result.push([componentType, dependencies]);
+ }
+ );
+ expect(result).toEqual(
+ [[a2, ['dataset']], [a1, ['dataset']], [m1, ['dataset', a1, a2]], [m2, ['dataset', a1, m1]]]
+ );
});
it('topologicalTravel_missingSomeNodeButHasDependencies', function () {
- var [m1, a1, a2, a3, a4] = makeTypes(5);
- ComponentModel.extend({type: m1, dependencies: [a1, a2]});
- ComponentModel.extend({type: a2, dependencies: [a3]});
- ComponentModel.extend({type: a3});
- ComponentModel.extend({type: a4});
- var result = [];
- var allList = ComponentModel.getAllClassMainTypes();
- ComponentModel.topologicalTravel([a3, m1], allList, function (componentType, dependencies) {
- result.push([componentType, dependencies]);
- });
+ const [m1, a1, a2, a3, a4] = makeTypes(5);
+ componentModelConstructor.extend({type: m1, dependencies: [a1, a2]});
+ componentModelConstructor.extend({type: a2, dependencies: [a3]});
+ componentModelConstructor.extend({type: a3});
+ componentModelConstructor.extend({type: a4});
+ let result: TopoResultItem[] = [];
+ let allList = componentModelConstructor.getAllClassMainTypes();
+ componentModelConstructor.topologicalTravel(
+ [a3, m1],
+ allList,
+ function (componentType, dependencies) {
+ result.push([componentType, dependencies]);
+ }
+ );
expect(result).toEqual([[a3, ['dataset']], [a2, ['dataset', a3]], [m1, ['dataset', a1, a2]]]);
- var result = [];
- var allList = ComponentModel.getAllClassMainTypes();
- ComponentModel.topologicalTravel([m1, a3], allList, function (componentType, dependencies) {
- result.push([componentType, dependencies]);
- });
+ result = [];
+ allList = componentModelConstructor.getAllClassMainTypes();
+ componentModelConstructor.topologicalTravel(
+ [m1, a3],
+ allList,
+ function (componentType, dependencies) {
+ result.push([componentType, dependencies]);
+ }
+ );
expect(result).toEqual([[a3, ['dataset']], [a2, ['dataset', a3]], [m1, ['dataset', a1, a2]]]);
});
it('topologicalTravel_subType', function () {
- var [m1, a1, a2, a3, a4] = makeTypes(5);
- ComponentModel.extend({type: m1, dependencies: [a1, a2]});
- ComponentModel.extend({type: a1 + '.aaa', dependencies: [a2]});
- ComponentModel.extend({type: a1 + '.bbb', dependencies: [a3, a4]});
- ComponentModel.extend({type: a2});
- ComponentModel.extend({type: a3});
- ComponentModel.extend({type: a4});
- var result = [];
- var allList = ComponentModel.getAllClassMainTypes();
- ComponentModel.topologicalTravel([m1, a1, a2, a4], allList, function (componentType, dependencies) {
- result.push([componentType, dependencies]);
- });
- expect(result).toEqual([[a4, ['dataset']], [a2, ['dataset']], [a1, ['dataset', a2, a3, a4]], [m1, ['dataset', a1, a2]]]);
+ const [m1, a1, a2, a3, a4] = makeTypes(5);
+ componentModelConstructor.extend({type: m1, dependencies: [a1, a2]});
+ componentModelConstructor.extend({type: a1 + '.aaa', dependencies: [a2]});
+ componentModelConstructor.extend({type: a1 + '.bbb', dependencies: [a3, a4]});
+ componentModelConstructor.extend({type: a2});
+ componentModelConstructor.extend({type: a3});
+ componentModelConstructor.extend({type: a4});
+ const result: TopoResultItem[] = [];
+ const allList = componentModelConstructor.getAllClassMainTypes();
+ componentModelConstructor.topologicalTravel(
+ [m1, a1, a2, a4],
+ allList,
+ function (componentType, dependencies) {
+ result.push([componentType, dependencies]);
+ }
+ );
+ expect(result).toEqual(
+ [[a4, ['dataset']],
+ [a2, ['dataset']],
+ [a1, ['dataset', a2, a3, a4]],
+ [m1, ['dataset', a1, a2]]
+ ]);
});
});
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org