diff --git a/uni_modules/uts-tests/utssdk/Promise.uts b/uni_modules/uts-tests/utssdk/Promise.uts index 0b7a3c07c61363e0d9d7fd6b402bbace9fbd6d86..5cd8e614b9d6b5d7c955e3571eaad6fad6163cdd 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 017a512e3b584784d1a57023047b10a1f598ca12..8cf98ccaf8ad35cbd7579e99e6729ee0f5c01cb3 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