提交 a7752a34 编写于 作者: Anne_LXM's avatar Anne_LXM

新增默认下拉刷新事件自动化测试例

上级 03aae027
......@@ -11,7 +11,15 @@ describe('component-native-scroll-view-refresher', () => {
beforeAll(async () => {
page = await program.reLaunch('/pages/component/scroll-view/scroll-view-refresher');
await page.waitFor(300);
});
});
async function eventCheck(dataName,typeName){
const eventInfo = await page.data(dataName)
expect(eventInfo.type).toBe(typeName)
expect(eventInfo.currentTarget).not.toBeFalsy();
expect(eventInfo.target).not.toBeFalsy();
expect(eventInfo.detail.dy).toBeGreaterThan(0)
}
it('scroll-view-refresher-screenshot', async () => {
//禁止滚动条
......@@ -23,12 +31,19 @@ describe('component-native-scroll-view-refresher', () => {
expect(image).toSaveImageSnapshot();
})
it('check_refresher', async () => {
it('check_refresher_refresh_event', async () => {
await page.setData({
refresherTriggered: true
})
await page.waitFor(2000);
expect(await page.data('refresherrefreshTimes')).toBe(1)
expect(await page.data('refresherrefreshTimes')).toBe(1)
// 手动设置下拉刷新状态refresher-triggered为true时,在web和iOS不触发@refresherpulling事件
if(process.env.uniTestPlatformInfo.startsWith('android')){
await eventCheck('onRefresherpullingTest','refresherpulling')
}
await eventCheck('refresherrefreshTest','refresherrefresh')
await page.waitFor(1000);
await eventCheck('onRefresherrestoreTest','refresherrestore')
});
it('check_refresher_snapshot', async () => {
......
......@@ -20,7 +20,12 @@
refresherTriggered: false,
refresherrefresh: false,
refresherrefreshTimes: 0,
showScrollbar: false
showScrollbar: false,
// 自动化测试
refresherrefreshTest:null as RefresherEvent|null,
onRefresherabortTest:null as RefresherEvent|null,
onRefresherrestoreTest:null as RefresherEvent|null,
onRefresherpullingTest:null as RefresherEvent|null
};
},
onLoad() {
......@@ -32,25 +37,28 @@
},
methods: {
onRefresherrefresh(_ : RefresherEvent) {
onRefresherrefresh(e : RefresherEvent) {
this.refresherrefresh = true
console.log("onRefresherrefresh--------------下拉刷新触发")
this.refresherrefreshTest = e
this.refresherTriggered = true
this.refresherrefreshTimes++
setTimeout(() => {
this.refresherTriggered = false
}, 1500)
},
onRefresherabort(_ : RefresherEvent) {
onRefresherabort(e : RefresherEvent) {
console.log("onRefresherabort------下拉刷新被中止")
this.onRefresherabortTest = e
},
onRefresherrestore(_ : RefresherEvent) {
onRefresherrestore(e : RefresherEvent) {
this.refresherrefresh = false
console.log("onRefresherrestore------下拉刷新被复位")
this.onRefresherrestoreTest = e
},
onRefresherpulling(e : RefresherEvent) {
console.log("onRefresherpulling------拉刷新控件被下拉-dy=" + e.detail.dy)
this.onRefresherpullingTest = e
},
onScrolltolower(e : ScrollToLowerEvent) {
console.log("onScrolltolower 滚动到底部-----" + e.detail.direction)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册