From 471b5cad8610ca41df9267a4b91f2a4ac179a54e Mon Sep 17 00:00:00 2001 From: m0_75226990 Date: Tue, 27 Aug 2024 17:55:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4Promise=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BE=8B=EF=BC=8C=E5=85=BC=E5=AE=B9=E5=AE=89=E5=8D=93=E5=92=8C?= =?UTF-8?q?web?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/Promise.uts | 12 +++++++++--- uni_modules/uts-tests/utssdk/index.uts | 9 ++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/uni_modules/uts-tests/utssdk/Promise.uts b/uni_modules/uts-tests/utssdk/Promise.uts index 0b7a3c0..5cd8e61 100644 --- a/uni_modules/uts-tests/utssdk/Promise.uts +++ b/uni_modules/uts-tests/utssdk/Promise.uts @@ -2,7 +2,6 @@ import { describe, test, expect, Result } from './tests.uts' export function testPromise(): Result { return describe("Promise", () => { - // #ifdef APP-IOS test('constructor', () => { // 常规方式 let p = new Promise((resolve, reject) => { @@ -308,7 +307,7 @@ export function testPromise(): Result { console.log(res); let statusArr : string[] = [] res.forEach((item, index: number) => { - statusArr.append(item.status) + statusArr.add(item.status) }) expect(statusArr).toEqual(["fulfilled", "fulfilled", "rejected", "rejected"]) }) @@ -352,9 +351,17 @@ export function testPromise(): Result { .catch( (error: any | null) => { console.log("test for promise.any error ==> ", error); + // #ifdef APP-IOS expect((error as UTSPromiseAggregateError).name).toEqual("AggregateError"); expect((error as UTSPromiseAggregateError).message).toEqual("All promises were rejected"); expect((error as UTSPromiseAggregateError).errors).toEqual([null, "error"]); + // #endif + + // #ifdef APP-ANDROID + expect((error as UTSPromiseAggregateError).name).toEqual("AggregateError"); + expect((error as UTSPromiseAggregateError).message).toEqual("All promises were rejected"); + expect((error as UTSPromiseAggregateError).errors).toEqual([null, "error"]); + // #endif }) }) @@ -392,6 +399,5 @@ export function testPromise(): Result { expect(error).toEqual(null); }) }) - // #endif }) } diff --git a/uni_modules/uts-tests/utssdk/index.uts b/uni_modules/uts-tests/utssdk/index.uts index 017a512..8cf98cc 100644 --- a/uni_modules/uts-tests/utssdk/index.uts +++ b/uni_modules/uts-tests/utssdk/index.uts @@ -46,10 +46,7 @@ export function runTests() : UTSJSONObject { const ArrayBufferRes = testArrayBuffer(); // #endif const NativeCodeRes = testNativeCode(); - - // #ifdef APP-IOS - const PromiseRes = testPromise(); - // #endif + const PromiseRes = testPromise(); return { Array: ArrayRes, Date: DateRes, @@ -73,8 +70,6 @@ export function runTests() : UTSJSONObject { ArrayBuffer: ArrayBufferRes, // #endif NativeCode: NativeCodeRes, - // #ifdef APP-IOS - Primise: PromiseRes - // #endif + Primise: PromiseRes } } \ No newline at end of file -- GitLab