From 1be31cee06538daf16daa292bb315cf41d0f39e3 Mon Sep 17 00:00:00 2001 From: yinjiacheng Date: Wed, 13 Mar 2024 19:52:23 +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 | 13 +++++++++++++ pages/component/text/text-props.uvue | 13 ++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/pages/component/text/text-props.test.js b/pages/component/text/text-props.test.js index 8c60a266..d82b503e 100644 --- a/pages/component/text/text-props.test.js +++ b/pages/component/text/text-props.test.js @@ -13,12 +13,25 @@ describe('text-props', () => { }) it('empty text', async () => { + await page.setData({ + autoTest: true + }) const element = await page.$('#empty-text') if (element != null) { const { width, height } = await element.size() expect(width).toBe(0) expect(height).toBe(0) } + page.callMethod("setTextEmpty") + const element2 = await page.$('#empty-text2') + if (element2 != null) { + const { width, height } = await element2.size() + expect(width).toBe(0) + expect(height).toBe(0) + } + await page.setData({ + autoTest: false + }) }) if (process.env.uniTestPlatformInfo.indexOf('web') > -1) { diff --git a/pages/component/text/text-props.uvue b/pages/component/text/text-props.uvue index c6093576..5bb4403f 100644 --- a/pages/component/text/text-props.uvue +++ b/pages/component/text/text-props.uvue @@ -96,10 +96,12 @@ hello uni-app x - + - + + test + @@ -112,12 +114,17 @@ export default { multiLineText: 'HBuilderX,轻巧、极速,极客编辑器;uni-app x,终极跨平台方案;uts,大一统语言;HBuilderX,轻巧、极速,极客编辑器;uni-app x,终极跨平台方案;uts,大一统语言', singleLineText: 'uni-app x,终极跨平台方案', + // 自动化测试 + autoTest: false } }, methods: { // 自动化测试 setTextNested() { - (this.$refs["text-nested"] as UniTextElement).value = "二级节点文字红色且背景色黄色"; + (this.$refs["text-nested"] as UniElement).setAttribute("value", "二级节点文字红色且背景色黄色"); + }, + setTextEmpty() { + (this.$refs["empty-text2"] as UniElement).setAttribute("value", ""); } } } -- GitLab