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

update: 补充上传下载的cookie测试例

上级 11feed5f
......@@ -12,7 +12,25 @@ describe('ExtApi-DownloadFile', () => {
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 () => {
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 () => {
res = await page.callMethod('jest_delete_cookie')
await page.waitFor(1000);
res = await page.data('jest_result');
expect(res).toBe(true)
});
});
......@@ -69,6 +69,51 @@
this.jest_result = false
}
});
},
jest_set_cookie(){
uni.request({
url: "http://request.dcloud.net.cn/api/http/header/setCookie",
method: "GET",
timeout: 6000,
sslVerify: false,
withCredentials: false,
firstIpv4: false,
success: () => {
this.jest_cookie_download(true)
},
fail: () => {
this.jest_result = false;
},
});
},
jest_delete_cookie(){
uni.request({
url: "http://request.dcloud.net.cn/api/http/header/deleteCookie",
method: "GET",
timeout: 6000,
sslVerify: false,
withCredentials: false,
firstIpv4: false,
success: () => {
this.jest_cookie_download(false)
},
fail: () => {
this.jest_result = false;
},
});
},
jest_cookie_download(needCookie: boolean){
uni.downloadFile({
url: "http://request.dcloud.net.cn/api/http/header/download",
success: () => {
this.jest_result = needCookie ? true : false;
},
fail: () => {
this.jest_result = needCookie ? false : true;
}
});
}
}
}
......
......@@ -12,7 +12,26 @@ describe('ExtApi-UploadFile', () => {
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 () => {
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 () => {
res = await page.callMethod('jest_delete_cookie')
await page.waitFor(1000);
res = await page.data('jest_result');
expect(res).toBe(true)
});
});
......@@ -94,7 +94,61 @@
this.jest_result = false;
},
})
},
jest_set_cookie(){
uni.request({
url: "http://request.dcloud.net.cn/api/http/header/setCookie",
method: "GET",
timeout: 6000,
sslVerify: false,
withCredentials: false,
firstIpv4: false,
success: () => {
this.jest_cookie_upload(true)
},
fail: () => {
this.jest_result = false;
},
});
},
jest_delete_cookie(){
uni.request({
url: "http://request.dcloud.net.cn/api/http/header/deleteCookie",
method: "GET",
timeout: 6000,
sslVerify: false,
withCredentials: false,
firstIpv4: false,
success: () => {
this.jest_cookie_upload(false)
},
fail: () => {
this.jest_result = false;
},
});
},
jest_cookie_upload(needCookie: boolean){
const imageSrc = "/static/uni.png";
this.task = uni.uploadFile({
url: 'http://request.dcloud.net.cn/api/http/header/upload',
filePath: imageSrc,
name: 'file',
success: (res:UploadFileSuccess) => {
const data = JSON.parseObject(res.data)
const errCode = data?.getNumber("errCode")
if(errCode != null && errCode == 1000){
this.jest_result = needCookie ? false : true;
}else{
this.jest_result = needCookie ? true : false;
}
},
fail: () => {
this.jest_result = false;
},
})
}
}
}
</script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册