提交 b1f21689 编写于 作者: 张磊

add textarea.test.js

上级 89e0b53d
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe('component-native-textarea', () => {
let page;
let textarea;
beforeAll(async () => {
page = await program.reLaunch("/pages/component/textarea/textarea");
await page.waitFor(3000);
textarea = await page.$('.uni-textarea');
await page.waitFor(1000);
});
it('focus', async () => {
expect(await textarea.property("focus")).toBe(false)
await page.setData({
focus_boolean: true,
})
await page.waitFor(500)
expect(await textarea.property("focus")).toBe(true)
});
it("auto-height", async () => {
await page.setData({
auto_height_boolean: true
})
await page.waitFor(500)
// 原始高度
var {
width,
height
} = await textarea.size()
expect(height).toBeGreaterThanOrEqual(150)
await page.waitFor(500)
// 只有一行的高度
await page.setData({
maxlength: 3,
})
await page.waitFor(500)
await page.setData({
default_value: "第一行\n第二行\n第三行",
})
await page.waitFor(500)
var {
width,
height
} = await textarea.size()
expect(height).toBeLessThanOrEqual(50)
// 四行的高度
await page.setData({
maxlength: -1,
})
await page.waitFor(500)
await page.setData({
default_value: "第一行\n第二行\n第三行\n第四行",
})
await page.waitFor(500)
var {
width,
height
} = await textarea.size()
expect(height).toBeLessThanOrEqual(150)
})
it("inputmode", async () => {
const inputmodeEnum = await page.data("inputmode_enum")
for (var i = 0; i < inputmodeEnum.length; i++) {
var x = inputmodeEnum[i]
console.log(x['value'], x['name'])
await page.callMethod("radio_change_inputmode_enum", x['value']);
await page.waitFor(500)
expect(await textarea.property("inputmode")).toEqual(x['name'])
await page.waitFor(500)
}
})
it("confirm-type", async () => {
const inputmodeEnum = await page.data("confirm_type_enum")
for (var i = 0; i < inputmodeEnum.length; i++) {
var x = inputmodeEnum[i]
console.log(x['value'], x['name'])
await page.callMethod("radio_change_confirm_type_enum", x['value']);
await page.waitFor(500)
expect(await textarea.property("confirm-type")).toEqual(x['name'])
await page.waitFor(500)
}
})
});
......@@ -9,13 +9,16 @@ export default {
auto_height_boolean: false,
confirm_hold_boolean: false,
focus_boolean: false,
auto_focus_boolean: false,
auto_focus_boolean: false,
default_value:"",
maxlength:-1,
confirm_type_enum: [{"value":0,"name":"send"},{"value":1,"name":"search"},{"value":2,"name":"next"},{"value":3,"name":"go"},{"value":4,"name":"done"}] as ItemType[],
confirm_type_enum_current: 0,
inputmode_enum: [{"value":0,"name":"none"},{"value":1,"name":"text"},{"value":2,"name":"decimal"},{"value":3,"name":"numeric"},{"value":4,"name":"tel"},{"value":5,"name":"search"},{"value":6,"name":"email"},{"value":7,"name":"url"}] as ItemType[],
inputmode_enum_current: 0
}
},
},
methods: {
textarea_click() { console.log("组件被点击时触发") },
textarea_touchstart() { console.log("手指触摸动作开始") },
......@@ -45,7 +48,8 @@ export default {
<template>
<view class="main">
<textarea
<textarea
:value="default_value"
class="uni-textarea"
:auto-focus="auto_focus_boolean"
:focus="focus_boolean"
......@@ -55,7 +59,8 @@ export default {
:fixed="fixed_boolean"
:show-confirm-bar="show_confirm_bar_boolean"
:adjust-position="adjust_position_boolean"
:inputmode="inputmode_enum[inputmode_enum_current].name"
:inputmode="inputmode_enum[inputmode_enum_current].name"
:maxlength="maxlength"
@click="textarea_click"
@touchstart="textarea_touchstart"
@touchmove="textarea_touchmove"
......@@ -81,7 +86,8 @@ export default {
:defaultValue="false"
title="键盘弹起时,是否自动上推页面"
@change="change_adjust_position_boolean"
></boolean-data>
></boolean-data>
<!-- #ifdef !APP -->
<boolean-data
:defaultValue="false"
title="是否显示键盘上方带有”完成“按钮那一栏"
......@@ -91,7 +97,8 @@ export default {
:defaultValue="false"
title="如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 true"
@change="change_fixed_boolean"
></boolean-data>
></boolean-data>
<!-- #endif -->
<boolean-data
:defaultValue="false"
title="是否自动增高,设置auto-height时,style.height不生效"
......@@ -103,22 +110,22 @@ export default {
@change="change_confirm_hold_boolean"
></boolean-data>
<boolean-data
:defaultValue="false"
:defaultValue="focus_boolean"
title="获取焦点"
@change="change_focus_boolean"
@change="change_focus_boolean" class="textarea-focus"
></boolean-data>
<boolean-data
:defaultValue="false"
title="自动获取焦点"
@change="change_auto_focus_boolean"
></boolean-data>
<enum-data
<enum-data class="textarea-confirm"
:items="confirm_type_enum"
title="设置键盘右下角按钮的文字"
@change="radio_change_confirm_type_enum"
></enum-data>
<enum-data
:items="inputmode_enum"
:items="inputmode_enum" class="textarea-input"
title="是一个枚举属性,它提供了用户在编辑元素或其内容时可能输入的数据类型的提示。在符合条件的高版本webview里,uni-app的 web 和 app-vue 平台中可使用本属性。"
@change="radio_change_inputmode_enum"
></enum-data>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册