提交 9f8eb0e4 编写于 作者: DCloud_iOS_XHY's avatar DCloud_iOS_XHY

合并 swiper2.test.js 解决冲突

上级 5b6f9356
......@@ -9,9 +9,9 @@
:rebound="reboundSelect" :interval="intervalSelect" :circular="circularSelect"
:indicator-color="indicatorColor" :indicator-active-color="indicatorColorActive"
:disable-touch="disableTouchSelect" :current="currentVal" :current-item-id="currentItemIdVal"
@change="swiperChange" @transition="swiperTransition" @animationfinish="swiperAnimationfinish">
@change="swiperChange" @transition="swiperTransition" @animationfinish="swiperAnimationfinish" @touchstart="swipertouchStart">
<swiper-item item-id="A">
<view class="swiper-item uni-bg-red"><text class="swiper-item-Text">A</text></view>
<view class="swiper-item uni-bg-red"><text class="swiper-item-Text" >A</text></view>
</swiper-item>
<swiper-item item-id="B">
<view class="swiper-item uni-bg-green"><text class="swiper-item-Text">B</text></view>
......@@ -90,9 +90,9 @@
<script>
type SwiperEventTest = {
type: string;
target: UniElement | null;
currentTarget: UniElement | null;
type : string;
target : UniElement | null;
currentTarget : UniElement | null;
}
export default {
data() {
......@@ -117,22 +117,28 @@
swiperChangeSelect: false,
currentValChange: 0,
// 自动化测试
changeDetailTest:null as UniSwiperChangeEventDetail | null,
transitionDetailTest:null as UniSwiperTransitionEventDetail | null,
animationfinishDetailTest:null as UniSwiperAnimationFinishEventDetail | null,
isChangeTest:'',
isTransitionTest:'',
isAnimationfinishTest:''
changeDetailTest: null as UniSwiperChangeEventDetail | null,
transitionDetailTest: null as UniSwiperTransitionEventDetail | null,
animationfinishDetailTest: null as UniSwiperAnimationFinishEventDetail | null,
isChangeTest: '',
isTransitionTest: '',
isAnimationfinishTest: ''
}
},
methods: {
swipertouchStart(e: UniTouchEvent) {
console.log("swiper touchstart")
},
viewtouchStart(e: UniTouchEvent) {
console.log("view touchstart:")
},
swiperChange: function (e : UniSwiperChangeEvent) {
this.changeDetailTest = e.detail
this.checkEventTest({
type:e.type,
target:e.target,
currentTarget:e.currentTarget
} as SwiperEventTest,'change')
type: e.type,
target: e.target,
currentTarget: e.currentTarget
} as SwiperEventTest, 'change')
this.currentValChange = e.detail.current
console.log(this.currentValChange)
if (this.swiperChangeSelect) {
......@@ -143,10 +149,10 @@
swiperTransition: function (e : UniSwiperTransitionEvent) {
this.transitionDetailTest = e.detail
this.checkEventTest({
type:e.type,
target:e.target,
currentTarget:e.currentTarget
} as SwiperEventTest,'transition')
type: e.type,
target: e.target,
currentTarget: e.currentTarget
} as SwiperEventTest, 'transition')
if (this.swiperTransitionSelect) {
console.log("swiperTransition")
console.log(e)
......@@ -155,20 +161,20 @@
swiperAnimationfinish: function (e : UniSwiperAnimationFinishEvent) {
this.animationfinishDetailTest = e.detail
this.checkEventTest({
type:e.type,
target:e.target,
currentTarget:e.currentTarget
} as SwiperEventTest,'animationfinish')
type: e.type,
target: e.target,
currentTarget: e.currentTarget
} as SwiperEventTest, 'animationfinish')
if (this.swiperAnimationfinishSelect) {
console.log("swiperAnimationfinish")
console.log(e)
}
},
// 自动化测试专用(由于事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取)
checkEventTest(e:SwiperEventTest, eventName:String){
checkEventTest(e : SwiperEventTest, eventName : String) {
const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement;
const result = isPass ? `${eventName}:Success` : `${eventName}:Fail`;
switch (eventName){
switch (eventName) {
case 'change':
this.isChangeTest = result
break;
......
const PAGE_PATH = '/pages/component/swiper/swiper'
describe('swiper-touch-test', () => {
// 屏蔽 web 平台
if (process.env.uniTestPlatformInfo.startsWith('web')) {
it('other platform', () => {
expect(1).toBe(1)
})
return
}
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(1500);
})
it('swiper-touch-test', async () => {
await program.swipe({
startPoint: {x: 246,y: 193},
endPoint: {x: 1,y: 193},
duration: 200
})
await page.waitFor(1000)
let val = await page.data('currentValChange')
console.log(val)
expect(val).toEqual(1)
})
})
......@@ -6,6 +6,7 @@ const sortTestFilePaths = [
"pages/component/list-view/list-view-refresh.test.js",
"pages/component/scroll-view/scroll-view-refresher.test.js",
"pages/component/global-events/touch-events.test.js",
"pages/component/swiper/swiper2.test.js",
"pages/component/rich-text/rich-text-complex.test.js"
]
class CustomSequencer extends Sequencer {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册