Skip to content

Commit

Permalink
fix(forkJoin): test for object literal (#4741)
Browse files Browse the repository at this point in the history
* test(forkJoin): add failing test for #4737

* fix(forkJoin): test for object literal not observable

Closes #4737.
  • Loading branch information
cartant authored and benlesh committed May 2, 2019
1 parent 1dc09e9 commit c11e1b3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions spec/observables/forkJoin-spec.ts
Expand Up @@ -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();
}
});
});
});
});
2 changes: 1 addition & 1 deletion src/internal/observable/forkJoin.ts
Expand Up @@ -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);
}
Expand Down

0 comments on commit c11e1b3

Please sign in to comment.