提交 471b5cad 编写于 作者: lizhongyi_'s avatar lizhongyi_

调整Promise 测试例,兼容安卓和web

上级 969c9666
......@@ -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<number>((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
})
}
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册