diff --git a/pages/API/download-file/download-file.test.js b/pages/API/download-file/download-file.test.js index 8a64b2b55678c731a8ba66af09615d878af8d17e..5431ffd4f9d9824b2f893450cb42f25cb3286764 100644 --- a/pages/API/download-file/download-file.test.js +++ b/pages/API/download-file/download-file.test.js @@ -20,7 +20,18 @@ describe('ExtApi-DownloadFile', () => { it('Check ', async () => { expect(res).toBe(true); - }); + }); + + + if (!process.env.uniTestPlatformInfo.startsWith('web')) { + it('Check uni.env', async () => { + await page.callMethod('jest_downloadFile_with_uni_env'); + await page.waitFor(2000); + 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) { diff --git a/pages/API/download-file/download-file.uvue b/pages/API/download-file/download-file.uvue index 5e719754b37d2fe6af31206e224578e4b979949e..22ad9a97523b2258e8de190ff3c5a7ab1b7fa9df 100644 --- a/pages/API/download-file/download-file.uvue +++ b/pages/API/download-file/download-file.uvue @@ -71,6 +71,19 @@ }); }, + jest_downloadFile_with_uni_env() { + uni.downloadFile({ + url: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app.png", + filePath: `${uni.env.CACHE_PATH}/a/b/`, + success: () => { + this.jest_result = true + }, + fail: () => { + this.jest_result = false + } + }); + }, + jest_set_cookie(){ uni.request({ url: "https://request.dcloud.net.cn/api/http/header/setCookie",