提交 f6a0a744 编写于 作者: 张磊

更新input测试

上级 0ce4c494
...@@ -8,25 +8,36 @@ describe('component-native-input', () => { ...@@ -8,25 +8,36 @@ describe('component-native-input', () => {
await page.waitFor(3000); await page.waitFor(3000);
}); });
it("beforeAllTestScreenshot", async () => {
const image = await program.screenshot({
fullPage: true
})
expect(image).toMatchImageSnapshot()
})
// 测试焦点及键盘弹起 // 测试焦点及键盘弹起
it('focus', async () => { it('focus', async () => {
const input = await page.$('.uni-input-focus'); const input = await page.$('.uni-input-focus');
expect(await input.property('focus')).toBe(true) expect(await input.property('focus')).toBe(true)
expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(true)
await page.setData({ await page.setData({
focus: false, focus: false,
}) })
expect(await input.property('focus')).toBe(false) expect(await input.property('focus')).toBe(false)
await page.waitFor(1000) await page.waitFor(1000)
expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(false)
await page.setData({ await page.setData({
focus: true, focus: true,
}) })
expect(await input.property('focus')).toBe(true) expect(await input.property('focus')).toBe(true)
await page.waitFor(1000) await page.waitFor(1000)
expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(true)
await page.setData({ await page.setData({
focus: false, focus: false,
}) })
expect(await input.property('focus')).toBe(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属性 // 测试修改value属性
...@@ -53,8 +64,13 @@ describe('component-native-input', () => { ...@@ -53,8 +64,13 @@ describe('component-native-input', () => {
expect(await input.property('password')).toBe(true) expect(await input.property('password')).toBe(true)
await page.setData({ await page.setData({
inputPassword: false, inputPassword: false,
inputPasswordValue: "inputPasswordValue"
}) })
expect(await input.property('password')).toBe(false) expect(await input.property('password')).toBe(false)
await page.waitFor(500)
await page.setData({
inputPassword: true
})
}) })
// 测试placeholder // 测试placeholder
it("placeholder", async () => { it("placeholder", async () => {
...@@ -79,12 +95,12 @@ describe('component-native-input', () => { ...@@ -79,12 +95,12 @@ describe('component-native-input', () => {
}) })
await page.setData({ 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({ expect(await placeholder1.property("placeholder-style")).toEqual({
"backgroundColor": "#00b1c0", "backgroundColor": "#00b1c0",
"color": "#CC19CC", "color": "#CC19CC",
"fontSize": "100px", "fontSize": "44px",
"fontWeight": "900", "fontWeight": "900",
"textAlign": "center" "textAlign": "center"
}) })
...@@ -114,4 +130,19 @@ describe('component-native-input', () => { ...@@ -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-go')).property("confirmType")).toEqual("go")
expect(await (await page.$('.uni-input-confirm-done')).property("confirmType")).toEqual("done") 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()
})
});
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
<text class="uni-title-text">密码输入框</text> <text class="uni-title-text">密码输入框</text>
</view> </view>
<view class="uni-input-wrapper"> <view class="uni-input-wrapper">
<input class="uni-input uni-input-password" :password="inputPassword" /> <input class="uni-input uni-input-password" :password="inputPassword" :value="inputPasswordValue" />
</view> </view>
</view> </view>
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
<text class="uni-title-text">自动获取焦点</text> <text class="uni-title-text">自动获取焦点</text>
</view> </view>
<view class="uni-input-wrapper"> <view class="uni-input-wrapper">
<input class="uni-input uni-input-focus" :focus="focus"/> <input class="uni-input uni-input-focus" :focus="focus" @keyboardheightchange="inputFocusKeyBoardChange"/>
</view> </view>
</view> </view>
...@@ -232,10 +232,15 @@ ...@@ -232,10 +232,15 @@
inputPlaceHolderClass: "uni-input-placeholder-class", inputPlaceHolderClass: "uni-input-placeholder-class",
inputMaxLengthValue:"", inputMaxLengthValue:"",
onMaxLengthInputValue:"", onMaxLengthInputValue:"",
inputMaxLengthFocus:false inputMaxLengthFocus:false,
inputPasswordValue:"",
inputFocusKeyBoardChangeValue:true
} }
}, },
methods: { methods: {
inputFocusKeyBoardChange(e:InputKeyboardHeightChangeEvent) {
this.inputFocusKeyBoardChangeValue = e.detail.height > 50
},
onMaxLengthInput(event:InputEvent) { onMaxLengthInput(event:InputEvent) {
this.onMaxLengthInputValue = event.detail.value this.onMaxLengthInputValue = event.detail.value
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册