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

test: uploadFile uni.env测试例

上级 ef4b31e0
...@@ -36,6 +36,13 @@ describe('ExtApi-UploadFile', () => { ...@@ -36,6 +36,13 @@ describe('ExtApi-UploadFile', () => {
expect(res).toBe(true) expect(res).toBe(true)
}); });
it('Check uni.env', async () => {
await page.callMethod('jest_uploadFile_with_uni_env');
await page.waitFor(2000);
res = await page.data('jest_result');
expect(res).toBe(true);
});
// 15以下的模拟器所对应的xcode不能编译自定义插件 // 15以下的模拟器所对应的xcode不能编译自定义插件
let version = process.env.uniTestPlatformInfo let version = process.env.uniTestPlatformInfo
let split = version.split(" ") let split = version.split(" ")
...@@ -49,6 +56,8 @@ describe('ExtApi-UploadFile', () => { ...@@ -49,6 +56,8 @@ describe('ExtApi-UploadFile', () => {
}) })
} }
let shouldTestCookie = false let shouldTestCookie = false
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) { if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
let version = process.env.uniTestPlatformInfo let version = process.env.uniTestPlatformInfo
......
...@@ -102,6 +102,29 @@ ...@@ -102,6 +102,29 @@
}, },
}) })
}, },
jest_uploadFile_with_uni_env() {
const filePath = `${uni.env.CACHE_PATH}/download/uni-app.png`
uni.downloadFile({
url: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
filePath: filePath,
success: () => {
uni.uploadFile({
url: 'https://unidemo.dcloud.net.cn/upload', //仅为示例,非真实的接口地址
filePath: filePath,
name: 'file',
success: () => {
this.jest_result = true;
},
fail: () => {
this.jest_result = false;
},
})
},
fail: () => {
this.jest_result = false
}
});
},
jest_set_cookie() { jest_set_cookie() {
uni.request({ uni.request({
url: "https://request.dcloud.net.cn/api/http/header/setCookie", url: "https://request.dcloud.net.cn/api/http/header/setCookie",
...@@ -179,14 +202,14 @@ ...@@ -179,14 +202,14 @@
}, },
}) })
}, },
jest_uts_module_invoked(){ jest_uts_module_invoked() {
// #ifdef APP // #ifdef APP
testInovkeUploadFile({ testInovkeUploadFile({
success:(res: any)=>{ success: (res : any) => {
console.log("success :", res); console.log("success :", res);
this.jest_result = true this.jest_result = true
}, },
fail:(err: any)=>{ fail: (err : any) => {
console.log("fail :", err); console.log("fail :", err);
this.jest_result = false this.jest_result = false
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册