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

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

上级 6c3707f4
...@@ -11,7 +11,15 @@ describe('component-native-scroll-view-refresher', () => { ...@@ -11,7 +11,15 @@ describe('component-native-scroll-view-refresher', () => {
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch('/pages/component/scroll-view/scroll-view-refresher'); page = await program.reLaunch('/pages/component/scroll-view/scroll-view-refresher');
await page.waitFor(300); 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 () => { it('scroll-view-refresher-screenshot', async () => {
//禁止滚动条 //禁止滚动条
...@@ -23,12 +31,19 @@ describe('component-native-scroll-view-refresher', () => { ...@@ -23,12 +31,19 @@ describe('component-native-scroll-view-refresher', () => {
expect(image).toSaveImageSnapshot(); expect(image).toSaveImageSnapshot();
}) })
it('check_refresher', async () => { it('check_refresher_refresh_event', async () => {
await page.setData({ await page.setData({
refresherTriggered: true refresherTriggered: true
}) })
await page.waitFor(2000); 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 () => { it('check_refresher_snapshot', async () => {
......
...@@ -20,7 +20,12 @@ ...@@ -20,7 +20,12 @@
refresherTriggered: false, refresherTriggered: false,
refresherrefresh: false, refresherrefresh: false,
refresherrefreshTimes: 0, 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() { onLoad() {
...@@ -32,25 +37,28 @@ ...@@ -32,25 +37,28 @@
}, },
methods: { methods: {
onRefresherrefresh(_ : RefresherEvent) { onRefresherrefresh(e : RefresherEvent) {
this.refresherrefresh = true this.refresherrefresh = true
console.log("onRefresherrefresh--------------下拉刷新触发") console.log("onRefresherrefresh--------------下拉刷新触发")
this.refresherrefreshTest = e
this.refresherTriggered = true this.refresherTriggered = true
this.refresherrefreshTimes++ this.refresherrefreshTimes++
setTimeout(() => { setTimeout(() => {
this.refresherTriggered = false this.refresherTriggered = false
}, 1500) }, 1500)
}, },
onRefresherabort(_ : RefresherEvent) { onRefresherabort(e : RefresherEvent) {
console.log("onRefresherabort------下拉刷新被中止") console.log("onRefresherabort------下拉刷新被中止")
this.onRefresherabortTest = e
}, },
onRefresherrestore(_ : RefresherEvent) { onRefresherrestore(e : RefresherEvent) {
this.refresherrefresh = false this.refresherrefresh = false
console.log("onRefresherrestore------下拉刷新被复位") console.log("onRefresherrestore------下拉刷新被复位")
this.onRefresherrestoreTest = e
}, },
onRefresherpulling(e : RefresherEvent) { onRefresherpulling(e : RefresherEvent) {
console.log("onRefresherpulling------拉刷新控件被下拉-dy=" + e.detail.dy) console.log("onRefresherpulling------拉刷新控件被下拉-dy=" + e.detail.dy)
this.onRefresherpullingTest = e
}, },
onScrolltolower(e : ScrollToLowerEvent) { onScrolltolower(e : ScrollToLowerEvent) {
console.log("onScrolltolower 滚动到底部-----" + e.detail.direction) console.log("onScrolltolower 滚动到底部-----" + e.detail.direction)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册