From 4b26b2ac7edc84db274016b8b291249c73feabbc Mon Sep 17 00:00:00 2001 From: Anne_LXM Date: Mon, 17 Jun 2024 21:15:59 +0800 Subject: [PATCH] =?UTF-8?q?test(list-view/scroll-view):=20=E5=AE=89?= =?UTF-8?q?=E5=8D=93=E7=AB=AF=E5=B7=AE=E5=BC=82=E8=B0=83=E6=95=B4=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/list-view/list-view.test.js | 8 +++++--- .../scroll-view/scroll-view-refresher.test.js | 1 + pages/component/scroll-view/scroll-view.test.js | 11 ++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pages/component/list-view/list-view.test.js b/pages/component/list-view/list-view.test.js index 236f8c70..faac5e12 100644 --- a/pages/component/list-view/list-view.test.js +++ b/pages/component/list-view/list-view.test.js @@ -43,14 +43,16 @@ describe('component-native-list-view', () => { const scrollDetail = await page.data('scrollDetailTest') console.log('scrollDetailTest:', scrollDetail) expect(scrollDetail.scrollLeft).toBe(0) - expect(scrollDetail.scrollTop).toBe(300) + // 在安卓端差异 299.8095 + expect([300, 299.8095]).toContain(scrollDetail.scrollTop); expect(scrollDetail.scrollHeight).toBeGreaterThan(0) // 在安卓端 "scrollWidth":0 if(!process.env.UNI_UTS_PLATFORM.startsWith('app-android')){ expect(scrollDetail.scrollWidth).toBeGreaterThan(0) } expect(scrollDetail.deltaX).toBe(0) - expect(scrollDetail.deltaY).toBe(300) + // 在安卓端差异 299.8095 + expect([300, 299.8095]).toContain(scrollDetail.deltaY); } expect(await page.data('isScrollTest')).toBe('scroll:Success') }) @@ -89,7 +91,7 @@ describe('component-native-list-view', () => { expect(endDetail.scrollTop).toBeGreaterThan(0) expect(endDetail.scrollHeight).toBeGreaterThan(0) // 在安卓端 "scrollWidth":0 - expect(endDetail.scrollWidth).toBeGreaterThan(0) + // expect(endDetail.scrollWidth).toBeGreaterThan(0) }) if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) { diff --git a/pages/component/scroll-view/scroll-view-refresher.test.js b/pages/component/scroll-view/scroll-view-refresher.test.js index cc537975..7f24cc76 100644 --- a/pages/component/scroll-view/scroll-view-refresher.test.js +++ b/pages/component/scroll-view/scroll-view-refresher.test.js @@ -49,6 +49,7 @@ describe('component-native-scroll-view-refresher', () => { await page.waitFor(1500) // 下拉刷新被中止,在iOS不触发@refresherabort事件 if(process.env.UNI_UTS_PLATFORM.startsWith('app-android')){ + console.log('onRefresherabortTest',await page.data('onRefresherabortTest')) expect(await page.data('onRefresherabortTest')).toBe('refresherabort:Success') } }); diff --git a/pages/component/scroll-view/scroll-view.test.js b/pages/component/scroll-view/scroll-view.test.js index bdd133b2..17fe1ee1 100644 --- a/pages/component/scroll-view/scroll-view.test.js +++ b/pages/component/scroll-view/scroll-view.test.js @@ -27,9 +27,7 @@ describe('component-native-scroll-view', () => { console.log('topScrollDetail:', topScrollDetail) expect(topScrollDetail.scrollLeft).toBe(0) // Android 差异scrollTop:99.809525 - if(!process.env.uniTestPlatformInfo.startsWith('android')){ - expect(topScrollDetail.scrollTop).toBe(100) - } + expect([100, 99.809525]).toContain(topScrollDetail.scrollTop); expect(topScrollDetail.scrollHeight).toBeGreaterThan(0) expect(topScrollDetail.scrollWidth).toBeGreaterThan(0) expect(topScrollDetail.deltaX).toBe(0) @@ -47,13 +45,12 @@ describe('component-native-scroll-view', () => { const leftScrollDetail = await page.data('scrollDetailTest') console.log('leftScrollDetail:', leftScrollDetail) // Android 差异scrollLeft:219.80952 - if(!process.env.uniTestPlatformInfo.startsWith('android')){ - expect(leftScrollDetail.scrollLeft).toBe(220) - } + expect([220, 219.80952]).toContain(leftScrollDetail.scrollLeft); expect(leftScrollDetail.scrollTop).toBe(0) expect(leftScrollDetail.scrollHeight).toBeGreaterThan(0) expect(leftScrollDetail.scrollWidth).toBeGreaterThan(0) - expect(leftScrollDetail.deltaX).toBe(-100) + // 在安卓差异 -99.809525 + expect([-100, -99.809525]).toContain(leftScrollDetail.deltaX); expect(leftScrollDetail.deltaY).toBe(0) } expect(await page.data('isScrollTest')).toBe('scroll:Success') -- GitLab