提交 1a8ee3b2 编写于 作者: shutao-dc's avatar shutao-dc

update sticky-section.test.js 修改waitFor条件 增加截图准确性

上级 f40c5207
...@@ -17,8 +17,14 @@ describe('component-native-sticky-section', () => { ...@@ -17,8 +17,14 @@ describe('component-native-sticky-section', () => {
//滚动回顶部 //滚动回顶部
await page.callMethod('toTop') await page.callMethod('toTop')
page.waitFor(100) page.waitFor(100)
await page.setData({
scrolling: 'true'
})
//跳转到id为C的StickyHeader位置 //跳转到id为C的StickyHeader位置
await page.callMethod('gotoStickyHeader', 'C') await page.callMethod('gotoStickyHeader', 'C')
await page.waitFor(async () => {
return await page.data('scrolling') === false;
});
const image = await program.screenshot(); const image = await program.screenshot();
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
}) })
......
<template> <template>
<list-view id="list-view" ref="list-view" show-scrollbar=false class="page" :scroll-into-view="scrollIntoView" <list-view id="list-view" ref="list-view" show-scrollbar=false class="page" :scroll-into-view="scrollIntoView"
@scroll="onScroll" rebound="false"> @scroll="onScroll" @scrollend="onScrollEnd" rebound="false">
<list-item style="padding: 10px; margin: 5px 0;align-items: center;" type = 20> <list-item style="padding: 10px; margin: 5px 0;align-items: center;" type = 20>
<button @click="gotoStickyHeader('C')" size="mini">跳转到id为C的sticky-header位置上</button> <button @click="gotoStickyHeader('C')" size="mini">跳转到id为C的sticky-header位置上</button>
</list-item> </list-item>
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
return { return {
data: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N'], data: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N'],
sectionPadding: [0, 10, 0, 10] as Array<number>, sectionPadding: [0, 10, 0, 10] as Array<number>,
scrollIntoView: "" scrollIntoView: "",
scrolling: false
} }
}, },
methods: { methods: {
...@@ -42,6 +43,10 @@ ...@@ -42,6 +43,10 @@
this.scrollIntoView = id this.scrollIntoView = id
}, },
onScroll() { onScroll() {
this.scrolling = true
},
onScrollEnd() {
this.scrolling = false
//滚动后重置scrollIntoView = "" //滚动后重置scrollIntoView = ""
if(this.scrollIntoView != "") { if(this.scrollIntoView != "") {
this.scrollIntoView = "" this.scrollIntoView = ""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册