提交 68f2a55b 编写于 作者: P pissang

test: fix ut

上级 4933a8ea
......@@ -21,10 +21,10 @@ import { createChart, getGraphicElements, getECModel } from '../../../core/utHel
// import { imageURI } from './setOptionImageURI';
import { EChartsType } from '../../../../../src/echarts';
import Element from 'zrender/src/Element';
import { EChartsFullOption } from '../../../../../src/option';
import { EChartsOption } from '../../../../../src/export/option';
import {
GraphicComponentOption, GraphicComponentImageOption
} from '../../../../../src/component/graphic';
} from '../../../../../src/component/graphic/install';
import Group from 'zrender/src/graphic/Group';
import { Dictionary } from 'zrender/src/core/types';
......@@ -1049,7 +1049,7 @@ describe('graphic_setOption', function () {
describe('boundingAndRotation', function () {
function getOption(): EChartsFullOption {
function getOption(): EChartsOption {
return {
legend: {
data: ['高度(km)与气温(°C)变化关系']
......
......@@ -20,7 +20,7 @@
import { createChart, getECModel } from '../../../core/utHelper';
import { EChartsType } from '../../../../../src/echarts';
import { EChartsFullOption } from '../../../../../src/option';
import { EChartsOption } from '../../../../../src/export/option';
import { ContinousVisualMapOption } from '../../../../../src/component/visualMap/ContinuousModel';
import { PiecewiseVisualMapOption } from '../../../../../src/component/visualMap/PiecewiseModel';
import VisualMapModel from '../../../../../src/component/visualMap/VisualMapModel';
......@@ -94,15 +94,15 @@ describe('vsiaulMap_setOption', function () {
visualMap: {}
});
expectTheSame(chart.getOption());
expectTheSame(chart.getOption() as EChartsOption);
chart.setOption({
series: [{data: [[44, 55]]}] // visualMap depends series
});
expectTheSame(chart.getOption());
expectTheSame(chart.getOption() as EChartsOption);
function expectTheSame(option: EChartsFullOption) {
function expectTheSame(option: EChartsOption) {
const visualMapOptionGotten = option.visualMap as (ContinousVisualMapOption | PiecewiseVisualMapOption)[];
expect(visualMapOptionGotten.length).toEqual(1);
expect(visualMapOptionGotten[0].inRange.color).toEqual(['red', 'blue', 'yellow']);
......
......@@ -19,7 +19,7 @@
import { EChartsType } from '../../../../src/echarts';
import { createChart, removeChart, getECModel } from '../../core/utHelper';
import { EChartsFullOption } from '../../../../src/option';
import { EChartsOption } from '../../../../src/export/option';
import { retrieveRawValue } from '../../../../src/data/helper/dataProvider';
......@@ -59,7 +59,7 @@ describe('dataTransform', function () {
}
it('forbid_seriesLayoutBy_row', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
dataset: [{
source: makeDatasetSourceDetection(),
// This config should cause error thrown.
......@@ -78,7 +78,7 @@ describe('dataTransform', function () {
});
it('seriesLayoutBy_changed_no_transform', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
dataset: {
source: makeDatasetSourceDetection()
},
......@@ -104,7 +104,7 @@ describe('dataTransform', function () {
]
}].forEach((dataset1, itIdx) => {
it(`seriesLayoutBy_changed_transform_detection_${itIdx}`, function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
dataset: [{
source: makeDatasetSourceDetection()
}, dataset1],
......@@ -136,7 +136,7 @@ describe('dataTransform', function () {
}].forEach((dataset1, itIdx) => {
it(`seriesLayoutBy_changed_transform_non_detection_${itIdx}`, function () {
const sourceWrap = makeDatasetSourceNonDetectionByRow();
const option: EChartsFullOption = {
const option: EChartsOption = {
dataset: [{
dimensions: sourceWrap.dimensions,
source: sourceWrap.source
......@@ -163,7 +163,7 @@ describe('dataTransform', function () {
]
}].forEach((dataset1, itIdx) => {
it(`inherit_detected_dimensions_${itIdx}`, function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
dataset: [{
source: makeDatasetSourceDetection()
}, dataset1],
......
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
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: 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 () {
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 () {
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 () {
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 () {
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 () {
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 () {
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 () {
componentModelConstructor.topologicalTravel(
[m1, m2, a1],
allList,
() => {}
);
}).toThrowError(/Circl/);
});
it('topologicalTravel_multipleEchartsInstance', function () {
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 = [];
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 () {
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]]]);
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 () {
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]]
]);
});
});
});
\ No newline at end of file
......@@ -24,7 +24,7 @@ import { ComponentMainType, ParsedValue } from '../../../../src/util/types';
import SeriesModel from '../../../../src/model/Series';
import ComponentModel from '../../../../src/model/Component';
import ChartView from '../../../../src/view/Chart';
import { EChartsFullOption } from '../../../../src/option';
import { EChartsOption } from '../../../../src/export/option';
type OriginModelView = {
model: SeriesModel;
......@@ -119,7 +119,7 @@ describe('modelAndOptionMapping', function () {
describe('idNoNameNo', function () {
it('sameTypeNotMerge', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -239,7 +239,7 @@ describe('modelAndOptionMapping', function () {
describe('idSpecified', function () {
it('sameTypeNotMerge', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -270,7 +270,7 @@ describe('modelAndOptionMapping', function () {
});
it('sameTypeMerge', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -293,7 +293,7 @@ describe('modelAndOptionMapping', function () {
});
it('differentTypeNotMerge', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -307,7 +307,7 @@ describe('modelAndOptionMapping', function () {
chart.setOption(option);
const origins = saveOrigins(chart);
const option2: EChartsFullOption = {
const option2: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -328,7 +328,7 @@ describe('modelAndOptionMapping', function () {
});
it('differentTypeMergeFull', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -342,7 +342,7 @@ describe('modelAndOptionMapping', function () {
chart.setOption(option);
const origins = saveOrigins(chart);
const option2: EChartsFullOption = {
const option2: EChartsOption = {
series: [
{type: 'line', data: [11]},
{type: 'bar', data: [22], id: 20, name: 'a'},
......@@ -362,7 +362,7 @@ describe('modelAndOptionMapping', function () {
});
it('differentTypeMergePartial1', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -376,7 +376,7 @@ describe('modelAndOptionMapping', function () {
chart.setOption(option);
const origins = saveOrigins(chart);
const option2: EChartsFullOption = {
const option2: EChartsOption = {
series: [
{type: 'bar', data: [444], id: 40},
{type: 'line', data: [333]},
......@@ -399,7 +399,7 @@ describe('modelAndOptionMapping', function () {
});
it('differentTypeMergePartial2', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -409,7 +409,7 @@ describe('modelAndOptionMapping', function () {
};
chart.setOption(option);
const option2: EChartsFullOption = {
const option2: EChartsOption = {
series: [
{type: 'bar', data: [444], id: 40},
{type: 'line', data: [333]},
......@@ -429,7 +429,7 @@ describe('modelAndOptionMapping', function () {
it('mergePartialDoNotMapToOtherId', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -439,7 +439,7 @@ describe('modelAndOptionMapping', function () {
};
chart.setOption(option);
const option2: EChartsFullOption = {
const option2: EChartsOption = {
series: [
{type: 'bar', data: [444], id: 40}
]
......@@ -455,7 +455,7 @@ describe('modelAndOptionMapping', function () {
it('idDuplicate', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -524,7 +524,7 @@ describe('modelAndOptionMapping', function () {
describe('noIdButNameExists', function () {
it('sameTypeNotMerge', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -558,7 +558,7 @@ describe('modelAndOptionMapping', function () {
});
it('sameTypeMerge', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -581,7 +581,7 @@ describe('modelAndOptionMapping', function () {
});
it('differentTypeNotMerge', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -595,7 +595,7 @@ describe('modelAndOptionMapping', function () {
chart.setOption(option);
const origins = saveOrigins(chart);
const option2: EChartsFullOption = {
const option2: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -616,7 +616,7 @@ describe('modelAndOptionMapping', function () {
});
it('differentTypeMergePartialOneMapTwo', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -630,7 +630,7 @@ describe('modelAndOptionMapping', function () {
chart.setOption(option);
const origins = saveOrigins(chart);
const option2: EChartsFullOption = {
const option2: EChartsOption = {
series: [
{type: 'bar', data: [444], id: 40},
{type: 'line', data: [333]},
......@@ -654,7 +654,7 @@ describe('modelAndOptionMapping', function () {
});
it('differentTypeMergePartialTwoMapOne', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -664,7 +664,7 @@ describe('modelAndOptionMapping', function () {
};
chart.setOption(option);
const option2: EChartsFullOption = {
const option2: EChartsOption = {
series: [
{type: 'bar', data: [444], name: 'a'},
{type: 'line', data: [333]},
......@@ -684,7 +684,7 @@ describe('modelAndOptionMapping', function () {
it('mergePartialCanMapToOtherName', function () {
// Consider case: axis.name = 'some label', which can be overwritten.
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
series: [
......@@ -694,7 +694,7 @@ describe('modelAndOptionMapping', function () {
};
chart.setOption(option);
const option2: EChartsFullOption = {
const option2: EChartsOption = {
series: [
{type: 'bar', data: [444], name: 40},
{type: 'bar', data: [999], name: 40},
......@@ -720,7 +720,7 @@ describe('modelAndOptionMapping', function () {
describe('ohters', function () {
it('aBugCase', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
series: [
{
type: 'pie',
......@@ -790,7 +790,7 @@ describe('modelAndOptionMapping', function () {
});
it('color', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
backgroundColor: 'rgba(1,1,1,1)',
xAxis: {data: ['a']},
yAxis: {},
......@@ -812,7 +812,7 @@ describe('modelAndOptionMapping', function () {
});
it('innerId', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: {data: ['a']},
yAxis: {},
toolbox: {
......
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import ComponentModel, { ComponentModelConstructor } from '../../../../src/model/Component';
import { ComponentMainType } from '../../../../src/util/types';
const componentModelConstructor = ComponentModel as ComponentModelConstructor;
function extendModel(type: string, dependencies?: string[]) {
class SubModel extends ComponentModel {
static type: string = type;
type: string = type;
static dependencies = dependencies || [];
};
ComponentModel.registerClass(SubModel);
return SubModel;
}
describe('componentDependency', function () {
let idx = 0;
function makeTypes(count: number): string[] {
const arr = [];
for (let i = 0; i < count; i++) {
arr.push('type_' + idx++);
}
return arr;
}
type TopoResultItem = [ComponentMainType, ComponentMainType[]];
it('topologicalTravel_base', function () {
const [m1, a1, a2] = makeTypes(3);
extendModel(m1, [a1, a2]);
extendModel(a1);
extendModel(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 () {
const [m1, a1, a2] = makeTypes(3);
extendModel(m1, [a1, a2]);
extendModel(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 () {
const [m1, a1, a2] = makeTypes(3);
extendModel(m1, [a1, a2]);
extendModel(a1);
extendModel(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 () {
const [m1, a1, a2] = makeTypes(3);
extendModel(a2);
extendModel(a1);
extendModel(m1, [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 () {
const [m1, a1, a2, a3] = makeTypes(4);
extendModel(a1, []);
extendModel(a2, [a1]);
extendModel(a3, [a1]);
extendModel(m1, [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 () {
const [m1, m2, a1, a2, a3] = makeTypes(5);
extendModel(m1, [a1, a2]);
extendModel(m2, [m1, a2]);
extendModel(a1, [m2, a2, a3]);
extendModel(a2);
extendModel(a3);
const allList = componentModelConstructor.getAllClassMainTypes();
expect(function () {
componentModelConstructor.topologicalTravel(
[m1, m2, a1],
allList,
() => {}
);
}).toThrowError(/Circular/);
});
it('topologicalTravel_multipleEchartsInstance', function () {
const [m1, m2, a1, a2] = makeTypes(4);
extendModel(m1, [a1, a2]);
extendModel(a1);
extendModel(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 = [];
extendModel(m2, [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 () {
const [m1, a1, a2, a3, a4] = makeTypes(5);
extendModel(m1, [a1, a2]);
extendModel(a2, [a3]);
extendModel(a3);
extendModel(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]]]);
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 () {
const [m1, a1, a2, a3, a4] = makeTypes(5);
extendModel(m1, [a1, a2]);
extendModel(a1 + '.aaa', [a2]);
extendModel(a1 + '.bbb', [a3, a4]);
extendModel(a2);
extendModel(a3);
extendModel(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]]
]);
});
});
\ No newline at end of file
......@@ -24,7 +24,7 @@ import { ParsedValue } from '../../../../src/util/types';
import { LegendOption } from '../../../../src/component/legend/LegendModel';
import TimelineModel from '../../../../src/component/timeline/TimelineModel';
import { createChart, getECModel } from '../../core/utHelper';
import { EChartsFullOption } from '../../../../src/option';
import { EChartsOption } from '../../../../src/export/option';
describe('timelineMediaOptions', function () {
......@@ -36,7 +36,7 @@ describe('timelineMediaOptions', function () {
return getECModel(chart).getComponent('series', seriesIndex) as SeriesModel;
}
function getLegendOption(chart: EChartsType): LegendOption {
return getECModel(chart).getComponent('legend', 0).option;
return getECModel(chart).getComponent('legend', 0).option as LegendOption;
}
function getTimelineComponent(chart: EChartsType): TimelineModel {
return getECModel(chart).getComponent('timeline', 0) as TimelineModel;
......@@ -60,7 +60,7 @@ describe('timelineMediaOptions', function () {
describe('parse_timeline_media_option', function () {
it('parse_media_has_baseOption_has_default', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
baseOption: {
xAxis: { data: ['a'] },
yAxis: {},
......@@ -88,7 +88,7 @@ describe('timelineMediaOptions', function () {
});
it('parse_media_no_baseOption_has_default', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: { data: ['a'] },
yAxis: {},
legend: { left: 10 },
......@@ -112,7 +112,7 @@ describe('timelineMediaOptions', function () {
});
it('parse_media_no_baseOption_no_default', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
xAxis: { data: ['a'] },
yAxis: {},
legend: { left: 10 },
......@@ -132,7 +132,7 @@ describe('timelineMediaOptions', function () {
});
it('parse_timeline_media_has_baseOption', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
baseOption: {
timeline: { axisType: 'category' },
xAxis: { data: ['a'] },
......@@ -166,13 +166,13 @@ describe('timelineMediaOptions', function () {
expect(getData0(chart, 0)).toEqual(88);
expect(getLegendOption(chart).left).toEqual(50);
chart.setOption({ timeline: { currentIndex: 1 } });
chart.setOption<EChartsOption>({ timeline: { currentIndex: 1 } });
expect(getData0(chart, 0)).toEqual(99);
expect(getLegendOption(chart).left).toEqual(50);
});
it('parse_timeline_media_no_baseOption', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
timeline: { axisType: 'category' },
xAxis: { data: ['a'] },
yAxis: {},
......@@ -202,13 +202,13 @@ describe('timelineMediaOptions', function () {
expect(getData0(chart, 0)).toEqual(88);
expect(getLegendOption(chart).left).toEqual(50);
chart.setOption({ timeline: { currentIndex: 1 } });
chart.setOption<EChartsOption>({ timeline: { currentIndex: 1 } });
expect(getData0(chart, 0)).toEqual(99);
expect(getLegendOption(chart).left).toEqual(50);
});
it('parse_timeline_has_baseOption', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
baseOption: {
timeline: { axisType: 'category' },
xAxis: { data: ['a'] },
......@@ -227,12 +227,12 @@ describe('timelineMediaOptions', function () {
expect(getLegendOption(chart).right).not.toEqual(123);
expect(getTimelineComponent(chart) != null).toEqual(true);
chart.setOption({ timeline: { currentIndex: 1 } });
chart.setOption<EChartsOption>({ timeline: { currentIndex: 1 } });
expect(getData0(chart, 0)).toEqual(99);
});
it('parse_timeline_has_baseOption_compat', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
timeline: { axisType: 'category' },
baseOption: {
xAxis: { data: ['a'] },
......@@ -251,12 +251,12 @@ describe('timelineMediaOptions', function () {
expect(getLegendOption(chart).right).not.toEqual(123);
expect(getTimelineComponent(chart) != null).toEqual(true);
chart.setOption({ timeline: { currentIndex: 1 } });
chart.setOption<EChartsOption>({ timeline: { currentIndex: 1 } });
expect(getData0(chart, 0)).toEqual(99);
});
it('parse_timeline_has_baseOption_compat', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
timeline: { axisType: 'category' },
baseOption: {
xAxis: { data: ['a'] },
......@@ -275,12 +275,12 @@ describe('timelineMediaOptions', function () {
expect(getLegendOption(chart).right).not.toEqual(123);
expect(getTimelineComponent(chart) != null).toEqual(true);
chart.setOption({ timeline: { currentIndex: 1 } });
chart.setOption<EChartsOption>({ timeline: { currentIndex: 1 } });
expect(getData0(chart, 0)).toEqual(99);
});
it('parse_timeline_no_baseOption', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
timeline: { axisType: 'category' },
xAxis: { data: ['a'] },
yAxis: {},
......@@ -296,7 +296,7 @@ describe('timelineMediaOptions', function () {
expect(getLegendOption(chart).right).not.toEqual(123);
expect(getTimelineComponent(chart) != null).toEqual(true);
chart.setOption({ timeline: { currentIndex: 1 } });
chart.setOption<EChartsOption>({ timeline: { currentIndex: 1 } });
expect(getData0(chart, 0)).toEqual(99);
});
......@@ -310,7 +310,7 @@ describe('timelineMediaOptions', function () {
describe('timeline_onceMore', function () {
it('timeline_setOptionOnceMore_baseOption', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
baseOption: {
timeline: {
axisType: 'category',
......@@ -344,7 +344,7 @@ describe('timelineMediaOptions', function () {
expect(getData0(chart, 0)).toEqual(11);
expect(getData0(chart, 1)).toEqual(22);
chart.setOption({
chart.setOption<EChartsOption>({
xAxis: {data: ['c']},
timeline: {
currentIndex: 1
......@@ -358,7 +358,7 @@ describe('timelineMediaOptions', function () {
it('timeline_setOptionOnceMore_substitudeTimelineOptions', function () {
const option: EChartsFullOption = {
const option: EChartsOption = {
baseOption: {
timeline: {
axisType: 'category',
......@@ -416,7 +416,7 @@ describe('timelineMediaOptions', function () {
expect(getData0(chart, 0)).toEqual(1111);
expect(getData0(chart, 1)).toEqual(2222);
chart.setOption({
chart.setOption<EChartsOption>({
timeline: {
currentIndex: 0
}
......@@ -425,7 +425,7 @@ describe('timelineMediaOptions', function () {
expect(getData0(chart, 0)).toEqual(55);
expect(getData0(chart, 1)).toEqual(66);
chart.setOption({
chart.setOption<EChartsOption>({
timeline: {
currentIndex: 2
}
......
......@@ -20,7 +20,7 @@
import { EChartsType } from '../../../../src/echarts';
import { createChart } from '../../core/utHelper';
import { ZRColor } from '../../../../src/util/types';
import { CustomSeriesRenderItemAPI, CustomSeriesRenderItemParams } from '../../../../src/chart/custom';
import { CustomSeriesRenderItemAPI, CustomSeriesRenderItemParams } from '../../../../src/chart/custom/install';
describe('custom_series', function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册