From c11e1b3579ec748b33a1a402fd2366aa74720165 Mon Sep 17 00:00:00 2001 From: Nicholas Jamieson Date: Thu, 2 May 2019 12:57:06 +1000 Subject: [PATCH] fix(forkJoin): test for object literal (#4741) * test(forkJoin): add failing test for #4737 * fix(forkJoin): test for object literal not observable Closes #4737. --- spec/observables/forkJoin-spec.ts | 13 +++++++++++++ src/internal/observable/forkJoin.ts | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/spec/observables/forkJoin-spec.ts b/spec/observables/forkJoin-spec.ts index 0bbb31211e..8d437f38b5 100644 --- a/spec/observables/forkJoin-spec.ts +++ b/spec/observables/forkJoin-spec.ts @@ -504,5 +504,18 @@ describe('forkJoin', () => { expectSubscriptions(e1.subscriptions).toBe(e1subs); expectSubscriptions(e2.subscriptions).toBe(e2subs); }); + + it('should accept promise as the first arg', done => { + const e1 = forkJoin(Promise.resolve(1)); + const values: number[][] = []; + + e1.subscribe({ + next: x => values.push(x), + complete: () => { + expect(values).to.deep.equal([[1]]); + done(); + } + }); + }); }); }); diff --git a/src/internal/observable/forkJoin.ts b/src/internal/observable/forkJoin.ts index a7a8d3453a..400e54f8ef 100644 --- a/src/internal/observable/forkJoin.ts +++ b/src/internal/observable/forkJoin.ts @@ -147,7 +147,7 @@ export function forkJoin( return forkJoinInternal(first, null); } // TODO(benlesh): isObservable check will not be necessary when deprecated path is removed. - if (isObject(first) && !isObservable(first)) { + if (isObject(first) && Object.getPrototypeOf(first) === Object.prototype) { const keys = Object.keys(first); return forkJoinInternal(keys.map(key => first[key]), keys); }