Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 0b44e83

Browse files
JiaLiPassionmhevery
authored andcommitted
test(promise): add test cases for Promise.all with sync then operations (#1158)
1 parent b038214 commit 0b44e83

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Diff for: test/common/Promise.spec.ts

+20
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,26 @@ describe(
463463
});
464464
});
465465

466+
it('should resolve with the sync then operation', () => {
467+
queueZone.run(() => {
468+
let value = null;
469+
const p1 = {
470+
then: function(thenCallback: Function) {
471+
return thenCallback('p1');
472+
}
473+
};
474+
const p2 = {
475+
then: function(thenCallback: Function) {
476+
return thenCallback('p2');
477+
}
478+
};
479+
Promise.all([p1, 'v1', p2]).then((v: any) => value = v);
480+
// expect(Zone.current.get('queue').length).toEqual(2);
481+
flushMicrotasks();
482+
expect(value).toEqual(['p1', 'v1', 'p2']);
483+
});
484+
});
485+
466486
it('should resolve generators',
467487
ifEnvSupports(
468488
() => {

0 commit comments

Comments
 (0)