Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
03dcd92d
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6004
Star
91
Fork
163
代码
文件
提交
分支
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
...
@@ -4,21 +4,26 @@ function getData(key = '') {
...
@@ -4,21 +4,26 @@ function getData(key = '') {
resolve
(
key
?
data
[
key
]
:
data
)
resolve
(
key
?
data
[
key
]
:
data
)
})
})
}
}
const
PAGE_PATH
=
'
/pages/component/picker-view/picker-view
'
const
PAGE_PATH
=
'
/pages/component/picker-view/picker-view
'
let
page
let
page
beforeAll
(
async
()
=>
{
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
await
page
.
waitFor
(
'
view
'
)
await
page
.
callMethod
(
'
setEventCallbackNum
'
,
0
)
})
afterEach
(
async
()
=>
{
await
page
.
callMethod
(
'
setEventCallbackNum
'
,
0
)
})
})
describe
(
'
PickerView.uvue
'
,
()
=>
{
describe
(
'
PickerView.uvue
'
,
()
=>
{
it
(
'
value
'
,
async
()
=>
{
it
(
'
value
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
.picker-view
'
)
const
el
=
await
page
.
$
(
'
.picker-view
'
)
await
page
.
callMethod
(
'
setValue
'
)
await
page
.
callMethod
(
'
setValue
'
)
await
page
.
waitFor
(
1000
)
await
page
.
waitFor
(
1000
)
const
newValue1
=
await
el
.
property
(
'
value
'
)
const
newValue1
=
await
el
.
property
(
'
value
'
)
// TODO
// TODO
expect
(
newValue1
.
toString
()).
toEqual
(
'
0,0,0
'
)
expect
(
newValue1
.
toString
()).
toEqual
(
'
0,0,0
'
)
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-android
'
)
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-android
'
)
{
...
@@ -26,8 +31,8 @@ describe('PickerView.uvue', () => {
...
@@ -26,8 +31,8 @@ describe('PickerView.uvue', () => {
}
}
await
page
.
callMethod
(
'
setValue1
'
)
await
page
.
callMethod
(
'
setValue1
'
)
await
page
.
waitFor
(
1000
)
await
page
.
waitFor
(
1000
)
const
newValue2
=
await
el
.
property
(
'
value
'
)
const
newValue2
=
await
el
.
property
(
'
value
'
)
// TODO
// TODO
expect
(
newValue2
.
toString
()).
toEqual
(
'
10,10,10
'
)
expect
(
newValue2
.
toString
()).
toEqual
(
'
10,10,10
'
)
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-android
'
)
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-android
'
)
{
...
@@ -62,21 +67,39 @@ describe('PickerView.uvue', () => {
...
@@ -62,21 +67,39 @@ describe('PickerView.uvue', () => {
maskBottomStyle
:
'
background: #ffffff;
'
,
maskBottomStyle
:
'
background: #ffffff;
'
,
})
})
expect
(
await
el
.
attribute
(
'
mask-bottom-style
'
)).
toBe
(
'
background: #ffffff;
'
)
expect
(
await
el
.
attribute
(
'
mask-bottom-style
'
)).
toBe
(
'
background: #ffffff;
'
)
})
it
(
'
reopen-picker-view-page
'
,
async
()
=>
{
page
=
await
program
.
switchTab
(
'
/pages/tabBar/component
'
)
await
page
.
waitFor
(
500
)
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
const
date
=
new
Date
()
const
{
year
,
month
,
day
}
=
await
page
.
data
()
expect
(
year
).
toEqual
(
date
.
getFullYear
())
expect
(
month
).
toEqual
(
date
.
getMonth
()
+
1
)
expect
(
day
).
toEqual
(
date
.
getDate
())
})
})
})
it
(
'
reopen-picker-view-page
'
,
async
()
=>
{
page
=
await
program
.
switchTab
(
'
/pages/tabBar/component
'
)
await
page
.
waitFor
(
500
)
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
const
date
=
new
Date
()
const
{
year
,
month
,
day
}
=
await
page
.
data
()
expect
(
year
).
toEqual
(
date
.
getFullYear
())
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
...
@@ -22,7 +22,8 @@
...
@@ -22,7 +22,8 @@
</view>
</view>
</template>
</template>
<script lang="uts">
<script lang="uts">
import { state, setEventCallbackNum } from '@/store/index.uts'
export default {
export default {
data() {
data() {
const date = new Date()
const date = new Date()
...
@@ -56,8 +57,25 @@
...
@@ -56,8 +57,25 @@
maskBottomStyle: ''
maskBottomStyle: ''
}
}
},
},
methods: {
methods: {
bindChange(e : UniPickerViewChangeEvent) {
// 自动化测试
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
const val = e.detail.value
this.result = val
this.result = val
this.year = this.years[val[0]]
this.year = this.years[val[0]]
...
...
pages/component/progress/progress.test.js
浏览文件 @
03dcd92d
...
@@ -11,6 +11,10 @@ beforeAll(async () => {
...
@@ -11,6 +11,10 @@ beforeAll(async () => {
await
page
.
waitFor
(
2000
);
await
page
.
waitFor
(
2000
);
})
})
beforeEach
(
async
()
=>
{
await
page
.
callMethod
(
'
setEventCallbackNum
'
,
0
)
})
describe
(
'
Progress.uvue
'
,
()
=>
{
describe
(
'
Progress.uvue
'
,
()
=>
{
it
(
'
percent
'
,
async
()
=>
{
it
(
'
percent
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setProgress
'
)
await
page
.
callMethod
(
'
setProgress
'
)
...
@@ -80,4 +84,21 @@ describe('Progress.uvue', () => {
...
@@ -80,4 +84,21 @@ describe('Progress.uvue', () => {
})
})
expect
(
await
el
.
attribute
(
'
background-color
'
)).
toEqual
(
'
#007aff
'
)
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>
<script>
import { state, setEventCallbackNum } from '@/store/index.uts'
import { ItemType } from '@/components/enum-data/enum-data'
import { ItemType } from '@/components/enum-data/enum-data'
export default {
export default {
data() {
data() {
...
@@ -25,6 +26,15 @@
...
@@ -25,6 +26,15 @@
}
}
},
},
methods: {
methods: {
// 自动化测试
getEventCallbackNum() : number {
return state.eventCallbackNum
},
// 自动化测试
setEventCallbackNum(num : number) {
setEventCallbackNum(num)
},
setProgress() {
setProgress() {
this.pgList = [20, 40, 60, 80] as number[]
this.pgList = [20, 40, 60, 80] as number[]
},
},
...
@@ -32,6 +42,13 @@
...
@@ -32,6 +42,13 @@
this.pgList = [0, 0, 0, 0] as number[]
this.pgList = [0, 0, 0, 0] as number[]
},
},
activeend(e : UniProgressActiveendEvent) {
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
this.curPercent = e.detail.curPercent
},
},
progress_touchstart() { console.log("手指触摸动作开始") },
progress_touchstart() { console.log("手指触摸动作开始") },
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录