提交 0d04724f 编写于 作者: taohebin@dcloud.io's avatar taohebin@dcloud.io 提交者: 雪洛

test: 增加request Cookie过期测试

上级 0ade5339
......@@ -117,7 +117,28 @@ describe('ExtApi-Request', () => {
await page.waitFor(2000);
res = await page.data('jest_result');
expect(res).toBe(true)
});
});
it('Check Set Cookie Expires', async () => {
await page.callMethod('jest_set_cookie_expires')
await page.waitFor(2000);
res = await page.data('jest_result_data');
console.log("request expires cookie data :", res);
res = await page.data('jest_result');
expect(res).toBe(true)
await page.setData({
jest_result: false,
jest_result_data: "",
data: null,
header: null
})
await page.waitFor(5000);
await page.callMethod('jest_cookie_request', false)
await page.waitFor(2000);
res = await page.data('jest_result_data');
console.log("verify request data :", res);
res = await page.data('jest_result');
expect(res).toBe(true)
});
it('Check Get With Data', async () => {
res = await page.callMethod('jest_get_with_data')
await page.waitFor(2000);
......
......@@ -141,7 +141,8 @@
"/api/http/contentType/xWwwFormUrlencoded",
],
//自动化测试例专用
jest_result: false
jest_result: false,
jest_result_data: ""
}
},
onLoad() {
......@@ -257,6 +258,22 @@
this.jest_result = false;
},
});
},
jest_set_cookie_expires(){
uni.request({
url: this.host + "/api/http/header/setCookie?expires=5",
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({
......@@ -284,7 +301,8 @@
firstIpv4: false,
success: (res) => {
const requestCookie = (res.data as UTSJSONObject).getJSON("data")?.getAny("requestCookie")
console.log("requestCookie ", requestCookie);
console.log("requestCookie ", requestCookie);
this.jest_result_data = JSON.stringify(requestCookie)
if (requestCookie instanceof Array) {
this.jest_result = needCookie ? requestCookie.length > 0 : requestCookie.length == 0
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册