From 0b44e8336c56c28e4129b8b1a3fe14bbb9324c4a Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 12 Mar 2019 14:08:01 +0900 Subject: [PATCH] test(promise): add test cases for Promise.all with sync then operations (#1158) --- test/common/Promise.spec.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/common/Promise.spec.ts b/test/common/Promise.spec.ts index 15036c148..2ef7c09a8 100644 --- a/test/common/Promise.spec.ts +++ b/test/common/Promise.spec.ts @@ -463,6 +463,26 @@ describe( }); }); + it('should resolve with the sync then operation', () => { + queueZone.run(() => { + let value = null; + const p1 = { + then: function(thenCallback: Function) { + return thenCallback('p1'); + } + }; + const p2 = { + then: function(thenCallback: Function) { + return thenCallback('p2'); + } + }; + Promise.all([p1, 'v1', p2]).then((v: any) => value = v); + // expect(Zone.current.get('queue').length).toEqual(2); + flushMicrotasks(); + expect(value).toEqual(['p1', 'v1', 'p2']); + }); + }); + it('should resolve generators', ifEnvSupports( () => {