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 d1b23c016c67c78173cf912f17732ed167db72e6..82b743764f31c89d5b468de1362baa82e58f48fb 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 2f93d91af5d126b05f273203b242a791b26187f2..de755f52d39b341d112cf4217f6e112e6e451c6a 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 @@ - +