From 263391d828cf4d2d0cabf90785d2cb4d89979043 Mon Sep 17 00:00:00 2001 From: taohebin Date: Sat, 20 Apr 2024 11:15:52 +0800 Subject: [PATCH] =?UTF-8?q?test:=20downloadfile=20uni.env=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/download-file/download-file.test.js | 13 ++++++++++++- pages/API/download-file/download-file.uvue | 13 +++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/pages/API/download-file/download-file.test.js b/pages/API/download-file/download-file.test.js index 8a64b2b5..5431ffd4 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 5e719754..22ad9a97 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", -- GitLab