From eb2461add54436457a1d87a8573e6a718e082b77 Mon Sep 17 00:00:00 2001 From: shutao Date: Tue, 23 Jan 2024 15:24:38 +0800 Subject: [PATCH] =?UTF-8?q?update=20nodes-info.test.js=20nodes-info.uvue?= =?UTF-8?q?=20=E8=A1=A5=E5=85=85=E8=87=AA=E5=8A=A8=E5=8C=96=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/API/nodes-info/nodes-info.test.js | 6 ++++++ pages/API/nodes-info/nodes-info.uvue | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pages/API/nodes-info/nodes-info.test.js b/pages/API/nodes-info/nodes-info.test.js index ce8077a7..e9da7c84 100644 --- a/pages/API/nodes-info/nodes-info.test.js +++ b/pages/API/nodes-info/nodes-info.test.js @@ -43,5 +43,11 @@ describe('nodes-info', () => { 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) }) }) diff --git a/pages/API/nodes-info/nodes-info.uvue b/pages/API/nodes-info/nodes-info.uvue index d28b889f..e0a092c0 100644 --- a/pages/API/nodes-info/nodes-info.uvue +++ b/pages/API/nodes-info/nodes-info.uvue @@ -3,7 +3,7 @@ - + @@ -53,6 +53,18 @@ return { title: 'createSelectorQuery', nodeInfoList: [] as NodeInfoType[], + //供自动化测试使用 + resizeRectValid: false + } + }, + onResize() { + //供自动化测试使用 + var rect12Element = uni.getElementById("rect-1-2") + if(rect12Element != null) { + var domRect = rect12Element.getBoundingClientRect() + if(domRect.width > 100) { + this.resizeRectValid = true + } } }, methods: { -- GitLab