Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
3a6e84b1
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看板
提交
3a6e84b1
编写于
1月 25, 2024
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 调整测试例兼容web端
上级
55b49ed3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
93 addition
and
82 deletion
+93
-82
pages/API/download-file/download-file.test.js
pages/API/download-file/download-file.test.js
+41
-36
pages/API/download-file/download-file.uvue
pages/API/download-file/download-file.uvue
+2
-2
pages/API/upload-file/upload-file.test.js
pages/API/upload-file/upload-file.test.js
+50
-44
未找到文件。
pages/API/download-file/download-file.test.js
浏览文件 @
3a6e84b1
...
...
@@ -2,47 +2,52 @@ const PAGE_PATH = '/pages/API/download-file/download-file'
describe
(
'
ExtApi-DownloadFile
'
,
()
=>
{
let
page
;
let
page
;
let
res
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
600
);
await
page
.
callMethod
(
'
jest_downloadFile
'
);
await
page
.
waitFor
(
1000
);
res
=
await
page
.
data
(
'
jest_result
'
);
});
beforeEach
(
async
()
=>
{
await
page
.
setData
({
jest_result
:
false
})
await
page
.
waitFor
(
600
);
await
page
.
callMethod
(
'
jest_downloadFile
'
);
await
page
.
waitFor
(
1000
);
res
=
await
page
.
data
(
'
jest_result
'
);
});
beforeEach
(
async
()
=>
{
await
page
.
setData
({
jest_result
:
false
})
});
it
(
'
Check
'
,
async
()
=>
{
expect
(
res
).
toBe
(
true
);
});
it
(
'
Check Set Cookie
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
let
version
=
process
.
env
.
uniTestPlatformInfo
version
=
version
.
split
(
"
"
)[
1
]
if
(
version
>
9
){
res
=
await
page
.
callMethod
(
'
jest_set_cookie
'
)
await
page
.
waitFor
(
1000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
}
}
});
it
(
'
Check Delete Cookie
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
let
version
=
process
.
env
.
uniTestPlatformInfo
version
=
version
.
split
(
"
"
)[
1
]
if
(
version
>
9
){
res
=
await
page
.
callMethod
(
'
jest_delete_cookie
'
)
await
page
.
waitFor
(
1000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
}
}
expect
(
res
).
toBe
(
true
);
});
let
shouldTestCookie
=
false
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
let
version
=
process
.
env
.
uniTestPlatformInfo
version
=
version
.
split
(
"
"
)[
1
]
shouldTestCookie
=
version
>
9
}
else
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
// TODO 测试网址调整后放开此测试
shouldTestCookie
=
false
}
it
(
'
Check Set Cookie
'
,
async
()
=>
{
if
(
!
shouldTestCookie
)
{
return
}
res
=
await
page
.
callMethod
(
'
jest_set_cookie
'
)
await
page
.
waitFor
(
1000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
});
it
(
'
Check Delete Cookie
'
,
async
()
=>
{
if
(
!
shouldTestCookie
)
{
return
}
res
=
await
page
.
callMethod
(
'
jest_delete_cookie
'
)
await
page
.
waitFor
(
1000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
});
});
pages/API/download-file/download-file.uvue
浏览文件 @
3a6e84b1
...
...
@@ -77,7 +77,7 @@
method: "GET",
timeout: 6000,
sslVerify: false,
withCredentials:
fals
e,
withCredentials:
tru
e,
firstIpv4: false,
success: () => {
this.jest_cookie_download(true)
...
...
@@ -94,7 +94,7 @@
method: "GET",
timeout: 6000,
sslVerify: false,
withCredentials:
fals
e,
withCredentials:
tru
e,
firstIpv4: false,
success: () => {
this.jest_cookie_download(false)
...
...
pages/API/upload-file/upload-file.test.js
浏览文件 @
3a6e84b1
const
PAGE_PATH
=
'
/pages/API/upload-file/upload-file
'
describe
(
'
ExtApi-UploadFile
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)){
// TODO: web 端暂不支持测试
it
(
'
web
'
,
async
()
=>
{
expect
(
1
).
toBe
(
1
)
})
}
let
page
;
let
page
;
let
res
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
600
);
await
page
.
callMethod
(
'
jest_uploadFile
'
);
await
page
.
waitFor
(
1000
);
res
=
await
page
.
data
(
'
jest_result
'
);
});
beforeEach
(
async
()
=>
{
await
page
.
setData
({
jest_result
:
false
})
await
page
.
waitFor
(
600
);
await
page
.
callMethod
(
'
jest_uploadFile
'
);
await
page
.
waitFor
(
1000
);
res
=
await
page
.
data
(
'
jest_result
'
);
});
beforeEach
(
async
()
=>
{
await
page
.
setData
({
jest_result
:
false
})
});
it
(
'
Check
'
,
async
()
=>
{
expect
(
res
).
toBe
(
true
);
});
it
(
'
Check Set Cookie
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
let
version
=
process
.
env
.
uniTestPlatformInfo
version
=
version
.
split
(
"
"
)[
1
]
if
(
version
>
9
){
res
=
await
page
.
callMethod
(
'
jest_set_cookie
'
)
await
page
.
waitFor
(
1000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
}
}
});
it
(
'
Check Delete Cookie
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
let
version
=
process
.
env
.
uniTestPlatformInfo
version
=
version
.
split
(
"
"
)[
1
]
if
(
version
>
9
){
res
=
await
page
.
callMethod
(
'
jest_delete_cookie
'
)
await
page
.
waitFor
(
1000
);
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
(
1000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
expect
(
res
).
toBe
(
true
);
});
it
(
'
Check Set Cookie
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
let
version
=
process
.
env
.
uniTestPlatformInfo
version
=
version
.
split
(
"
"
)[
1
]
if
(
version
>
9
){
res
=
await
page
.
callMethod
(
'
jest_set_cookie
'
)
await
page
.
waitFor
(
1000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
}
}
});
it
(
'
Check Delete Cookie
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
let
version
=
process
.
env
.
uniTestPlatformInfo
version
=
version
.
split
(
"
"
)[
1
]
if
(
version
>
9
){
res
=
await
page
.
callMethod
(
'
jest_delete_cookie
'
)
await
page
.
waitFor
(
1000
);
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
(
1000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录