From 76a448b9feeb9dd276d68b39de0af87ca5edf1a6 Mon Sep 17 00:00:00 2001 From: taohebin Date: Thu, 18 Jul 2024 10:44:06 +0800 Subject: [PATCH] =?UTF-8?q?test:=20request=E5=A2=9E=E5=8A=A0=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/request/request.test.js | 9 +++++++++ pages/API/request/request.uvue | 22 ++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/pages/API/request/request.test.js b/pages/API/request/request.test.js index 60130dd3..2e3f62db 100644 --- a/pages/API/request/request.test.js +++ b/pages/API/request/request.test.js @@ -171,4 +171,13 @@ describe('ExtApi-Request', () => { res = await page.data('jest_result'); expect(res).toBe(true) }) + + if(process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('android')){ + it('Check Respone With String Generics', async () => { + res = await page.callMethod('jest_respone_with_string_generics') + await page.waitFor(2000); + res = await page.data('jest_result'); + expect(res).toBe(true) + }) + } }); diff --git a/pages/API/request/request.uvue b/pages/API/request/request.uvue index ee769e47..ed74e5b1 100644 --- a/pages/API/request/request.uvue +++ b/pages/API/request/request.uvue @@ -301,7 +301,6 @@ firstIpv4: false, success: (res) => { const requestCookie = (res.data as UTSJSONObject).getJSON("data")?.getAny("requestCookie") - console.log("requestCookie ", requestCookie); this.jest_result_data = JSON.stringify(requestCookie) if (requestCookie instanceof Array) { this.jest_result = needCookie ? requestCookie.length > 0 : requestCookie.length == 0 @@ -358,7 +357,6 @@ withCredentials: false, firstIpv4: false, success: (res: RequestSuccess) => { - console.log("success :", res.data?.data); this.jest_result = true; }, fail: () => { @@ -371,7 +369,6 @@ url: 'https://unidemo.dcloud.net.cn/api/news?column=title,author_name,cover,published_at', method: "GET", success: (res : RequestSuccess) => { - console.log(res) if (res.statusCode == 200 && Array.isArray(res.data)) { this.jest_result = true } else { @@ -387,11 +384,9 @@ // #ifdef APP testInovkeRequest({ success:(res: any)=>{ - console.log("success :", res); this.jest_result = true }, fail:(err: any)=>{ - console.log("fail :", err); this.jest_result = false } } as CommonOptions) @@ -401,13 +396,28 @@ uni.request({ url:"https://request.dcloud.net.cn/api/http/contentType/text/json", success:(res: RequestSuccess)=>{ - console.log("res :", res, typeof res.data); this.jest_result = typeof res.data == "object" }, fail:(e: RequestFail)=>{ this.jest_result = false } }) + }, + jest_respone_with_string_generics(){ + uni.request({ + url: this.host + (methodMap['GET'] as string), + method: "GET", + timeout: null, + sslVerify: false, + withCredentials: false, + firstIpv4: false, + success: (res: RequestSuccess) => { + this.jest_result = true; + }, + fail: () => { + this.jest_result = false; + }, + }); } } } -- GitLab