Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
f5f22bf9
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6007
Star
91
Fork
164
代码
文件
提交
分支
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看板
提交
f5f22bf9
编写于
6月 04, 2024
作者:
Anne_LXM
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增swiper事件自动化测试例
上级
160a7862
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
72 addition
and
8 deletion
+72
-8
pages/component/swiper/swiper.test.js
pages/component/swiper/swiper.test.js
+59
-2
pages/component/swiper/swiper.uvue
pages/component/swiper/swiper.uvue
+13
-6
未找到文件。
pages/component/swiper/swiper.test.js
浏览文件 @
f5f22bf9
jest
.
setTimeout
(
2
0000
);
jest
.
setTimeout
(
3
0000
);
function
getData
(
key
=
''
)
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
...
...
@@ -72,6 +72,63 @@ describe('test swiper', () => {
})
await
page
.
waitFor
(
600
)
expect
(
await
getData
(
'
currentValChange
'
)).
toEqual
(
0
)
});
it
(
'
Trigger Event
'
,
async
()
=>
{
await
page
.
setData
({
swiperChangeSelect
:
true
,
swiperTransitionSelect
:
true
,
swiperAnimationfinishSelect
:
true
,
autoplaySelect
:
true
})
await
page
.
waitFor
(
2000
)
console
.
log
(
'
currentValChange
'
,
await
getData
(
'
currentValChange
'
))
if
(
await
getData
(
'
currentValChange
'
)
==
1
){
await
page
.
setData
({
autoplaySelect
:
false
})
}
});
it
(
'
Event change-transitiont-animationfinish
'
,
async
()
=>
{
const
webResult
=
{
current
:
1
,
currentItemId
:
'
B
'
,
//web端多了currentItemId
source
:
'
autoplay
'
,
}
const
appResult
=
{
current
:
1
,
source
:
'
autoplay
'
,
}
const
changeInfo
=
await
page
.
data
(
'
swiperChangeEventTest
'
)
// console.log('change',changeInfo)
expect
(
changeInfo
.
type
).
toBe
(
'
change
'
)
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)){
expect
(
changeInfo
.
detail
).
toEqual
(
webResult
)
}
else
{
expect
(
changeInfo
.
detail
).
toEqual
(
appResult
)
}
expect
(
changeInfo
.
currentTarget
).
not
.
toBeFalsy
();
expect
(
changeInfo
.
target
).
not
.
toBeFalsy
();
const
transitionInfo
=
await
page
.
data
(
'
swiperTransitionTest
'
)
// console.log('transitiont',transitionInfo,detail)
expect
(
transitionInfo
.
type
).
toBe
(
'
transition
'
)
expect
(
transitionInfo
.
detail
.
dy
).
toBe
(
0
)
expect
(
transitionInfo
.
detail
.
dx
).
toBeGreaterThan
(
0
)
expect
(
transitionInfo
.
currentTarget
).
not
.
toBeFalsy
();
expect
(
transitionInfo
.
target
).
not
.
toBeFalsy
();
await
page
.
waitFor
(
1000
)
// bug:在android端第一次触发@animationfinish 得到detail中的source为空,第二次触发时正常得到source: 'autoplay'
const
animationfinishInfo
=
await
page
.
data
(
'
swiperAnimationfinishTest
'
)
// console.log('animationfinish',animationfinishInfo.detail)
expect
(
animationfinishInfo
.
type
).
toBe
(
'
animationfinish
'
)
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)){
expect
(
animationfinishInfo
.
detail
).
toEqual
(
webResult
)
}
else
if
(
!
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)){
expect
(
animationfinishInfo
.
detail
).
toEqual
(
appResult
)
}
expect
(
animationfinishInfo
.
currentTarget
).
not
.
toBeFalsy
();
expect
(
animationfinishInfo
.
target
).
not
.
toBeFalsy
();
});
});
pages/component/swiper/swiper.uvue
浏览文件 @
f5f22bf9
...
...
@@ -110,12 +110,17 @@
swiperTransitionSelect: false,
swiperAnimationfinishSelect: false,
swiperChangeSelect: false,
currentValChange: 0
currentValChange: 0,
// 自动化测试
swiperChangeEventTest:null as SwiperChangeEvent | null,
swiperTransitionTest:null as SwiperTransitionEvent | null,
swiperAnimationfinishTest:null as SwiperAnimationFinishEvent | null
}
},
},
methods: {
swiperChange: function (e : SwiperChangeEvent) {
swiperChange: function (e : SwiperChangeEvent) {
this.swiperChangeEventTest = e
this.currentValChange = e.detail.current
console.log(this.currentValChange)
if (this.swiperChangeSelect) {
...
...
@@ -123,13 +128,15 @@
console.log(e)
}
},
swiperTransition: function (e : SwiperTransitionEvent) {
swiperTransition: function (e : SwiperTransitionEvent) {
this.swiperTransitionTest = e
if (this.swiperTransitionSelect) {
console.log("swiperTransition")
console.log(e)
}
},
swiperAnimationfinish: function (e : SwiperAnimationFinishEvent) {
swiperAnimationfinish: function (e : SwiperAnimationFinishEvent) {
this.swiperAnimationfinishTest = e
if (this.swiperAnimationfinishSelect) {
console.log("swiperAnimationfinish")
console.log(e)
...
...
@@ -148,7 +155,7 @@
swiperAnimationfinishChange: function (e : UniSwitchChangeEvent) {
this.swiperAnimationfinishSelect = e.detail.value
},
autoplayChange: function (e : UniSwitchChangeEvent) {
autoplayChange: function (e : UniSwitchChangeEvent) {
this.autoplaySelect = e.detail.value
},
verticalChange: function (e : UniSwitchChangeEvent) {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录