Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
7b3c6175
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5992
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
7b3c6175
编写于
6月 30, 2023
作者:
Y
yurj26
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(radio): add test
上级
551ee7c6
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
91 addition
and
11 deletion
+91
-11
pages/component/radio/radio.test.js
pages/component/radio/radio.test.js
+68
-0
pages/component/radio/radio.uvue
pages/component/radio/radio.uvue
+23
-11
未找到文件。
pages/component/radio/radio.test.js
0 → 100644
浏览文件 @
7b3c6175
function
getData
(
key
=
''
)
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
const
data
=
await
page
.
data
()
resolve
(
key
?
data
[
key
]
:
data
)
})
}
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/component/radio/radio
'
)
await
page
.
waitFor
(
1000
)
})
describe
(
'
Radio.uvue
'
,
()
=>
{
it
(
'
change
'
,
async
()
=>
{
const
radio
=
await
page
.
$
(
'
.r
'
)
const
radio1
=
await
page
.
$
(
'
.r1
'
)
const
radio2
=
await
page
.
$
(
'
.r2
'
)
expect
(
await
getData
(
'
value
'
)).
toEqual
(
""
)
await
radio1
.
tap
()
expect
(
await
getData
(
'
value
'
)).
toEqual
(
"
r1
"
)
await
radio
.
tap
()
expect
(
await
getData
(
'
value
'
)).
toEqual
(
"
r
"
)
await
radio2
.
tap
()
expect
(
await
getData
(
'
value
'
)).
toEqual
(
"
r
"
)
})
it
(
'
length
'
,
async
()
=>
{
const
radioGroupElements
=
await
page
.
$$
(
'
.radio-group
'
)
expect
(
radioGroupElements
.
length
).
toBe
(
3
)
const
radioElements
=
await
page
.
$$
(
'
.radio
'
)
expect
(
radioElements
.
length
).
toBe
(
11
)
})
it
(
'
text
'
,
async
()
=>
{
const
radio
=
await
page
.
$
(
'
.r
'
)
expect
(
await
radio
.
text
()).
toEqual
(
'
选中
'
)
await
page
.
setData
({
text
:
'
checked
'
})
expect
(
await
radio
.
text
()).
toEqual
(
'
checked
'
)
})
it
(
'
checked
'
,
async
()
=>
{
const
radio
=
await
page
.
$
(
'
.r
'
)
expect
(
await
radio
.
property
(
'
checked
'
)).
toBe
(
true
)
await
page
.
setData
({
checked
:
false
})
await
page
.
waitFor
(
500
)
expect
(
await
radio
.
property
(
'
checked
'
)).
toBe
(
false
)
})
it
(
'
color
'
,
async
()
=>
{
const
radio
=
await
page
.
$
(
'
.r
'
)
expect
(
await
radio
.
property
(
'
color
'
)).
toBe
(
'
#007aff
'
)
await
page
.
setData
({
color
:
'
#63acfc
'
})
await
page
.
waitFor
(
500
)
expect
(
await
radio
.
property
(
'
color
'
)).
toBe
(
'
#63acfc
'
)
})
it
(
'
disabled
'
,
async
()
=>
{
const
radio
=
await
page
.
$
(
'
.r2
'
)
expect
(
await
radio
.
property
(
'
disabled
'
)).
toBe
(
true
)
await
page
.
setData
({
disabled
:
false
})
await
page
.
waitFor
(
500
)
expect
(
await
radio
.
property
(
'
disabled
'
)).
toBe
(
false
)
})
})
\ No newline at end of file
pages/component/radio/radio.uvue
浏览文件 @
7b3c6175
...
...
@@ -7,10 +7,12 @@
默认样式
</text>
</view>
<view class="uni-flex uni-row">
<radio value="r1" :checked="true" style="margin-right: 30rpx;">选中</radio>
<radio value="r2">未选中</radio>
</view>
<radio-group class="uni-flex uni-row radio-group" @change="testChange">
<radio value="r" :checked="checked" :color="color" style="margin-right: 30rpx;" class="radio r">{{text}}
</radio>
<radio value="r1" style="margin-right: 30rpx;" class="radio r1">未选中</radio>
<radio value="r2" :disabled="disabled" class="radio r2">禁用</radio>
</radio-group>
</view>
<view class="uni-padding-wrap">
<view class="uni-title uni-common-mt">
...
...
@@ -18,11 +20,12 @@
不同颜色和尺寸的radio
</text>
</view>
<view class="uni-flex uni-row">
<radio value="r1" :checked="true" color="#FFCC33" style="transform:scale(0.7); margin-right: 30rpx;">选中
<radio-group class="uni-flex uni-row radio-group">
<radio value="r1" :checked="true" color="#FFCC33" style="transform:scale(0.7); margin-right: 30rpx;"
class="radio">选中
</radio>
<radio value="r2" color="#FFCC33" style="transform:scale(0.7)">未选中</radio>
</
view
>
<radio value="r2" color="#FFCC33" style="transform:scale(0.7)"
class="radio"
>未选中</radio>
</
radio-group
>
</view>
<view class="uni-padding-wrap">
<view class="uni-title uni-common-mt">
...
...
@@ -32,8 +35,8 @@
</view>
</view>
<view class="uni-list">
<radio-group @change="radioChange">
<radio class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items" :key="item.value"
<radio-group @change="radioChange"
class="radio-group"
>
<radio class="uni-list-cell uni-list-cell-pd
radio
" v-for="(item, index) in items" :key="item.value"
:class="index < items.length - 1 ? 'uni-list-cell-line': ''" :value="item.value"
:checked="index === current">
{{item.name}}
...
...
@@ -76,7 +79,13 @@
name: '法国'
},
] as ItemType[],
current: 0
current: 0,
value: '',
text: '选中',
disabled: true,
checked: true,
color: '#007aff'
}
},
methods: {
...
...
@@ -87,6 +96,9 @@
break;
}
}
},
testChange(e : RadioGroupChangeEvent) {
this.value = e.detail.value
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录