From 3ed205f77f18530533c11c9f4179188a3e3b7e87 Mon Sep 17 00:00:00 2001 From: hdx Date: Fri, 6 Dec 2024 14:42:58 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=BF=AE=E6=AD=A3=20getBoundingClientR?= =?UTF-8?q?ectAsync?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../element-get-bounding-client-rect-async.test.js | 11 ++++++++--- .../element-get-bounding-client-rect-async.uvue | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pages/API/element-get-bounding-client-rect-async/element-get-bounding-client-rect-async.test.js b/pages/API/element-get-bounding-client-rect-async/element-get-bounding-client-rect-async.test.js index d1b23c01..82b74376 100644 --- a/pages/API/element-get-bounding-client-rect-async/element-get-bounding-client-rect-async.test.js +++ b/pages/API/element-get-bounding-client-rect-async/element-get-bounding-client-rect-async.test.js @@ -12,18 +12,23 @@ describe('element-get-bounding-client-rect-async', () => { await page.waitFor(500) }) it('getBoundingClientRectSync', async () => { - await invokeGetBoundingClientRect('getBoundingClientRectAsync', 'rectInfo'); + await invokeGetBoundingClientRect(page, 'getBoundingClientRectAsync', 'rectInfo'); }) }) -async function invokeGetBoundingClientRect(methodName, dataName) { +async function invokeGetBoundingClientRect(page, methodName, dataName) { await page.callMethod(methodName); await page.waitFor(50) const data = await page.data() - const width = uni.getWindowInfo().windowWidth + const systemInfo = await program.systemInfo(); + const width = systemInfo.screenWidth const rectInfo = data[dataName] + + console.log('width', width); + console.log('rectInfo', rectInfo); + expect(Math.round(rectInfo.x)).toBe(RECT_X) expect(Math.round(rectInfo.y) > 90).toBe(true) expect(Math.round(rectInfo.width)).toBe(width - 15 * 2) diff --git a/pages/API/element-get-bounding-client-rect-async/element-get-bounding-client-rect-async.uvue b/pages/API/element-get-bounding-client-rect-async/element-get-bounding-client-rect-async.uvue index 2f93d91a..de755f52 100644 --- a/pages/API/element-get-bounding-client-rect-async/element-get-bounding-client-rect-async.uvue +++ b/pages/API/element-get-bounding-client-rect-async/element-get-bounding-client-rect-async.uvue @@ -3,7 +3,7 @@ - + -- GitLab