Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
cube-ui
提交
863fef4d
C
cube-ui
项目概览
DiDi
/
cube-ui
12 个月 前同步成功
通知
34
Star
9078
Fork
1508
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
cube-ui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
863fef4d
编写于
12月 13, 2017
作者:
D
dolymood
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more unit tests
上级
eb156647
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
96 addition
and
1 deletion
+96
-1
test/unit/specs/dialog.spec.js
test/unit/specs/dialog.spec.js
+53
-0
test/unit/specs/loading.spec.js
test/unit/specs/loading.spec.js
+12
-1
test/unit/specs/picker.spec.js
test/unit/specs/picker.spec.js
+18
-0
test/unit/specs/time-picker.spec.js
test/unit/specs/time-picker.spec.js
+13
-0
未找到文件。
test/unit/specs/dialog.spec.js
浏览文件 @
863fef4d
...
...
@@ -53,6 +53,28 @@ describe('Dialog', () => {
.
to
.
equal
(
2
)
})
it
(
'
should render correct contents - confirmBtn/cancelBtn
'
,
()
=>
{
const
href
=
'
https://didichuxing.com/
'
vm
=
createDialog
({
type
:
'
confirm
'
,
content
:
'
dialog
'
,
confirmBtn
:
'
确定1
'
,
cancelBtn
:
{
text
:
'
取消1
'
,
active
:
false
,
disabled
:
false
,
href
:
href
}
})
const
btns
=
vm
.
$el
.
querySelector
(
'
.cube-dialog-btns
'
).
getElementsByTagName
(
'
a
'
)
expect
(
btns
.
length
)
.
to
.
equal
(
2
)
expect
(
btns
[
0
].
href
).
to
.
equal
(
href
)
expect
(
btns
[
0
].
textContent
).
to
.
equal
(
'
取消1
'
)
expect
(
btns
[
1
].
href
).
to
.
equal
(
'
javascript:;
'
)
expect
(
btns
[
1
].
textContent
).
to
.
equal
(
'
确定1
'
)
})
it
(
'
should trigger events
'
,
()
=>
{
const
confirmHandler
=
sinon
.
spy
()
const
cancelHandler
=
sinon
.
spy
()
...
...
@@ -87,6 +109,37 @@ describe('Dialog', () => {
.
to
.
be
.
calledOnce
})
it
(
'
should not trigger events when btn is disabled
'
,
()
=>
{
const
confirmHandler
=
sinon
.
spy
()
const
cancelHandler
=
sinon
.
spy
()
vm
=
createDialog
({
type
:
'
confirm
'
,
title
:
'
dialog title
'
,
content
:
'
dialog
'
,
confirmBtn
:
{
disabled
:
true
},
cancelBtn
:
{
disabled
:
true
}
},
{
confirm
:
confirmHandler
,
cancel
:
cancelHandler
})
vm
.
show
()
// confirm click
vm
.
$el
.
querySelector
(
'
.cube-dialog-btns a:last-child
'
).
click
()
expect
(
vm
.
isVisible
)
.
to
.
be
.
true
expect
(
confirmHandler
)
.
to
.
have
.
callCount
(
0
)
vm
.
$el
.
querySelector
(
'
.cube-dialog-btns a
'
).
click
()
expect
(
vm
.
isVisible
)
.
to
.
be
.
true
expect
(
cancelHandler
)
.
to
.
have
.
callCount
(
0
)
})
function
createDialog
(
props
=
{},
events
=
{})
{
return
instantiateComponent
(
Vue
,
Dialog
,
{
props
:
props
,
...
...
test/unit/specs/loading.spec.js
浏览文件 @
863fef4d
...
...
@@ -15,9 +15,20 @@ describe('Loading.vue', () => {
expect
(
Vue
.
component
(
Loading
.
name
))
.
to
.
be
.
a
(
'
function
'
)
})
it
(
'
should render correct contents
'
,
()
=>
{
it
(
'
should render correct contents
- no size
'
,
()
=>
{
vm
=
instantiateComponent
(
Vue
,
Loading
,
{})
expect
(
vm
.
$el
.
className
)
.
to
.
equal
(
'
cube-loading
'
)
expect
(
vm
.
$el
.
querySelector
(
'
.cube-loading-spinners
'
).
style
.
width
)
.
to
.
equal
(
''
)
})
it
(
'
should render correct contents - with size
'
,
()
=>
{
vm
=
instantiateComponent
(
Vue
,
Loading
,
{
props
:
{
size
:
30
}
})
expect
(
vm
.
$el
.
querySelector
(
'
.cube-loading-spinners
'
).
style
.
width
)
.
to
.
equal
(
'
30px
'
)
})
})
test/unit/specs/picker.spec.js
浏览文件 @
863fef4d
...
...
@@ -58,6 +58,7 @@ describe('Picker', () => {
Vue
.
use
(
Picker
)
expect
(
Vue
.
component
(
Picker
.
name
))
.
to
.
be
.
a
(
'
function
'
)
expect
(
Vue
.
prototype
.
$createPicker
).
to
.
be
.
a
(
'
function
'
)
})
it
(
'
should render correct contents
'
,
function
()
{
...
...
@@ -155,6 +156,23 @@ describe('Picker', () => {
},
150
)
})
it
(
'
should add warn log when sigle is false
'
,
()
=>
{
const
app
=
new
Vue
()
const
originWarn
=
console
.
warn
const
msgs
=
[]
console
.
warn
=
function
(...
args
)
{
msgs
.
push
(
args
.
join
(
'
#
'
))
}
vm
=
app
.
$createPicker
({
title
:
'
变化选择器
'
,
data
:
[
data1
],
selectedIndex
:
[
1
]
},
true
)
expect
(
msgs
.
length
)
.
to
.
equal
(
1
)
console
.
warn
=
originWarn
})
function
createPicker
(
props
=
{},
events
=
{})
{
return
instantiateComponent
(
Vue
,
Picker
,
{
props
:
props
,
...
...
test/unit/specs/time-picker.spec.js
浏览文件 @
863fef4d
...
...
@@ -121,6 +121,19 @@ describe('TimePicker', () => {
},
100
)
})
})
it
(
'
should add warn log when sigle is false
'
,
()
=>
{
const
app
=
new
Vue
()
const
originWarn
=
console
.
warn
const
msgs
=
[]
console
.
warn
=
function
(...
args
)
{
msgs
.
push
(
args
.
join
(
'
#
'
))
}
vm
=
app
.
$createTimePicker
({},
true
)
expect
(
msgs
.
length
)
.
to
.
equal
(
1
)
console
.
warn
=
originWarn
})
})
function
createPicker
(
props
=
{},
events
=
{})
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录