提交 78f9a5ff 编写于 作者: H hdx

test: 修正 getBoundingClientRectAsync

上级 9da5ab8b
......@@ -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)
......
......@@ -3,7 +3,7 @@
<scroll-view class="page-scroll-view">
<!-- #endif -->
<view class="page" id="page">
<!-- <page-head :title="title"></page-head> -->
<page-head :title="title"></page-head>
<button class="btn btn-get-all-node-info" @click="getBoundingClientRectAsync">getBoundingClientRectAsync</button>
<view id="rect-test" ref="rect-test" class="rect-test"></view>
<view class="rect-info" v-if="rectInfo">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册