Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
d377f1b7
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6068
Star
93
Fork
166
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
d377f1b7
编写于
6月 28, 2023
作者:
Y
yurj26
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(button): add test
上级
9c9f75e3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
147 addition
and
6 deletion
+147
-6
env.js
env.js
+38
-0
jest.config.js
jest.config.js
+11
-0
pages/component/button/button.test.js
pages/component/button/button.test.js
+82
-0
pages/component/button/button.uvue
pages/component/button/button.uvue
+16
-6
未找到文件。
env.js
0 → 100644
浏览文件 @
d377f1b7
module
.
exports
=
{
"
is-custom-runtime
"
:
false
,
"
compile
"
:
true
,
"
h5
"
:
{
"
options
"
:
{
"
headless
"
:
true
},
"
executablePath
"
:
""
},
"
mp-weixin
"
:
{
"
port
"
:
9420
,
"
account
"
:
""
,
"
args
"
:
""
,
"
cwd
"
:
""
,
"
launch
"
:
true
,
"
teardown
"
:
"
disconnect
"
,
"
remote
"
:
false
,
"
executablePath
"
:
""
},
"
app-plus
"
:
{
"
android
"
:
{
"
id
"
:
""
,
"
executablePath
"
:
""
},
"
version
"
:
""
,
"
ios
"
:
{
"
id
"
:
""
,
"
executablePath
"
:
""
},
"
uni-app-x
"
:
{
"
version
"
:
"
/Applications/HBuilderX-Alpha.app/Contents/HBuilderX/plugins/uniappx-launcher/base/version.txt
"
,
"
android
"
:
{
"
id
"
:
"
emulator-5554
"
,
"
executablePath
"
:
"
/Applications/HBuilderX-Alpha.app/Contents/HBuilderX/plugins/uniappx-launcher/base/android_base.apk
"
}
}
}
}
\ No newline at end of file
jest.config.js
0 → 100644
浏览文件 @
d377f1b7
module
.
exports
=
{
testTimeout
:
10000
,
reporters
:
[
'
default
'
],
watchPathIgnorePatterns
:
[
'
/node_modules/
'
,
'
/dist/
'
,
'
/.git/
'
],
moduleFileExtensions
:
[
'
js
'
,
'
json
'
],
rootDir
:
__dirname
,
testMatch
:
[
"
<rootDir>/pages/**/*test.[jt]s?(x)
"
],
testPathIgnorePatterns
:
[
'
/node_modules/
'
]
}
pages/component/button/button.test.js
0 → 100644
浏览文件 @
d377f1b7
function
getData
(
key
=
''
)
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
const
data
=
await
page
.
data
()
resolve
(
key
?
data
[
key
]
:
data
)
})
}
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/component/button/button
'
)
await
page
.
waitFor
(
1000
)
})
describe
(
'
Button.uvue
'
,
()
=>
{
it
(
'
click
'
,
async
()
=>
{
const
defaultBtn
=
await
page
.
$
(
'
.default-button
'
)
const
disabledBtn
=
await
page
.
$
(
'
.disabled-button
'
)
expect
(
await
getData
(
'
count
'
)).
toEqual
(
0
)
await
defaultBtn
.
tap
()
expect
(
await
getData
(
'
count
'
)).
toEqual
(
1
)
await
disabledBtn
.
tap
()
expect
(
await
getData
(
'
count
'
)).
toEqual
(
1
)
})
it
(
'
length
'
,
async
()
=>
{
const
btnLen
=
await
page
.
$$
(
'
.button
'
)
expect
(
btnLen
.
length
).
toBe
(
13
)
})
it
(
'
text
'
,
async
()
=>
{
const
textBtn
=
await
page
.
$
(
'
.text-button
'
)
expect
(
await
textBtn
.
text
()).
toEqual
(
'
按钮
'
)
await
page
.
setData
({
text
:
'
button
'
})
// TODO 待修复
expect
(
await
textBtn
.
text
()).
toEqual
(
'
button
'
)
})
it
(
'
type
'
,
async
()
=>
{
// TODO 目前获取组件属性只能通过组件的name,并且拿到的是最后一个
const
btn
=
await
page
.
$
(
'
Button
'
)
expect
(
await
btn
.
property
(
'
type
'
)).
toBe
(
'
warn
'
)
await
page
.
setData
({
type
:
'
default
'
})
await
page
.
waitFor
(
500
)
expect
(
await
btn
.
property
(
'
type
'
)).
toBe
(
'
default
'
)
await
page
.
setData
({
type
:
'
warn
'
})
await
page
.
waitFor
(
500
)
expect
(
await
btn
.
property
(
'
type
'
)).
toBe
(
'
warn
'
)
})
it
(
'
size
'
,
async
()
=>
{
const
btn
=
await
page
.
$
(
'
Button
'
)
expect
(
await
btn
.
property
(
'
size
'
)).
toBe
(
'
mini
'
)
await
page
.
setData
({
size
:
'
default
'
})
await
page
.
waitFor
(
500
)
expect
(
await
btn
.
property
(
'
size
'
)).
toBe
(
'
default
'
)
await
page
.
setData
({
size
:
'
mini
'
})
})
it
(
'
plain
'
,
async
()
=>
{
const
btn
=
await
page
.
$
(
'
Button
'
)
expect
(
await
btn
.
property
(
'
plain
'
)).
toBe
(
false
)
await
page
.
setData
({
plain
:
true
})
await
page
.
waitFor
(
500
)
expect
(
await
btn
.
property
(
'
plain
'
)).
toBe
(
true
)
})
it
(
'
disabled
'
,
async
()
=>
{
const
btn
=
await
page
.
$
(
'
Button
'
)
expect
(
await
btn
.
property
(
'
disabled
'
)).
toBe
(
false
)
await
page
.
setData
({
disabled
:
true
})
await
page
.
waitFor
(
500
)
expect
(
await
btn
.
property
(
'
disabled
'
)).
toBe
(
true
)
})
})
\ No newline at end of file
pages/component/button/button.uvue
浏览文件 @
d377f1b7
...
...
@@ -2,18 +2,18 @@
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<button type="primary">页面主操作 Normal</button>
<button type="primary"
class="button test-button"
>页面主操作 Normal</button>
<!-- <button type="primary" :loading="loading" class="button">页面主操作 Loading</button> -->
<button type="primary" :disabled="true" class="button">页面主操作 Disabled</button>
<button type="default" class="button">页面次要操作 Normal</button>
<button type="default" :disabled="true" class="button">页面次要操作 Disabled</button>
<button type="default" class="button
default-button" @click="addCount
">页面次要操作 Normal</button>
<button type="default" :disabled="true" class="button
disabled-button
">页面次要操作 Disabled</button>
<button type="warn" class="button">警告类操作 Normal</button>
<button type="warn" :disabled="true" class="button">警告类操作 Disabled</button>
<view class="button-sp-area">
<button type="primary" :plain="true" class="button
">按钮
</button>
<button type="primary" :plain="true" class="button
text-button">{{text}}
</button>
<button type="primary" :disabled="true" :plain="true" class="button">
不可点击的按钮
</button>
...
...
@@ -24,7 +24,8 @@
<view class="uni-flex uni-row">
<button class="button mini-btn" type="primary" size="mini">按钮</button>
<button class="button mini-btn" type="default" size="mini">按钮</button>
<button class="button mini-btn" type="warn" size="mini">按钮</button>
<button class="button mini-btn" :type="type" :size="size" :plain="plain"
:disabled="disabled">按钮</button>
</view>
</view>
</view>
...
...
@@ -36,7 +37,13 @@
return {
title: 'button',
loading: false,
_timer: 0
_timer: 0,
text: '按钮',
type: 'warn',
size: 'mini',
plain: false,
disabled: false,
count: 0
}
},
onShow() {
...
...
@@ -55,6 +62,9 @@
// clearTimeout(this._timer);
// }
// }
addCount() {
this.count++
}
},
}
</script>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录