Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
76a448b9
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6060
Star
93
Fork
166
代码
文件
提交
分支
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看板
提交
76a448b9
编写于
7月 18, 2024
作者:
taohebin@dcloud.io
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: request增加测试例
上级
423e148f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
6 deletion
+25
-6
pages/API/request/request.test.js
pages/API/request/request.test.js
+9
-0
pages/API/request/request.uvue
pages/API/request/request.uvue
+16
-6
未找到文件。
pages/API/request/request.test.js
浏览文件 @
76a448b9
...
@@ -171,4 +171,13 @@ describe('ExtApi-Request', () => {
...
@@ -171,4 +171,13 @@ describe('ExtApi-Request', () => {
res
=
await
page
.
data
(
'
jest_result
'
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
expect
(
res
).
toBe
(
true
)
})
})
if
(
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
().
startsWith
(
'
android
'
)){
it
(
'
Check Respone With String Generics
'
,
async
()
=>
{
res
=
await
page
.
callMethod
(
'
jest_respone_with_string_generics
'
)
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
})
}
});
});
pages/API/request/request.uvue
浏览文件 @
76a448b9
...
@@ -301,7 +301,6 @@
...
@@ -301,7 +301,6 @@
firstIpv4: false,
firstIpv4: false,
success: (res) => {
success: (res) => {
const requestCookie = (res.data as UTSJSONObject).getJSON("data")?.getAny("requestCookie")
const requestCookie = (res.data as UTSJSONObject).getJSON("data")?.getAny("requestCookie")
console.log("requestCookie ", requestCookie);
this.jest_result_data = JSON.stringify(requestCookie)
this.jest_result_data = JSON.stringify(requestCookie)
if (requestCookie instanceof Array) {
if (requestCookie instanceof Array) {
this.jest_result = needCookie ? requestCookie.length > 0 : requestCookie.length == 0
this.jest_result = needCookie ? requestCookie.length > 0 : requestCookie.length == 0
...
@@ -358,7 +357,6 @@
...
@@ -358,7 +357,6 @@
withCredentials: false,
withCredentials: false,
firstIpv4: false,
firstIpv4: false,
success: (res: RequestSuccess<GETDataType>) => {
success: (res: RequestSuccess<GETDataType>) => {
console.log("success :", res.data?.data);
this.jest_result = true;
this.jest_result = true;
},
},
fail: () => {
fail: () => {
...
@@ -371,7 +369,6 @@
...
@@ -371,7 +369,6 @@
url: 'https://unidemo.dcloud.net.cn/api/news?column=title,author_name,cover,published_at',
url: 'https://unidemo.dcloud.net.cn/api/news?column=title,author_name,cover,published_at',
method: "GET",
method: "GET",
success: (res : RequestSuccess<UTSJSONObject[]>) => {
success: (res : RequestSuccess<UTSJSONObject[]>) => {
console.log(res)
if (res.statusCode == 200 && Array.isArray(res.data)) {
if (res.statusCode == 200 && Array.isArray(res.data)) {
this.jest_result = true
this.jest_result = true
} else {
} else {
...
@@ -387,11 +384,9 @@
...
@@ -387,11 +384,9 @@
// #ifdef APP
// #ifdef APP
testInovkeRequest({
testInovkeRequest({
success:(res: any)=>{
success:(res: any)=>{
console.log("success :", res);
this.jest_result = true
this.jest_result = true
},
},
fail:(err: any)=>{
fail:(err: any)=>{
console.log("fail :", err);
this.jest_result = false
this.jest_result = false
}
}
} as CommonOptions)
} as CommonOptions)
...
@@ -401,13 +396,28 @@
...
@@ -401,13 +396,28 @@
uni.request({
uni.request({
url:"https://request.dcloud.net.cn/api/http/contentType/text/json",
url:"https://request.dcloud.net.cn/api/http/contentType/text/json",
success:(res: RequestSuccess<any>)=>{
success:(res: RequestSuccess<any>)=>{
console.log("res :", res, typeof res.data);
this.jest_result = typeof res.data == "object"
this.jest_result = typeof res.data == "object"
},
},
fail:(e: RequestFail)=>{
fail:(e: RequestFail)=>{
this.jest_result = false
this.jest_result = false
}
}
})
})
},
jest_respone_with_string_generics(){
uni.request<string>({
url: this.host + (methodMap['GET'] as string),
method: "GET",
timeout: null,
sslVerify: false,
withCredentials: false,
firstIpv4: false,
success: (res: RequestSuccess<string>) => {
this.jest_result = true;
},
fail: () => {
this.jest_result = false;
},
});
}
}
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录