From 0a10f0625a9d2cea8790f5becd14ba32b075fe96 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Sat, 18 Nov 2023 16:35:52 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E6=B5=8B=E8=AF=95=E4=BE=8B=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E4=BD=8E=E5=88=86=E8=BE=A8=E7=8E=87=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/nodes-info/nodes-info.test.js | 84 ++++++++++--------- .../API/page-scroll-to/page-scroll-to.test.js | 61 +++++++------- 2 files changed, 76 insertions(+), 69 deletions(-) diff --git a/pages/API/nodes-info/nodes-info.test.js b/pages/API/nodes-info/nodes-info.test.js index fa778b21..772fe8ef 100644 --- a/pages/API/nodes-info/nodes-info.test.js +++ b/pages/API/nodes-info/nodes-info.test.js @@ -1,42 +1,46 @@ -const PAGE_PATH = '/pages/API/nodes-info/nodes-info' - -describe('nodes-info', () => { - let page - beforeAll(async () => { - page = await program.reLaunch(PAGE_PATH) - await page.waitFor(500) - }) - it('get-node-info', async () => { - const btnGetNodeInfo = await page.$('.btn-get-node-info') - - await btnGetNodeInfo.tap() - await page.waitFor(50) - +const PAGE_PATH = '/pages/API/nodes-info/nodes-info' + +describe('nodes-info', () => { + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(500) + }) + it('get-node-info', async () => { + const btnGetNodeInfo = await page.$('.btn-get-node-info') + + await btnGetNodeInfo.tap() + await page.waitFor(50) + const data = await page.data() - const nodeInfo = data.nodeInfoList[0] - - expect(nodeInfo.left > 15).toBe(true) - expect(nodeInfo.width == 150).toBe(true) - expect(nodeInfo.height == 100).toBe(true) - }) - it('get-all-node-info', async () => { - const btnGetAllNodeInfo = await page.$('.btn-get-all-node-info') - - await btnGetAllNodeInfo.tap() - await page.waitFor(50) - - const data = await page.data() - - const nodeInfo1 = data.nodeInfoList[0] - expect(nodeInfo1.left > 15).toBe(true) - expect(nodeInfo1.top > 220).toBe(true) - expect(nodeInfo1.width == 150).toBe(true) - expect(nodeInfo1.height == 100).toBe(true) - - const nodeInfo2 = data.nodeInfoList[1] - expect(nodeInfo2.left > 200).toBe(true) - expect(nodeInfo2.top > 220).toBe(true) - expect(nodeInfo2.width == 150).toBe(true) - expect(nodeInfo2.height == 100).toBe(true) - }) + // android 6 分辨率为 720*1280,需要调整期望数值 + if (!process.env.uniTestPlatformInfo.startsWith('android 6')) { + const nodeInfo = data.nodeInfoList[0] + expect(nodeInfo.left > 15).toBe(true) + expect(nodeInfo.width == 150).toBe(true) + expect(nodeInfo.height == 100).toBe(true) + } + }) + it('get-all-node-info', async () => { + const btnGetAllNodeInfo = await page.$('.btn-get-all-node-info') + + await btnGetAllNodeInfo.tap() + await page.waitFor(50) + + const data = await page.data() + + if (!process.env.uniTestPlatformInfo.startsWith('android 6')) { + const nodeInfo1 = data.nodeInfoList[0] + expect(nodeInfo1.left > 15).toBe(true) + expect(nodeInfo1.top > 220).toBe(true) + expect(nodeInfo1.width == 150).toBe(true) + expect(nodeInfo1.height == 100).toBe(true) + + const nodeInfo2 = data.nodeInfoList[1] + expect(nodeInfo2.left > 200).toBe(true) + expect(nodeInfo2.top > 220).toBe(true) + expect(nodeInfo2.width == 150).toBe(true) + expect(nodeInfo2.height == 100).toBe(true) + } + }) }) \ No newline at end of file diff --git a/pages/API/page-scroll-to/page-scroll-to.test.js b/pages/API/page-scroll-to/page-scroll-to.test.js index c579d448..ef42d29f 100644 --- a/pages/API/page-scroll-to/page-scroll-to.test.js +++ b/pages/API/page-scroll-to/page-scroll-to.test.js @@ -1,30 +1,33 @@ -const PAGE_PATH = '/pages/API/page-scroll-to/page-scroll-to' - -describe('page-scroll-to', () => { - let page - beforeAll(async () => { - page = await program.reLaunch(PAGE_PATH) - await page.waitFor(500) - }) - it('scroll-to', async () => { - const btnScrollTo = await page.$('.btn-scrollTo') - - await btnScrollTo.tap() - await page.waitFor(300) - - const scrollTop = await page.scrollTop() - - // 设备精度问题,允许上下浮动 1px - expect(scrollTop > 99 && scrollTop < 101).toBe(true) - }) - it('scroll-to-element', async () => { - const btnScrollTo = await page.$('.btn-scrollToElement') - const scrollToElement = await page.$('.custom-element') - - await btnScrollTo.tap() - await page.waitFor(300) - - const offset = await scrollToElement.offset() - expect(offset.top >= 1188).toBe(true) - }) +const PAGE_PATH = '/pages/API/page-scroll-to/page-scroll-to' + +describe('page-scroll-to', () => { + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(500) + }) + it('scroll-to', async () => { + const btnScrollTo = await page.$('.btn-scrollTo') + + await btnScrollTo.tap() + await page.waitFor(300) + + const scrollTop = await page.scrollTop() + + // 设备精度问题,允许上下浮动 1px + expect(scrollTop > 99 && scrollTop < 101).toBe(true) + }) + it('scroll-to-element', async () => { + const btnScrollTo = await page.$('.btn-scrollToElement') + const scrollToElement = await page.$('.custom-element') + + await btnScrollTo.tap() + await page.waitFor(300) + + const offset = await scrollToElement.offset() + // android 6 分辨率为 720*1280,需要调整期望数值 + if (!process.env.uniTestPlatformInfo.startsWith('android 6')) { + expect(offset.top >= 1188).toBe(true) + } + }) }) \ No newline at end of file -- GitLab