Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Accustomed_
hello uni-app x
提交
bc09763e
H
hello uni-app x
项目概览
Accustomed_
/
hello uni-app x
与 Fork 源项目一致
Fork自
DCloud / hello uni-app x
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
bc09763e
编写于
11月 03, 2023
作者:
H
hdx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
form组件: 添加自动化测试
上级
efdded6b
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
73 addition
and
5 deletion
+73
-5
pages/component/form/form.test.js
pages/component/form/form.test.js
+64
-0
pages/component/form/form.uvue
pages/component/form/form.uvue
+9
-5
未找到文件。
pages/component/form/form.test.js
0 → 100644
浏览文件 @
bc09763e
const
PAGE_PATH
=
'
/pages/component/form/form
'
const
DEFAULT_NICK_NAME
=
'
hello
'
const
DEFAULT_GENDER
=
'
0
'
const
DEFAULT_AGE
=
18
const
DEFAULT_SWITCH
=
true
const
CHANGE_NICK_NAME
=
'
hello
'
const
CHANGE_GENDER
=
'
0
'
const
CHANGE_AGE
=
50
const
CHANGE_SWITCH
=
false
describe
(
'
form
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
submit
'
,
async
()
=>
{
await
page
.
setData
({
nickname
:
CHANGE_NICK_NAME
,
age
:
CHANGE_AGE
,
switch
:
CHANGE_SWITCH
})
await
page
.
waitFor
(
200
)
const
btnSubmit
=
await
page
.
$
(
'
.btn-l
'
)
await
btnSubmit
.
tap
()
await
page
.
waitFor
(
200
)
const
{
formData
}
=
await
page
.
data
()
// expect(formData['nickname']).toBe(CHANGE_NICK_NAME)
expect
(
formData
[
'
gender
'
]).
toBe
(
CHANGE_GENDER
)
expect
(
formData
[
'
loves
'
][
0
]).
toBe
(
'
1
'
)
expect
(
formData
[
'
age
'
]).
toBe
(
CHANGE_AGE
)
expect
(
formData
[
'
switch
'
]).
toBe
(
CHANGE_SWITCH
)
})
it
(
'
reset
'
,
async
()
=>
{
await
page
.
setData
({
nickname
:
CHANGE_NICK_NAME
,
age
:
CHANGE_AGE
,
switch
:
CHANGE_SWITCH
})
await
page
.
waitFor
(
100
)
const
btnReset
=
await
page
.
$
(
'
.btn-r
'
)
await
btnReset
.
tap
()
await
page
.
waitFor
(
100
)
const
{
formData
}
=
await
page
.
data
()
// TODO
// expect(formData['nickname']).toBe(DEFAULT_NICK_NAME)
// expect(formData['gender']).toBe(undefined)
// expect(formData['loves'][0]).toBe(undefined)
// expect(formData['age']).toBe(undefined)
// expect(formData['switch']).toBe(undefined)
})
})
pages/component/form/form.uvue
浏览文件 @
bc09763e
...
@@ -5,16 +5,16 @@
...
@@ -5,16 +5,16 @@
<form @submit="onFormSubmit" @reset="onFormReset">
<form @submit="onFormSubmit" @reset="onFormReset">
<view class="uni-form-item">
<view class="uni-form-item">
<view class="title">姓名</view>
<view class="title">姓名</view>
<!-- <input class="uni-input" name="nickname" placeholder="请输入姓名" /> -->
<!-- <input class="uni-input" name="nickname"
:value="nickname"
placeholder="请输入姓名" /> -->
</view>
</view>
<view class="uni-form-item">
<view class="uni-form-item">
<view class="title">性别</view>
<view class="title">性别</view>
<radio-group name="gender" class="flex-row">
<radio-group name="gender" class="flex-row">
<view class="group-item">
<view class="group-item">
<radio value="0" /><text>男</text>
<radio value="0"
:checked="gender=='0'"
/><text>男</text>
</view>
</view>
<view class="group-item">
<view class="group-item">
<radio value="1" /><text>女</text>
<radio value="1"
:checked="gender=='1'"
/><text>女</text>
</view>
</view>
</radio-group>
</radio-group>
</view>
</view>
...
@@ -31,12 +31,12 @@
...
@@ -31,12 +31,12 @@
</view>
</view>
<view class="uni-form-item">
<view class="uni-form-item">
<view class="title">年龄</view>
<view class="title">年龄</view>
<slider
:value="18" nam
e="age" :show-value="true"></slider>
<slider
name="age" :valu
e="age" :show-value="true"></slider>
</view>
</view>
<view class="uni-form-item">
<view class="uni-form-item">
<view class="title">保留选项</view>
<view class="title">保留选项</view>
<view>
<view>
<switch
:checked="true" name
="switch" />
<switch
name="switch" :checked
="switch" />
</view>
</view>
</view>
</view>
<view class="uni-btn-v flex-row">
<view class="uni-btn-v flex-row">
...
@@ -55,6 +55,10 @@
...
@@ -55,6 +55,10 @@
export default {
export default {
data() {
data() {
return {
return {
nickname: '',
gender: '0',
age: 18,
switch: true,
formData: {} as UTSJSONObject
formData: {} as UTSJSONObject
}
}
},
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录