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

合并 swiper2.test.js 解决冲突

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