提交 711b5071 编写于 作者: taohebin@dcloud.io's avatar taohebin@dcloud.io

test: 增加request Cookie过期测试

上级 be333b23
...@@ -118,6 +118,27 @@ describe('ExtApi-Request', () => { ...@@ -118,6 +118,27 @@ describe('ExtApi-Request', () => {
res = await page.data('jest_result'); res = await page.data('jest_result');
expect(res).toBe(true) 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 () => { it('Check Get With Data', async () => {
res = await page.callMethod('jest_get_with_data') res = await page.callMethod('jest_get_with_data')
await page.waitFor(2000); await page.waitFor(2000);
......
...@@ -141,7 +141,8 @@ ...@@ -141,7 +141,8 @@
"/api/http/contentType/xWwwFormUrlencoded", "/api/http/contentType/xWwwFormUrlencoded",
], ],
//自动化测试例专用 //自动化测试例专用
jest_result: false jest_result: false,
jest_result_data: ""
} }
}, },
onLoad() { onLoad() {
...@@ -258,6 +259,22 @@ ...@@ -258,6 +259,22 @@
}, },
}); });
}, },
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() { jest_delete_cookie() {
uni.request({ uni.request({
url: this.host + "/api/http/header/deleteCookie", url: this.host + "/api/http/header/deleteCookie",
...@@ -285,6 +302,7 @@ ...@@ -285,6 +302,7 @@
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); console.log("requestCookie ", 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
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册