diff --git a/pages/component/general-attribute/general-attribute.test.js b/pages/component/general-attribute/general-attribute.test.js index 5ca39ce22fc6f09c4edc0f34ba505bdcb39b7838..540b3037940a5d836f8557dc410fd59b49fd1682 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 136edb756154babb61dfebf933d58d36ac280ddb..923513cc5b141914d415a13a9fd0b1c554a42074 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 {