Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(forkJoin): add tests with never and with unsubscribing after error #2394

Merged
merged 1 commit into from Apr 3, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 52 additions & 0 deletions spec/observables/forkJoin-spec.ts
Expand Up @@ -194,6 +194,35 @@ describe('Observable.forkJoin', () => {
expectObservable(e1).toBe(expected);
});

it('should not complete when only source never completes', () => {
const e1 = Observable.forkJoin(
hot('--------------')
);
const expected = '-';

expectObservable(e1).toBe(expected);
});

it('should not complete when one of the sources never completes', () => {
const e1 = Observable.forkJoin(
hot('--------------'),
hot('-a---b--c--|')
);
const expected = '-';

expectObservable(e1).toBe(expected);
});

it('should complete when one of the sources never completes but other completes without values', () => {
const e1 = Observable.forkJoin(
hot('--------------'),
hot('------|')
);
const expected = '------|';

expectObservable(e1).toBe(expected);
});

it('should complete if source is not provided', () => {
const e1 = Observable.forkJoin();
const expected = '|';
Expand Down Expand Up @@ -245,6 +274,15 @@ describe('Observable.forkJoin', () => {
expectObservable(e1).toBe(expected);
});

it('should raise error when any of source raises error with source that never completes', () => {
const e1 = Observable.forkJoin(
hot('------#'),
hot('----------'));
const expected = '------#';

expectObservable(e1).toBe(expected);
});

it('should raise error when any of source raises error with selector with empty observable', () => {
function selector(x, y) {
return x + y;
Expand Down Expand Up @@ -297,6 +335,20 @@ describe('Observable.forkJoin', () => {
expectSubscriptions(e2.subscriptions).toBe(e2subs);
});

it('should unsubscribe other Observables, when one of them errors', () => {
const e1 = hot('--a--^--b--c---d-| ');
const e1subs = '^ ! ';
const e2 = hot('---e-^---f--g-#');
const e2subs = '^ ! ';
const expected = '---------# ';

const result = Observable.forkJoin(e1, e2);

expectObservable(result).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
expectSubscriptions(e2.subscriptions).toBe(e2subs);
});

it('should support promises', () => {
type(() => {
/* tslint:disable:no-unused-variable */
Expand Down