提交 118070d5 编写于 作者: H hdx

nodes-info: 新增 根节点测试例

上级 87ca7eb1
...@@ -10,6 +10,14 @@ describe('nodes-info', () => { ...@@ -10,6 +10,14 @@ describe('nodes-info', () => {
page = await program.reLaunch(PAGE_PATH) page = await program.reLaunch(PAGE_PATH)
await page.waitFor(500) await page.waitFor(500)
}) })
it('get-root-node-info', async () => {
const page = await program.currentPage()
await page.callMethod('getRootNodeInfo')
await page.waitFor(100)
const data = await page.data()
expect(data.rootNodeInfo != null).toBe(true)
})
it('get-node-info', async () => { it('get-node-info', async () => {
const btnGetNodeInfo = await page.$('.btn-get-node-info') const btnGetNodeInfo = await page.$('.btn-get-node-info')
......
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
return { return {
title: 'createSelectorQuery', title: 'createSelectorQuery',
nodeInfoList: [] as NodeInfoType[], nodeInfoList: [] as NodeInfoType[],
// 仅用于自动化测试
rootNodeInfo: null as NodeInfoType | null,
//供自动化测试使用 //供自动化测试使用
// resizeRectValid: false // resizeRectValid: false
} }
...@@ -68,6 +70,23 @@ ...@@ -68,6 +70,23 @@
} */ } */
}, },
methods: { methods: {
// 仅用于自动化测试
getRootNodeInfo() {
uni.createSelectorQuery().select('.page').boundingClientRect().exec((ret) => {
if (ret.length == 1) {
const nodeInfo = ret[0] as NodeInfo;
const nodeType = {
left: nodeInfo.left,
top: nodeInfo.top,
right: nodeInfo.right,
bottom: nodeInfo.bottom,
width: nodeInfo.width,
height: nodeInfo.height,
} as NodeInfoType;
this.rootNodeInfo = nodeType
}
})
},
getNodeInfo() { getNodeInfo() {
uni.createSelectorQuery().select('.rect1').boundingClientRect().exec((ret) => { uni.createSelectorQuery().select('.rect1').boundingClientRect().exec((ret) => {
this.nodeInfoList.length = 0 this.nodeInfoList.length = 0
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册