diff --git a/pages/component/input/input.test.js b/pages/component/input/input.test.js index 2809091833eff78bed647b327ab642ec921e1ac2..1bfa2155607b9da412d10aa67e19af83b9956276 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 f6d0ca1935756b55ebbba9718eaf9135291df180..91017ae21f954bd22687c53d7af81d701cbebbb6 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 },