From d2d25f5427611d06eebcdaeb0b9211a0e66cc280 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Wed, 30 Aug 2023 16:11:09 +0800 Subject: [PATCH] test: ref --- .../general-attribute.test.js | 16 +++++-- .../general-attribute/general-attribute.uvue | 47 ++++++++++++++++--- 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/pages/component/general-attribute/general-attribute.test.js b/pages/component/general-attribute/general-attribute.test.js index 5ca39ce2..540b3037 100644 --- a/pages/component/general-attribute/general-attribute.test.js +++ b/pages/component/general-attribute/general-attribute.test.js @@ -7,14 +7,20 @@ describe('general attribute', () => { page = await program.navigateTo(PAGE_PATH) await page.waitFor(1000) }) - it('screenshot', async () => { - const image = await program.screenshot() - expect(image).toMatchImageSnapshot() - }) + it("class & style", async () => { + const image = await program.screenshot(); + expect(image).toMatchImageSnapshot(); + }); it('validateGeneralAttributes', async () => { - const button = await page.$('.btn') + const button = await page.$(".btn-style"); await button.tap() const btnInner = await page.$('.btn-inner') expect(await btnInner.text()).toBe('基础属性验证成功') }) + it("ref", async () => { + const button = await page.$(".btn-ref"); + await button.tap(); + const image = await program.screenshot(); + expect(image).toMatchImageSnapshot(); + }); }) diff --git a/pages/component/general-attribute/general-attribute.uvue b/pages/component/general-attribute/general-attribute.uvue index 136edb75..923513cc 100644 --- a/pages/component/general-attribute/general-attribute.uvue +++ b/pages/component/general-attribute/general-attribute.uvue @@ -4,16 +4,43 @@ - - - + + + id: {{ generalId }} + class: {{ generalClass }} + name: {{ generalName }} + title: {{ generalTitle }} + data-test: {{ generalData }} + style: {{ generalStyle }} + + {{ validateGeneralAttrText }} + + 通过 ref 修改高度 + 按下 50 ms 后背景变红 抬起 400 ms 后背景恢复 - + 按下 1000 ms 后背景变红 抬起 1000 ms 后背景恢复 @@ -34,6 +61,7 @@ export default { generalName: 'general-name', generalTitle: 'general-title', generalData: 'general-data', + generalStyle: 'background-color: aqua', validateGeneralAttrText: '验证基础属性', hoverClass: 'hover-class', validateViewAttrText: '验证 view 属性', @@ -69,6 +97,10 @@ export default { } this.validateGeneralAttrText = '基础属性验证成功' }, + changeHeight(){ + const generalTarget = this.$refs.get('general-target') as INode + generalTarget.style.set('height', '200px') + } }, } @@ -86,9 +118,10 @@ export default { color: #fff; } .general-class { - margin: 20px 0 0 50px; - width: 240px; - height: 100px; + margin-left: 40px; + padding: 10px; + width: 260px; + height: 160px; background-color: antiquewhite; } .view-class { -- GitLab