From b9bb64e7b0dec92f3e08f3cdcc10e819d081eaa9 Mon Sep 17 00:00:00 2001 From: hdx Date: Fri, 24 Nov 2023 15:23:32 +0800 Subject: [PATCH] =?UTF-8?q?node-info:=20=E8=B0=83=E6=95=B4=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=8C=96=E6=B5=8B=E8=AF=95=EF=BC=8C=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E9=87=87=E7=94=A8=E5=9B=9B=E8=88=8D=E4=BA=94=E5=85=A5=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E8=A7=84=E9=81=BF=E7=B2=BE=E5=BA=A6=E7=9A=84?= =?UTF-8?q?=E5=B7=AE=E5=BC=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/nodes-info/nodes-info.test.js | 27 +++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/pages/API/nodes-info/nodes-info.test.js b/pages/API/nodes-info/nodes-info.test.js index 772fe8ef..615fd57a 100644 --- a/pages/API/nodes-info/nodes-info.test.js +++ b/pages/API/nodes-info/nodes-info.test.js @@ -1,4 +1,8 @@ -const PAGE_PATH = '/pages/API/nodes-info/nodes-info' +const PAGE_PATH = '/pages/API/nodes-info/nodes-info' + +const RECT_LEFT = 15; +const RECT_WIDTH = 150; +const RECT_HEIGHT = 100; describe('nodes-info', () => { let page @@ -13,12 +17,13 @@ describe('nodes-info', () => { await page.waitFor(50) const data = await page.data() - // android 6 分辨率为 720*1280,需要调整期望数值 + + // TODO 和浏览器的计算存在差异 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) + expect(Math.round(nodeInfo.left)).toBe(RECT_LEFT) + expect(Math.round(nodeInfo.width)).toBe(RECT_WIDTH) + expect(Math.round(nodeInfo.height)).toBe(RECT_HEIGHT) } }) it('get-all-node-info', async () => { @@ -31,16 +36,16 @@ describe('nodes-info', () => { if (!process.env.uniTestPlatformInfo.startsWith('android 6')) { const nodeInfo1 = data.nodeInfoList[0] - expect(nodeInfo1.left > 15).toBe(true) + expect(Math.round(nodeInfo1.left)).toBe(RECT_LEFT) expect(nodeInfo1.top > 220).toBe(true) - expect(nodeInfo1.width == 150).toBe(true) - expect(nodeInfo1.height == 100).toBe(true) + expect(Math.round(nodeInfo1.width)).toBe(RECT_WIDTH) + expect(Math.round(nodeInfo1.height)).toBe(RECT_HEIGHT) 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) + expect(Math.round(nodeInfo2.width)).toBe(RECT_WIDTH) + expect(Math.round(nodeInfo2.height)).toBe(RECT_HEIGHT) } }) -}) \ No newline at end of file +}) -- GitLab