Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
03dcd92d
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
03dcd92d
编写于
5月 23, 2024
作者:
辛宝Otto
🥊
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: 补充 progress/picker-view 事件测试
上级
d9f88214
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
105 addition
and
26 deletion
+105
-26
pages/component/picker-view/picker-view.test.js
pages/component/picker-view/picker-view.test.js
+46
-23
pages/component/picker-view/picker-view.uvue
pages/component/picker-view/picker-view.uvue
+21
-3
pages/component/progress/progress.test.js
pages/component/progress/progress.test.js
+21
-0
pages/component/progress/progress.uvue
pages/component/progress/progress.uvue
+17
-0
未找到文件。
pages/component/picker-view/picker-view.test.js
浏览文件 @
03dcd92d
...
...
@@ -11,6 +11,11 @@ let page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
await
page
.
callMethod
(
'
setEventCallbackNum
'
,
0
)
})
afterEach
(
async
()
=>
{
await
page
.
callMethod
(
'
setEventCallbackNum
'
,
0
)
})
describe
(
'
PickerView.uvue
'
,
()
=>
{
...
...
@@ -79,4 +84,22 @@ describe('PickerView.uvue', () => {
expect
(
month
).
toEqual
(
date
.
getMonth
()
+
1
)
expect
(
day
).
toEqual
(
date
.
getDate
())
})
it
(
'
trigger UniPickerViewChangeEvent
'
,
async
()
=>
{
// if web skip todo
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
)
{
expect
(
1
).
toBe
(
1
)
return
}
const
el
=
await
page
.
$
(
'
.picker-view
'
)
await
page
.
callMethod
(
'
setValue
'
)
await
page
.
waitFor
(
1000
)
const
eventCallbackNum
=
await
page
.
callMethod
(
'
getEventCallbackNum
'
)
// 3 times 3*3
expect
(
eventCallbackNum
).
toBe
(
9
)
})
})
pages/component/picker-view/picker-view.uvue
浏览文件 @
03dcd92d
...
...
@@ -23,6 +23,7 @@
</template>
<script lang="uts">
import { state, setEventCallbackNum } from '@/store/index.uts'
export default {
data() {
const date = new Date()
...
...
@@ -57,7 +58,24 @@
}
},
methods: {
// 自动化测试
getEventCallbackNum() : number {
return state.eventCallbackNum
},
// 自动化测试
setEventCallbackNum(num : number) {
setEventCallbackNum(num)
},
bindChange(e : UniPickerViewChangeEvent) {
// 自动化测试
console.log(e.target?.tagName,e.type);
if ((e.target?.tagName ?? '').includes('PICKER-VIEW')) {
this.setEventCallbackNum(state.eventCallbackNum + 1)
}
if (e.type === 'change') {
this.setEventCallbackNum(state.eventCallbackNum + 2)
}
const val = e.detail.value
this.result = val
this.year = this.years[val[0]]
...
...
pages/component/progress/progress.test.js
浏览文件 @
03dcd92d
...
...
@@ -11,6 +11,10 @@ beforeAll(async () => {
await
page
.
waitFor
(
2000
);
})
beforeEach
(
async
()
=>
{
await
page
.
callMethod
(
'
setEventCallbackNum
'
,
0
)
})
describe
(
'
Progress.uvue
'
,
()
=>
{
it
(
'
percent
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setProgress
'
)
...
...
@@ -80,4 +84,21 @@ describe('Progress.uvue', () => {
})
expect
(
await
el
.
attribute
(
'
background-color
'
)).
toEqual
(
'
#007aff
'
)
})
it
(
'
trigger UniProgressActiveendEvent
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
)
{
expect
(
1
).
toBe
(
1
)
return
}
await
page
.
setData
({
pgList
:
[
21
,
40
,
60
,
80
]
})
// 动画执行
await
page
.
waitFor
(
1000
);
const
eventCallbackNum
=
await
page
.
callMethod
(
'
getEventCallbackNum
'
)
expect
(
eventCallbackNum
).
toBe
(
3
)
})
})
pages/component/progress/progress.uvue
浏览文件 @
03dcd92d
<script>
import { state, setEventCallbackNum } from '@/store/index.uts'
import { ItemType } from '@/components/enum-data/enum-data'
export default {
data() {
...
...
@@ -25,6 +26,15 @@
}
},
methods: {
// 自动化测试
getEventCallbackNum() : number {
return state.eventCallbackNum
},
// 自动化测试
setEventCallbackNum(num : number) {
setEventCallbackNum(num)
},
setProgress() {
this.pgList = [20, 40, 60, 80] as number[]
},
...
...
@@ -32,6 +42,13 @@
this.pgList = [0, 0, 0, 0] as number[]
},
activeend(e : UniProgressActiveendEvent) {
// 自动化测试
if ((e.target?.tagName ?? '').includes('PROGRESS')) {
this.setEventCallbackNum(state.eventCallbackNum + 1)
}
if (e.type === 'activeend') {
this.setEventCallbackNum(state.eventCallbackNum + 2)
}
this.curPercent = e.detail.curPercent
},
progress_touchstart() { console.log("手指触摸动作开始") },
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录