From 96f98bb6f4b877e51e760b884737286b392e18a2 Mon Sep 17 00:00:00 2001 From: yinjiacheng Date: Thu, 14 Mar 2024 14:08:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0text=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E5=92=8C=E8=87=AA=E5=8A=A8=E5=8C=96=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/text/text-props.test.js | 18 +++++++++------ pages/component/text/text-props.uvue | 29 +++++++++++++++++-------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/pages/component/text/text-props.test.js b/pages/component/text/text-props.test.js index d82b503e..7956e946 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 5bb4403f..2caa46dd 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 = ""; } } } -- GitLab