Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
b8c6add1
I
incubator-echarts
项目概览
x649585723
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
incubator-echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b8c6add1
编写于
3月 31, 2021
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: add missing component ut. fix some warnings
上级
ac49c2b2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
149 addition
and
10 deletion
+149
-10
test/ut/core/extendExpect.ts
test/ut/core/extendExpect.ts
+3
-1
test/ut/core/utHelper.ts
test/ut/core/utHelper.ts
+10
-4
test/ut/index.d.ts
test/ut/index.d.ts
+13
-0
test/ut/spec/model/componentMissing.test.ts
test/ut/spec/model/componentMissing.test.ts
+118
-0
test/ut/spec/scale/interval.test.ts
test/ut/spec/scale/interval.test.ts
+5
-5
未找到文件。
test/ut/core/extendExpect.ts
浏览文件 @
b8c6add1
...
...
@@ -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
...
...
test/ut/core/utHelper.ts
浏览文件 @
b8c6add1
...
...
@@ -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
...
...
test/ut/index.d.ts
0 → 100644
浏览文件 @
b8c6add1
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
test/ut/spec/model/componentMissing.test.ts
0 → 100644
浏览文件 @
b8c6add1
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
test/ut/spec/scale/interval.test.ts
浏览文件 @
b8c6add1
...
...
@@ -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
(
i
sValueFinite
(
intervalPrecision
)).
toEqual
(
true
);
expect
(
isValueFinite
(
niceTickExtent
[
0
])).
toEqual
(
true
);
expect
(
isValueFinite
(
niceTickExtent
[
1
])).
toEqual
(
true
);
expect
(
resultInterval
).
toBeFinite
(
);
expect
(
i
ntervalPrecision
).
toBeFinite
(
);
expect
(
niceTickExtent
[
0
]).
toBeFinite
(
);
expect
(
niceTickExtent
[
1
]).
toBeFinite
(
);
expect
(
niceTickExtent
[
0
]).
toBeGreaterThanOrEqual
(
extent
[
0
]);
expect
(
niceTickExtent
[
1
]).
not
.
toBeGreaterThan
(
extent
[
1
]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录