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

test: uploadFile uni.env测试例

上级 0d212e43
......@@ -34,6 +34,13 @@ describe('ExtApi-UploadFile', () => {
await page.waitFor(2000);
res = await page.data('jest_result');
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是因为某台设备,会用xcode14.1跑15.5的设备
......@@ -47,7 +54,9 @@ describe('ExtApi-UploadFile', () => {
res = await page.data('jest_result');
expect(res).toBe(true)
})
}
}
let shouldTestCookie = false
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
......
......@@ -15,13 +15,13 @@
</scroll-view>
<!-- #endif -->
</template>
<script>
// #ifdef APP
import {
testInovkeUploadFile,
CommonOptions
} from '@/uni_modules/test-invoke-network-api'
// #endif
<script>
// #ifdef APP
import {
testInovkeUploadFile,
CommonOptions
} from '@/uni_modules/test-invoke-network-api'
// #endif
export default {
data() {
......@@ -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() {
uni.request({
url: "https://request.dcloud.net.cn/api/http/header/setCookie",
......@@ -178,20 +201,20 @@
this.jest_result = false;
},
})
},
jest_uts_module_invoked(){
// #ifdef APP
testInovkeUploadFile({
success:(res: any)=>{
console.log("success :", res);
this.jest_result = true
},
fail:(err: any)=>{
console.log("fail :", err);
this.jest_result = false
}
} as CommonOptions)
// #endif
},
jest_uts_module_invoked() {
// #ifdef APP
testInovkeUploadFile({
success: (res : any) => {
console.log("success :", res);
this.jest_result = true
},
fail: (err : any) => {
console.log("fail :", err);
this.jest_result = false
}
} as CommonOptions)
// #endif
}
}
}
......@@ -217,4 +240,4 @@
font-size: 19px;
color: #808080;
}
</style>
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册