From f6a0a744c8b89235e84324be060fef1a7a2bef73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A3=8A?= <1633537611@qq.com> Date: Sat, 23 Sep 2023 13:05:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0input=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/input/input.test.js | 39 ++++++++++++++++++++++++++--- pages/component/input/input.uvue | 11 +++++--- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/pages/component/input/input.test.js b/pages/component/input/input.test.js index 28090918..1bfa2155 100644 --- a/pages/component/input/input.test.js +++ b/pages/component/input/input.test.js @@ -8,25 +8,36 @@ describe('component-native-input', () => { await page.waitFor(3000); }); + it("beforeAllTestScreenshot", async () => { + const image = await program.screenshot({ + fullPage: true + }) + expect(image).toMatchImageSnapshot() + }) // 测试焦点及键盘弹起 it('focus', async () => { const input = await page.$('.uni-input-focus'); expect(await input.property('focus')).toBe(true) + expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(true) await page.setData({ focus: false, }) expect(await input.property('focus')).toBe(false) await page.waitFor(1000) + expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(false) await page.setData({ focus: true, }) expect(await input.property('focus')).toBe(true) await page.waitFor(1000) + expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(true) await page.setData({ focus: false, }) expect(await input.property('focus')).toBe(false) - await page.waitFor(3000) + await page.waitFor(1000) + expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(false) + await page.waitFor(1000) }); // 测试修改value属性 @@ -53,8 +64,13 @@ describe('component-native-input', () => { expect(await input.property('password')).toBe(true) await page.setData({ inputPassword: false, + inputPasswordValue: "inputPasswordValue" }) expect(await input.property('password')).toBe(false) + await page.waitFor(500) + await page.setData({ + inputPassword: true + }) }) // 测试placeholder it("placeholder", async () => { @@ -79,12 +95,12 @@ describe('component-native-input', () => { }) await page.setData({ - inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0;text-align:center;font-size:100px;font-weight:900", + inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0;text-align:center;font-size:44px;font-weight:900", }) expect(await placeholder1.property("placeholder-style")).toEqual({ "backgroundColor": "#00b1c0", "color": "#CC19CC", - "fontSize": "100px", + "fontSize": "44px", "fontWeight": "900", "textAlign": "center" }) @@ -114,4 +130,19 @@ describe('component-native-input', () => { expect(await (await page.$('.uni-input-confirm-go')).property("confirmType")).toEqual("go") expect(await (await page.$('.uni-input-confirm-done')).property("confirmType")).toEqual("done") }) -}); \ No newline at end of file + + it("maxlength", async () => { + const input = await page.$('.uni-input-maxlength'); + await page.setData({ + inputMaxLengthValue: "uni-input-maxlength" + }) + await page.waitFor(500) + }) + + it("afterAllTestScreenshot", async () => { + const image = await program.screenshot({ + fullPage: true + }) + expect(image).toMatchImageSnapshot() + }) +}); diff --git a/pages/component/input/input.uvue b/pages/component/input/input.uvue index f6d0ca19..91017ae2 100644 --- a/pages/component/input/input.uvue +++ b/pages/component/input/input.uvue @@ -36,7 +36,7 @@ 密码输入框 - + @@ -84,7 +84,7 @@ 自动获取焦点 - + @@ -232,10 +232,15 @@ inputPlaceHolderClass: "uni-input-placeholder-class", inputMaxLengthValue:"", onMaxLengthInputValue:"", - inputMaxLengthFocus:false + inputMaxLengthFocus:false, + inputPasswordValue:"", + inputFocusKeyBoardChangeValue:true } }, methods: { + inputFocusKeyBoardChange(e:InputKeyboardHeightChangeEvent) { + this.inputFocusKeyBoardChangeValue = e.detail.height > 50 + }, onMaxLengthInput(event:InputEvent) { this.onMaxLengthInputValue = event.detail.value }, -- GitLab