Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
7c08d86c
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
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看板
提交
7c08d86c
编写于
8月 14, 2024
作者:
Anne_LXM
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test(picker-view.test.js): 补充测试例
上级
79c574e5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
91 addition
and
54 deletion
+91
-54
pages/component/picker-view/picker-view.test.js
pages/component/picker-view/picker-view.test.js
+70
-48
pages/component/picker-view/picker-view.uvue
pages/component/picker-view/picker-view.uvue
+21
-6
未找到文件。
pages/component/picker-view/picker-view.test.js
浏览文件 @
7c08d86c
function
getData
(
key
=
''
)
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
const
data
=
await
page
.
data
()
resolve
(
key
?
data
[
key
]
:
data
)
})
}
const
PAGE_PATH
=
'
/pages/component/picker-view/picker-view
'
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
await
page
.
callMethod
(
'
setEventCallbackNum
'
,
0
)
})
afterEach
(
async
()
=>
{
await
page
.
callMethod
(
'
setEventCallbackNum
'
,
0
)
})
let
page
,
pickerViewEl
;
describe
(
'
PickerView.uvue
'
,
()
=>
{
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
await
page
.
callMethod
(
'
setEventCallbackNum
'
,
0
)
pickerViewEl
=
await
page
.
$
(
'
.picker-view
'
)
})
afterEach
(
async
()
=>
{
await
page
.
callMethod
(
'
setEventCallbackNum
'
,
0
)
})
async
function
toScreenshot
(
imgName
)
{
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toSaveImageSnapshot
({
customSnapshotIdentifier
()
{
return
imgName
}})
await
page
.
waitFor
(
500
);
}
it
(
'
value
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
.picker-view
'
)
await
page
.
callMethod
(
'
setValue
'
)
await
page
.
waitFor
(
1000
)
const
newValue1
=
await
e
l
.
property
(
'
value
'
)
const
newValue1
=
await
pickerViewE
l
.
property
(
'
value
'
)
// TODO
expect
(
newValue1
.
toString
()).
toEqual
(
'
0,0,0
'
)
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-android
'
)
{
expect
(
await
getD
ata
(
'
result
'
)).
toEqual
([
0
,
0
,
0
])
expect
(
await
page
.
d
ata
(
'
result
'
)).
toEqual
([
0
,
0
,
0
])
}
await
page
.
callMethod
(
'
setValue1
'
)
await
page
.
waitFor
(
1000
)
const
newValue2
=
await
e
l
.
property
(
'
value
'
)
const
newValue2
=
await
pickerViewE
l
.
property
(
'
value
'
)
// TODO
expect
(
newValue2
.
toString
()).
toEqual
(
'
10,10,10
'
)
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-android
'
)
{
expect
(
await
getD
ata
(
'
result
'
)).
toEqual
([
10
,
10
,
10
])
expect
(
await
page
.
d
ata
(
'
result
'
)).
toEqual
([
10
,
10
,
10
])
}
})
...
...
@@ -46,29 +46,61 @@ describe('PickerView.uvue', () => {
const
els1
=
await
page
.
$$
(
'
.picker-view-column
'
)
expect
(
els1
.
length
).
toBe
(
3
)
})
it
(
'
indicator-style
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
.picker-view
'
)
// App端动态设置indicatorStyle无效
const
indicatorStyle
=
"
height: 50px;border:#ff5500 solid 1px;background:rgba(182, 179, 255, 0.4);
"
await
page
.
setData
({
indicatorStyle
:
'
height: 100px;
'
,
indicatorStyle
})
await
page
.
waitFor
(
500
)
expect
(
await
el
.
attribute
(
'
indicatorStyle
'
)).
toBe
(
'
height: 100px;
'
)
expect
(
await
pickerViewEl
.
attribute
(
'
indicatorStyle
'
)).
toBe
(
indicatorStyle
)
await
toScreenshot
(
'
indicator-style
'
)
})
it
(
'
mask-top-style
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
.picker-view
'
)
await
page
.
setData
({
maskTopStyle
:
'
background: #ffffff;
'
,
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)){
// indicator-class、mask-style、mask-class 仅web支持
it
(
'
indicator-class
'
,
async
()
=>
{
await
page
.
setData
({
indicatorStyle
:
""
,
//清空indicatorStyle
indicatorClass
:
"
indicator-test
"
,
//设置indicatorClass为indicator-test
})
expect
(
await
pickerViewEl
.
attribute
(
'
indicatorClass
'
)).
toBe
(
"
indicator-test
"
)
await
toScreenshot
(
'
indicator-class
'
)
await
page
.
setData
({
indicatorClass
:
""
,
//清空indicatorClass
})
})
expect
(
await
el
.
attribute
(
'
mask-top-style
'
)).
toBe
(
'
background: #ffffff;
'
)
})
it
(
'
mask-bottom-style
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
.picker-view
'
)
it
(
'
mask-style
'
,
async
()
=>
{
const
maskStyle
=
"
background-image: linear-gradient(to bottom, #d8e5ff, rgba(216, 229, 255, 0));
"
await
page
.
setData
({
maskStyle
})
expect
(
await
pickerViewEl
.
attribute
(
'
maskStyle
'
)).
toBe
(
maskStyle
)
await
toScreenshot
(
'
mask-style
'
)
})
it
(
'
mask-class
'
,
async
()
=>
{
await
page
.
setData
({
maskClass
:
"
mask-test
"
})
expect
(
await
pickerViewEl
.
attribute
(
'
maskClass
'
)).
toBe
(
"
mask-test
"
)
await
toScreenshot
(
'
mask-class
'
)
})
return
}
it
(
'
mask-top-bottom-style
'
,
async
()
=>
{
// App端动态设置mask-top-style、mask-bottom-style无效
const
linearToTop
=
"
background-image: linear-gradient(to bottom, #f4ff73, rgba(216, 229, 255, 0));
"
const
linearToBottom
=
"
background-image: linear-gradient(to top, #f4ff73, rgba(216, 229, 255, 0));
"
await
page
.
setData
({
maskBottomStyle
:
'
background: #ffffff;
'
,
maskTopStyle
:
linearToTop
,
maskBottomStyle
:
linearToBottom
,
})
expect
(
await
el
.
attribute
(
'
mask-bottom-style
'
)).
toBe
(
'
background: #ffffff;
'
)
await
page
.
waitFor
(
500
)
expect
(
await
pickerViewEl
.
attribute
(
'
mask-top-style
'
)).
toBe
(
linearToTop
)
expect
(
await
pickerViewEl
.
attribute
(
'
mask-bottom-style
'
)).
toBe
(
linearToBottom
)
await
page
.
waitFor
(
2000
)
await
toScreenshot
(
'
mask-top-bottom-style
'
)
})
it
(
'
reopen-picker-view-page
'
,
async
()
=>
{
page
=
await
program
.
switchTab
(
'
/pages/tabBar/component
'
)
await
page
.
waitFor
(
500
)
...
...
@@ -86,16 +118,6 @@ describe('PickerView.uvue', () => {
})
it
(
'
trigger UniPickerViewChangeEvent
'
,
async
()
=>
{
// if web skip todo
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
)
{
expect
(
1
).
toBe
(
1
)
return
}
const
el
=
await
page
.
$
(
'
.picker-view
'
)
await
page
.
callMethod
(
'
setValue
'
)
await
page
.
waitFor
(
1500
)
const
eventCallbackNum
=
await
page
.
callMethod
(
'
getEventCallbackNum
'
)
...
...
pages/component/picker-view/picker-view.uvue
浏览文件 @
7c08d86c
...
...
@@ -6,8 +6,13 @@
日期:{{year}}年{{month}}月{{day}}日
</view>
</view>
<picker-view class="picker-view" :indicator-style="indicatorStyle" :value="value" @change="bindChange"
:mask-top-style="maskTopStyle" :mask-bottom-style="maskBottomStyle">
<picker-view class="picker-view" :value="value" @change="bindChange"
:indicator-style="indicatorStyle"
:indicator-class="indicatorClass"
:mask-style="maskStyle"
:mask-class="maskClass"
:mask-top-style="maskTopStyle"
:mask-bottom-style="maskBottomStyle">
<picker-view-column class="picker-view-column">
<view class="item" v-for="(item,index) in years" :key="index"><text class="text">{{item}}年</text></view>
</picker-view-column>
...
...
@@ -52,7 +57,11 @@
day: _day as number,
value: [_year - 2000, _month - 1, _day - 1] as number[],
result: [] as number[],
indicatorStyle: 'height: 50px;',
indicatorStyle: 'height: 50px;',
// 自动化测试
indicatorClass: '',
maskStyle: '',
maskClass: '',
maskTopStyle: '',
maskBottomStyle: ''
}
...
...
@@ -75,7 +84,6 @@
if (e.type === 'change') {
this.setEventCallbackNum(state.eventCallbackNum + 2)
}
const val = e.detail.value
this.result = val
this.year = this.years[val[0]]
...
...
@@ -98,13 +106,20 @@
height: 320px;
margin-top: 10px;
}
.item {
height: 50px;
}
.text {
line-height: 50px;
text-align: center;
}
/* 自动化测试 */
.indicator-test{
height: 50px;
border:#0055ff solid 1px;
background:rgba(0, 170, 0, 0.4);
}
.mask-test{
background-image: linear-gradient(to bottom, #d8e5ff, rgba(216, 229, 255, 0));
}
</style>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录