Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
cb0b098c
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6005
Star
91
Fork
164
代码
文件
提交
分支
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看板
提交
cb0b098c
编写于
12月 25, 2023
作者:
taohebin@dcloud.io
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: request增加cookie的测试用例
上级
3c34446b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
71 addition
and
3 deletion
+71
-3
pages/API/request/request.test.js
pages/API/request/request.test.js
+13
-0
pages/API/request/request.uvue
pages/API/request/request.uvue
+58
-3
未找到文件。
pages/API/request/request.test.js
浏览文件 @
cb0b098c
...
...
@@ -75,5 +75,18 @@ describe('ExtApi-Request', () => {
});
it
(
'
Check HEAD
'
,
async
()
=>
{
await
request
(
page
,
'
HEAD
'
);
});
it
(
'
Check Set Cookie
'
,
async
()
=>
{
res
=
await
page
.
callMethod
(
'
jest_set_cookie
'
)
await
page
.
waitFor
(
500
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
});
it
(
'
Check Delete Cookie
'
,
async
()
=>
{
res
=
await
page
.
callMethod
(
'
jest_delete_cookie
'
)
await
page
.
waitFor
(
1000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
});
});
pages/API/request/request.uvue
浏览文件 @
cb0b098c
...
...
@@ -188,7 +188,8 @@
withCredentials: false,
firstIpv4: false,
success: (res) => {
console.log('request success', JSON.stringify(res.data))
console.log('request success', JSON.stringify(res.data))
console.log('request success header is :', JSON.stringify(res.header))
uni.showToast({
title: '请求成功',
icon: 'success',
...
...
@@ -229,7 +230,61 @@
this.jest_result = false;
},
});
}
},
jest_set_cookie() {
uni.request({
url: this.host + "/api/http/header/setCookie",
method: "GET",
timeout: 6000,
sslVerify: false,
withCredentials: false,
firstIpv4: false,
success: () => {
this.jest_cookie_request(true)
},
fail: () => {
this.jest_result = false;
},
});
},
jest_delete_cookie() {
uni.request({
url: this.host + "/api/http/header/deleteCookie",
method: "GET",
timeout: 6000,
sslVerify: false,
withCredentials: false,
firstIpv4: false,
success: () => {
this.jest_cookie_request(false)
},
fail: () => {
this.jest_result = false;
},
});
},
jest_cookie_request(needCookie: boolean) {
uni.request({
url: this.host + "/api/http/header/requestCookie",
method: "GET",
timeout: 6000,
sslVerify: false,
withCredentials: false,
firstIpv4: false,
success: (res) => {
const requestCookie = (res.data as UTSJSONObject).getJSON("data")?.getAny("requestCookie")
console.log("requestCookie ", requestCookie);
if(requestCookie instanceof Array<unknown>){
this.jest_result = needCookie ? requestCookie.length > 0 : requestCookie.length == 0
}else{
this.jest_result = needCookie ? (requestCookie as UTSJSONObject).toMap().size > 0 : (requestCookie as UTSJSONObject).toMap().size == 0
}
},
fail: () => {
this.jest_result = false;
},
});
},
}
}
</script>
\ No newline at end of file
</script>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录