From 8f23a34aab9603dcc740eac7e305bc4e8f4ff7be Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Thu, 29 Feb 2024 20:39:39 +0800 Subject: [PATCH] =?UTF-8?q?test:=20request=E5=A2=9E=E5=8A=A0timeout:=20nul?= =?UTF-8?q?l=E6=B5=8B=E8=AF=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/request/request.test.js | 6 ++++++ pages/API/request/request.uvue | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/pages/API/request/request.test.js b/pages/API/request/request.test.js index e3834827..2dd94105 100644 --- a/pages/API/request/request.test.js +++ b/pages/API/request/request.test.js @@ -78,6 +78,12 @@ describe('ExtApi-Request', () => { it('Check HEAD', async () => { await request(page, 'HEAD'); }); + it('Request with timeout null', async () => { + res = await page.callMethod('jest_timeout_null') + await page.waitFor(2000); + res = await page.data('jest_result'); + expect(res).toBe(true) + }); let shouldTestCookie = false if (process.env.uniTestPlatformInfo.startsWith('android')) { diff --git a/pages/API/request/request.uvue b/pages/API/request/request.uvue index 3d3c80b7..62637f90 100644 --- a/pages/API/request/request.uvue +++ b/pages/API/request/request.uvue @@ -285,6 +285,22 @@ }, }); }, + jest_timeout_null() { + uni.request({ + url: this.host + (methodMap['GET'] as string), + method: "GET", + timeout: null, + sslVerify: false, + withCredentials: false, + firstIpv4: false, + success: () => { + this.jest_result = true; + }, + fail: (err) => { + this.jest_result = false; + }, + }); + }, } } -- GitLab