diff --git a/pages/component/text/text-props.test.js b/pages/component/text/text-props.test.js index d82b503e3c7de9a51456bb43fe64263f2906e927..7956e9467710c89784a33c47608d5fea91d46c7b 100644 --- a/pages/component/text/text-props.test.js +++ b/pages/component/text/text-props.test.js @@ -22,7 +22,8 @@ describe('text-props', () => { expect(width).toBe(0) expect(height).toBe(0) } - page.callMethod("setTextEmpty") + await page.callMethod("setTextEmpty") + await page.waitFor(100) const element2 = await page.$('#empty-text2') if (element2 != null) { const { width, height } = await element2.size() @@ -34,15 +35,18 @@ describe('text-props', () => { }) }) - if (process.env.uniTestPlatformInfo.indexOf('web') > -1) { - return - } - it('text nested', async () => { - page.callMethod("setTextNested") + await page.setData({ + autoTest: true + }) + await page.callMethod("setTextNested") + await page.waitFor(100) const element = await page.$('#text-nested') if (element != null) { - expect(await element.text()).toBe("二级节点文字红色且背景色黄色") + expect(await element.text()).toBe("修改三级节点") } + await page.setData({ + autoTest: false + }) }) }) diff --git a/pages/component/text/text-props.uvue b/pages/component/text/text-props.uvue index 5bb4403fb196155c67ab1a232e856799aa727832..2caa46dd437d2e2f728911031e5fe4ff3662410a 100644 --- a/pages/component/text/text-props.uvue +++ b/pages/component/text/text-props.uvue @@ -78,7 +78,7 @@ 一级节点黑色 - 二级节点红色且背景色黄色 三级节点不继承二级的颜色 @@ -96,11 +96,20 @@ hello uni-app x - - - - - test + + + + + + {{emptyText}} + + 一级节点 + 二级节点 + {{nestedText}} + + @@ -115,16 +124,18 @@ export default { 'HBuilderX,轻巧、极速,极客编辑器;uni-app x,终极跨平台方案;uts,大一统语言;HBuilderX,轻巧、极速,极客编辑器;uni-app x,终极跨平台方案;uts,大一统语言', singleLineText: 'uni-app x,终极跨平台方案', // 自动化测试 - autoTest: false + autoTest: false, + nestedText: '三级节点', + emptyText: 'empty' } }, methods: { // 自动化测试 setTextNested() { - (this.$refs["text-nested"] as UniElement).setAttribute("value", "二级节点文字红色且背景色黄色"); + this.nestedText = "修改三级节点"; }, setTextEmpty() { - (this.$refs["empty-text2"] as UniElement).setAttribute("value", ""); + this.emptyText = ""; } } }