From 0e1fe44295c52fed8b1beb329104b260a7f8d214 Mon Sep 17 00:00:00 2001 From: shutao Date: Thu, 21 Sep 2023 15:19:10 +0800 Subject: [PATCH] add scroll-view-refresher.test.js --- pages/component/list-view/list-view.test.js | 10 ++++++++++ pages/component/list-view/list-view.uvue | 9 +++++++-- .../scroll-view/scroll-view-refresher.test.js | 19 +++++++++++++++++++ .../scroll-view/scroll-view-refresher.uvue | 9 ++++++--- 4 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 pages/component/scroll-view/scroll-view-refresher.test.js diff --git a/pages/component/list-view/list-view.test.js b/pages/component/list-view/list-view.test.js index 23fbd072..1b31fc1d 100644 --- a/pages/component/list-view/list-view.test.js +++ b/pages/component/list-view/list-view.test.js @@ -36,6 +36,16 @@ describe('component-native-list-view', () => { expect(scrollTop-690).toBeGreaterThanOrEqual(0) }) + //检测下拉刷新 + it('check_refresher', async () => { + await page.setData({ + refresher_enabled_boolean: true, + refresher_triggered_boolean: true + }) + await page.waitFor(2000) + expect(await page.data('refresherrefresh')).toBe(true) + }) + //检测横向可滚动区域 it('check_scroll_width', async () => { await page.callMethod('change_scroll_y_boolean', false) diff --git a/pages/component/list-view/list-view.uvue b/pages/component/list-view/list-view.uvue index b1544f2a..de55e38f 100644 --- a/pages/component/list-view/list-view.uvue +++ b/pages/component/list-view/list-view.uvue @@ -17,7 +17,8 @@ refresher_background_input: "#FFF", scrollData: [] as Array, size_enum: [{ "value": 0, "name": "item---0" }, { "value": 3, "name": "item---3" }] as ItemType[], - scrollIntoView: "" + scrollIntoView: "", + refresherrefresh: false } }, onLoad() { @@ -38,12 +39,16 @@ list_view_refresherpulling() { console.log("自定义下拉刷新控件被下拉") }, list_view_refresherrefresh() { console.log("自定义下拉刷新被触发 ") + this.refresherrefresh = true this.refresher_triggered_boolean = true setTimeout(function(){ this.refresher_triggered_boolean = false }, 1500) }, - list_view_refresherrestore() { console.log("自定义下拉刷新被复位") }, + list_view_refresherrestore() { + this.refresherrefresh = false + console.log("自定义下拉刷新被复位") + }, list_view_refresherabort() { console.log("自定义下拉刷新被中止") }, list_view_scrolltoupper(e:ScrollToUpperEvent) { console.log("滚动到顶部/左边,会触发 scrolltoupper 事件 direction="+e.detail.direction) }, list_view_scrolltolower(e:ScrollToLowerEvent) { console.log("滚动到底部/右边,会触发 scrolltolower 事件 direction="+e.detail.direction) }, diff --git a/pages/component/scroll-view/scroll-view-refresher.test.js b/pages/component/scroll-view/scroll-view-refresher.test.js new file mode 100644 index 00000000..cc050d66 --- /dev/null +++ b/pages/component/scroll-view/scroll-view-refresher.test.js @@ -0,0 +1,19 @@ +// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ + +describe('test title', () => { + + let page; + beforeAll(async () => { + page = await program.reLaunch('/pages/component/scroll-view/scroll-view-refresher'); + await page.waitFor(300); + }); + + + it('check_refresher', async () => { + await page.setData({ + refresherTriggered: true + }) + await page.waitFor(2000); + expect(await page.data('refresherrefresh')).toBe(true) + }); +}); diff --git a/pages/component/scroll-view/scroll-view-refresher.uvue b/pages/component/scroll-view/scroll-view-refresher.uvue index 4f928a80..8d26c19e 100644 --- a/pages/component/scroll-view/scroll-view-refresher.uvue +++ b/pages/component/scroll-view/scroll-view-refresher.uvue @@ -18,7 +18,8 @@ data() { return { scrollData: [] as Array , - refresherTriggered: false + refresherTriggered: false, + refresherrefresh: false }; }, onLoad() { @@ -30,7 +31,8 @@ }, methods: { - onRefresherrefresh(_: RefresherEvent) { + onRefresherrefresh(_: RefresherEvent) { + this.refresherrefresh = true console.log("onRefresherrefresh--------------下拉刷新触发") this.refresherTriggered = true setTimeout(function(){ @@ -41,7 +43,8 @@ onRefresherabort(_: RefresherEvent) { console.log("onRefresherabort------下拉刷新被中止") }, - onRefresherrestore(_: RefresherEvent) { + onRefresherrestore(_: RefresherEvent) { + this.refresherrefresh = false console.log("onRefresherrestore------下拉刷新被复位") }, onRefresherpulling(e: RefresherEvent) { -- GitLab