Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
1bd26566
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6048
Star
92
Fork
165
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
1bd26566
编写于
11月 26, 2024
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: 测试与示例适配小程序
上级
33fa5acf
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
100 addition
and
60 deletion
+100
-60
pages/API/create-selector-query/create-selector-query.test.js
...s/API/create-selector-query/create-selector-query.test.js
+8
-2
pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js
...lement-by-id/get-element-by-id-multiple-root-node.test.js
+4
-2
pages/API/get-element-by-id/get-element-by-id.test.js
pages/API/get-element-by-id/get-element-by-id.test.js
+3
-1
pages/API/upload-file/upload-file.test.js
pages/API/upload-file/upload-file.test.js
+20
-16
pages/API/upload-file/upload-file.uvue
pages/API/upload-file/upload-file.uvue
+7
-3
pages/component/button/button.test.js
pages/component/button/button.test.js
+1
-1
pages/component/checkbox/checkbox.test.js
pages/component/checkbox/checkbox.test.js
+57
-35
未找到文件。
pages/API/create-selector-query/create-selector-query.test.js
浏览文件 @
1bd26566
...
@@ -76,7 +76,10 @@ describe('nodes-info', () => {
...
@@ -76,7 +76,10 @@ describe('nodes-info', () => {
// #endif
// #endif
it
(
'
test filelds
'
,
async
()
=>
{
it
(
'
test filelds
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
||
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
)
)
{
expect
(
true
).
toBe
(
true
)
expect
(
true
).
toBe
(
true
)
}
else
{
}
else
{
const
pageData
=
await
page
.
data
()
const
pageData
=
await
page
.
data
()
...
@@ -85,7 +88,10 @@ describe('nodes-info', () => {
...
@@ -85,7 +88,10 @@ describe('nodes-info', () => {
})
})
it
(
'
test node
'
,
async
()
=>
{
it
(
'
test node
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
||
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
)
)
{
expect
(
true
).
toBe
(
true
)
expect
(
true
).
toBe
(
true
)
}
else
{
}
else
{
const
pageData
=
await
page
.
data
()
const
pageData
=
await
page
.
data
()
...
...
pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js
浏览文件 @
1bd26566
...
@@ -11,8 +11,10 @@ describe("getElementByIdForMultipleRootNode", () => {
...
@@ -11,8 +11,10 @@ describe("getElementByIdForMultipleRootNode", () => {
const
res
=
await
page
.
callMethod
(
"
getElementByNotExistId
"
);
const
res
=
await
page
.
callMethod
(
"
getElementByNotExistId
"
);
expect
(
res
).
toBe
(
null
);
expect
(
res
).
toBe
(
null
);
});
});
it
(
"
changeStyle
"
,
async
()
=>
{
it
(
"
changeStyle
"
,
async
()
=>
{
await
page
.
callMethod
(
"
changePageHeadBackgroundColor
"
);
if
(
!
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
))
{
await
page
.
callMethod
(
"
changePageHeadBackgroundColor
"
);
}
await
page
.
callMethod
(
"
changeTextColor
"
);
await
page
.
callMethod
(
"
changeTextColor
"
);
await
page
.
callMethod
(
"
changeViewStyle
"
);
await
page
.
callMethod
(
"
changeViewStyle
"
);
await
page
.
waitFor
(
500
);
await
page
.
waitFor
(
500
);
...
...
pages/API/get-element-by-id/get-element-by-id.test.js
浏览文件 @
1bd26566
...
@@ -11,7 +11,9 @@ describe("getElementById", () => {
...
@@ -11,7 +11,9 @@ describe("getElementById", () => {
expect
(
res
).
toBe
(
null
);
expect
(
res
).
toBe
(
null
);
});
});
it
(
"
changeStyle
"
,
async
()
=>
{
it
(
"
changeStyle
"
,
async
()
=>
{
await
page
.
callMethod
(
"
changePageHeadBackgroundColor
"
);
if
(
!
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
))
{
await
page
.
callMethod
(
"
changePageHeadBackgroundColor
"
);
}
await
page
.
callMethod
(
"
changeTextColor
"
);
await
page
.
callMethod
(
"
changeTextColor
"
);
await
page
.
callMethod
(
"
changeViewStyle
"
);
await
page
.
callMethod
(
"
changeViewStyle
"
);
await
page
.
waitFor
(
500
);
await
page
.
waitFor
(
500
);
...
...
pages/API/upload-file/upload-file.test.js
浏览文件 @
1bd26566
...
@@ -7,35 +7,39 @@ describe('ExtApi-UploadFile', () => {
...
@@ -7,35 +7,39 @@ describe('ExtApi-UploadFile', () => {
expect
(
1
).
toBe
(
1
)
expect
(
1
).
toBe
(
1
)
})
})
return
return
}
}
const
isUploadProjectFileSupported
=
!
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
)
let
page
;
let
page
;
let
res
;
let
res
;
beforeAll
(
async
()
=>
{
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
600
);
await
page
.
callMethod
(
'
jest_uploadFile
'
);
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
});
});
beforeEach
(
async
()
=>
{
beforeEach
(
async
()
=>
{
await
page
.
setData
({
await
page
.
setData
({
jest_result
:
false
jest_result
:
false
})
})
});
it
(
'
Check
'
,
async
()
=>
{
expect
(
res
).
toBe
(
true
);
});
it
(
'
Check files upload
'
,
async
()
=>
{
res
=
await
page
.
callMethod
(
'
jest_files_upload
'
)
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
});
});
if
(
isUploadProjectFileSupported
)
{
it
(
'
Check
'
,
async
()
=>
{
await
page
.
waitFor
(
600
);
await
page
.
callMethod
(
'
jest_uploadFile
'
);
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
);
});
it
(
'
Check files upload
'
,
async
()
=>
{
res
=
await
page
.
callMethod
(
'
jest_files_upload
'
)
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
});
}
it
(
'
Check uni.env
'
,
async
()
=>
{
it
(
'
Check uni.env
'
,
async
()
=>
{
await
page
.
callMethod
(
'
jest_uploadFile_with_uni_env
'
);
await
page
.
callMethod
(
'
jest_uploadFile_with_uni_env
'
);
await
page
.
waitFor
(
2000
);
await
page
.
waitFor
(
2000
);
...
...
pages/API/upload-file/upload-file.uvue
浏览文件 @
1bd26566
...
@@ -9,7 +9,8 @@
...
@@ -9,7 +9,8 @@
<image v-if="imageSrc" :src="imageSrc" class="image" mode="widthFix"></image>
<image v-if="imageSrc" :src="imageSrc" class="image" mode="widthFix"></image>
<text v-else class="uni-hello-addfile" @click="chooseImage">+ 选择图片</text>
<text v-else class="uni-hello-addfile" @click="chooseImage">+ 选择图片</text>
</view>
</view>
</view>
</view>
<button @click="jest_uploadFile_with_uni_env">jest_uploadFile_with_uni_env</button>
</view>
</view>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
</scroll-view>
</scroll-view>
...
@@ -104,8 +105,11 @@
...
@@ -104,8 +105,11 @@
},
},
})
})
},
},
jest_uploadFile_with_uni_env() {
jest_uploadFile_with_uni_env() {
const filePath = `${uni.env.CACHE_PATH}/download/uni-app.png`
/**
* 微信小程序只支持USER_DATA_PATH,且子目录未创建的情况下不能直接下载到子目录内
*/
const filePath = `${uni.env.USER_DATA_PATH}/uni-app.png`
uni.downloadFile({
uni.downloadFile({
url: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
url: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
filePath: filePath,
filePath: filePath,
...
...
pages/component/button/button.test.js
浏览文件 @
1bd26566
...
@@ -79,7 +79,7 @@ describe('Button.uvue', () => {
...
@@ -79,7 +79,7 @@ describe('Button.uvue', () => {
})
})
it
(
"
checkUniButtonElement
"
,
async
()
=>
{
it
(
"
checkUniButtonElement
"
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
))
{
expect
(
1
).
toBe
(
1
)
expect
(
1
).
toBe
(
1
)
return
return
}
}
...
...
pages/component/checkbox/checkbox.test.js
浏览文件 @
1bd26566
...
@@ -14,18 +14,23 @@ beforeAll(async () => {
...
@@ -14,18 +14,23 @@ beforeAll(async () => {
})
})
describe
(
'
Checkbox.uvue
'
,
()
=>
{
describe
(
'
Checkbox.uvue
'
,
()
=>
{
const
isMP
=
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
)
it
(
'
change
'
,
async
()
=>
{
it
(
'
change
'
,
async
()
=>
{
expect
(
await
getData
(
'
value
'
)).
toEqual
([])
expect
(
await
getData
(
'
value
'
)).
toEqual
([])
const
cb1
=
await
page
.
$
(
'
.cb1
'
)
const
cb1
=
await
page
.
$
(
'
.cb1
'
)
await
cb1
.
tap
()
await
cb1
.
tap
()
await
page
.
waitFor
(
100
)
expect
(
await
getData
(
'
value
'
)).
toEqual
([
'
cb
'
,
'
cb1
'
])
expect
(
await
getData
(
'
value
'
)).
toEqual
([
'
cb
'
,
'
cb1
'
])
const
cb
=
await
page
.
$
(
'
.cb
'
)
const
cb
=
await
page
.
$
(
'
.cb
'
)
await
cb
.
tap
()
await
cb
.
tap
()
await
page
.
waitFor
(
100
)
expect
(
await
getData
(
'
value
'
)).
toEqual
([
'
cb1
'
])
expect
(
await
getData
(
'
value
'
)).
toEqual
([
'
cb1
'
])
const
cb2
=
await
page
.
$
(
'
.cb2
'
)
const
cb2
=
await
page
.
$
(
'
.cb2
'
)
await
cb2
.
tap
()
await
cb2
.
tap
()
await
page
.
waitFor
(
100
)
expect
(
await
getData
(
'
value
'
)).
toEqual
([
'
cb1
'
])
expect
(
await
getData
(
'
value
'
)).
toEqual
([
'
cb1
'
])
await
cb1
.
tap
()
await
cb1
.
tap
()
await
page
.
waitFor
(
100
)
expect
(
await
getData
(
'
value
'
)).
toEqual
([])
expect
(
await
getData
(
'
value
'
)).
toEqual
([])
})
})
it
(
'
length
'
,
async
()
=>
{
it
(
'
length
'
,
async
()
=>
{
...
@@ -42,6 +47,29 @@ describe('Checkbox.uvue', () => {
...
@@ -42,6 +47,29 @@ describe('Checkbox.uvue', () => {
})
})
expect
(
await
cb
.
text
()).
toEqual
(
'
not selected
'
)
expect
(
await
cb
.
text
()).
toEqual
(
'
not selected
'
)
})
})
if
(
isMP
)
{
it
(
'
disabled
'
,
async
()
=>
{
const
cb
=
await
page
.
$
(
'
.cb2
'
)
const
disabled1
=
await
cb
.
property
(
'
disabled
'
)
expect
(
disabled1
).
toBe
(
true
)
await
page
.
setData
({
disabled
:
false
,
})
const
disabled2
=
await
cb
.
property
(
'
disabled
'
)
expect
(
disabled2
).
toBe
(
false
)
})
}
else
{
it
(
'
disabled
'
,
async
()
=>
{
const
cb
=
await
page
.
$
(
'
.cb2
'
)
const
disabled1
=
await
cb
.
attribute
(
'
disabled
'
)
expect
(
disabled1
).
toBe
(
true
+
''
)
await
page
.
setData
({
disabled
:
false
,
})
const
disabled2
=
await
cb
.
attribute
(
'
disabled
'
)
expect
(
disabled2
).
toBe
(
false
+
''
)
})
}
it
(
'
checked
'
,
async
()
=>
{
it
(
'
checked
'
,
async
()
=>
{
const
cb
=
await
page
.
$
(
'
.cb
'
)
const
cb
=
await
page
.
$
(
'
.cb
'
)
// TODO
// TODO
...
@@ -54,44 +82,38 @@ describe('Checkbox.uvue', () => {
...
@@ -54,44 +82,38 @@ describe('Checkbox.uvue', () => {
const
newValue2
=
await
cb
.
property
(
'
checked
'
)
const
newValue2
=
await
cb
.
property
(
'
checked
'
)
expect
(
newValue2
.
toString
()).
toBe
(
false
+
''
)
expect
(
newValue2
.
toString
()).
toBe
(
false
+
''
)
})
})
it
(
'
color
'
,
async
()
=>
{
if
(
!
isMP
)
{
const
cb
=
await
page
.
$
(
'
.cb
'
)
it
(
'
color
'
,
async
()
=>
{
expect
(
await
cb
.
attribute
(
'
color
'
)).
toBe
(
'
#007aff
'
)
const
cb
=
await
page
.
$
(
'
.cb
'
)
await
page
.
setData
({
expect
(
await
cb
.
attribute
(
'
color
'
)).
toBe
(
'
#007aff
'
)
color
:
'
#63acfc
'
,
await
page
.
setData
({
color
:
'
#63acfc
'
,
})
expect
(
await
cb
.
attribute
(
'
color
'
)).
toBe
(
'
#63acfc
'
)
})
})
expect
(
await
cb
.
attribute
(
'
color
'
)).
toBe
(
'
#63acfc
'
)
})
it
(
'
icon color
'
,
async
()
=>
{
it
(
'
icon color
'
,
async
()
=>
{
const
cb
=
await
page
.
$
(
'
.cb
'
)
const
cb
=
await
page
.
$
(
'
.cb
'
)
expect
(
await
cb
.
attribute
(
'
iconColor
'
)).
toBe
(
'
#211cfe
'
)
expect
(
await
cb
.
attribute
(
'
iconColor
'
)).
toBe
(
'
#211cfe
'
)
await
page
.
setData
({
await
page
.
setData
({
iconColor
:
'
#63acfc
'
,
iconColor
:
'
#63acfc
'
,
})
expect
(
await
cb
.
attribute
(
'
iconColor
'
)).
toBe
(
'
#63acfc
'
)
})
})
expect
(
await
cb
.
attribute
(
'
iconColor
'
)).
toBe
(
'
#63acfc
'
)
it
(
'
foreColor
'
,
async
()
=>
{
}
)
const
cb
=
await
page
.
$
(
'
.cb
'
)
it
(
'
foreColor
'
,
async
()
=>
{
expect
(
await
cb
.
attribute
(
'
foreColor
'
)).
toBe
(
'
#ff0000
'
)
const
cb
=
await
page
.
$
(
'
.cb
'
)
await
page
.
setData
({
expect
(
await
cb
.
attribute
(
'
foreColor
'
)).
toBe
(
'
#ff0000
'
)
foreColor
:
'
#63acfe
'
,
await
page
.
setData
({
})
foreColor
:
'
#63acfe
'
,
expect
(
await
cb
.
attribute
(
'
foreColor
'
)).
toBe
(
'
#63acfe
'
)
})
})
expect
(
await
cb
.
attribute
(
'
foreColor
'
)).
toBe
(
'
#63acfe
'
)
it
(
'
trigger UniCheckboxGroupChangeEvent
'
,
async
()
=>
{
})
const
element
=
await
page
.
$
(
'
.checkbox-item-0
'
)
it
(
'
disabled
'
,
async
()
=>
{
await
element
.
tap
()
const
cb
=
await
page
.
$
(
'
.cb2
'
)
await
page
.
waitFor
(
1000
)
expect
(
await
cb
.
attribute
(
'
disabled
'
)).
toBe
(
true
+
''
)
const
{
testEvent
}
=
await
page
.
data
()
await
page
.
setData
({
expect
(
testEvent
).
toBe
(
true
)
disabled
:
false
,
})
})
expect
(
await
cb
.
attribute
(
'
disabled
'
)).
toBe
(
false
+
''
)
}
})
it
(
'
trigger UniCheckboxGroupChangeEvent
'
,
async
()
=>
{
const
element
=
await
page
.
$
(
'
.checkbox-item-0
'
)
await
element
.
tap
()
await
page
.
waitFor
(
1000
)
const
{
testEvent
}
=
await
page
.
data
()
expect
(
testEvent
).
toBe
(
true
)
})
})
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录