From d40c0162705c0561422c249d419b27074ecad1be Mon Sep 17 00:00:00 2001 From: hdx Date: Tue, 23 Jan 2024 18:01:36 +0800 Subject: [PATCH] =?UTF-8?q?nodes-info-test:=20=E8=B0=83=E6=95=B4=E9=83=A8?= =?UTF-8?q?=E5=88=86=E8=87=AA=E5=8A=A8=E5=8C=96=E6=B5=8B=E8=AF=95=E4=BB=85?= =?UTF-8?q?=E5=9C=A8App=E5=B9=B3=E5=8F=B0=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/nodes-info/nodes-info.test.js | 53 +++++++++++++------------ 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/pages/API/nodes-info/nodes-info.test.js b/pages/API/nodes-info/nodes-info.test.js index e9da7c84..b86f9854 100644 --- a/pages/API/nodes-info/nodes-info.test.js +++ b/pages/API/nodes-info/nodes-info.test.js @@ -1,7 +1,7 @@ -const PAGE_PATH = '/pages/API/nodes-info/nodes-info' - -const RECT_LEFT = 15; -const RECT_WIDTH = 150; +const PAGE_PATH = '/pages/API/nodes-info/nodes-info' + +const RECT_LEFT = 15; +const RECT_WIDTH = 150; const RECT_HEIGHT = 100; describe('nodes-info', () => { @@ -16,12 +16,12 @@ describe('nodes-info', () => { await btnGetNodeInfo.tap() await page.waitFor(50) - const data = await page.data() - + const data = await page.data() + // TODO 和浏览器的计算存在差异 - const nodeInfo = data.nodeInfoList[0] - expect(Math.round(nodeInfo.left)).toBe(RECT_LEFT) - expect(Math.round(nodeInfo.width)).toBe(RECT_WIDTH) + const nodeInfo = data.nodeInfoList[0] + 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 () => { @@ -32,22 +32,25 @@ describe('nodes-info', () => { const data = await page.data() - const nodeInfo1 = data.nodeInfoList[0] - expect(Math.round(nodeInfo1.left)).toBe(RECT_LEFT) - expect(nodeInfo1.top > 220).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 > 180).toBe(true) - expect(nodeInfo2.top > 220).toBe(true) - expect(Math.round(nodeInfo2.width)).toBe(RECT_WIDTH) + const nodeInfo1 = data.nodeInfoList[0] + expect(Math.round(nodeInfo1.left)).toBe(RECT_LEFT) + expect(nodeInfo1.top > 220).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 > 180).toBe(true) + expect(nodeInfo2.top > 220).toBe(true) + expect(Math.round(nodeInfo2.width)).toBe(RECT_WIDTH) expect(Math.round(nodeInfo2.height)).toBe(RECT_HEIGHT) - }) - - //检测onResize获取BoundingClientRect信息是否有效 - it('check_resizeRectValid', async () => { - const resizeRectValid = await page.data('resizeRectValid') - expect(resizeRectValid).toBe(true) }) + + // #ifdef APP + //检测onResize获取BoundingClientRect信息是否有效 + it('check_resizeRectValid', async () => { + const resizeRectValid = await page.data('resizeRectValid') + expect(resizeRectValid).toBe(true) + }) + // #endif + }) -- GitLab