提交 bca57a74 编写于 作者: H hdx

feat(nodes-info): 补充子组件的 mounted 生命周期测试

上级 b54f8fe6
<template>
<view class="selector-query-child-view">
<text class="selector-query-child-text">selector-query-child</text>
</view>
</template>
<script>
export default {
data() {
return {
top: 0
}
},
mounted() {
uni.createSelectorQuery().in(this).select('.selector-query-child-view').boundingClientRect().exec((ret) => {
if (ret.length == 1) {
const nodeInfo = ret[0] as NodeInfo;
this.top = nodeInfo.top!
}
})
}
}
</script>
<style>
.selector-query-child-view {
margin-top: 15px;
}
</style>
......@@ -54,6 +54,11 @@ describe('nodes-info', () => {
expect(Math.round(nodeInfo2.width)).toBe(RECT_WIDTH)
expect(Math.round(nodeInfo2.height)).toBe(RECT_HEIGHT)
})
it('get-node-info-child', async () => {
const child = await page.$('.node-child')
const childData = await child.data()
expect(childData.top > 100).toBe(true)
})
// #ifdef APP
//检测onResize获取BoundingClientRect信息是否有效
......
......@@ -34,11 +34,14 @@
<text class="node-info-item-v">{{nodeInfo.height}}</text>
</view>
</view>
<node-child class="node-child"></node-child>
</view>
</view>
</template>
<script>
import nodeChild from './nodes-info-child.uvue'
type NodeInfoType = {
left : number | null,
top : number | null,
......@@ -49,6 +52,9 @@
}
export default {
components: {
nodeChild
},
data() {
return {
title: 'createSelectorQuery',
......@@ -71,7 +77,7 @@
},
methods: {
// 仅用于自动化测试
getRootNodeInfo(selector: string) {
getRootNodeInfo(selector : string) {
uni.createSelectorQuery().select(selector).boundingClientRect().exec((ret) => {
if (ret.length == 1) {
const nodeInfo = ret[0] as NodeInfo;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册