-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3289 from benlesh/onErrorResumeNext-fn
fix(onErrorResumeNext): no longer holds onto subscriptions too long
- Loading branch information
Showing
2 changed files
with
81 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,54 @@ | ||
import * as Rx from '../../src/Rx'; | ||
import { onErrorResumeNext } from '../../src/create'; | ||
import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports | ||
|
||
declare const hot: typeof marbleTestingSignature.hot; | ||
declare const cold: typeof marbleTestingSignature.cold; | ||
declare const expectObservable: typeof marbleTestingSignature.expectObservable; | ||
declare const expectSubscriptions: typeof marbleTestingSignature.expectSubscriptions; | ||
|
||
const Observable = Rx.Observable; | ||
|
||
describe('Observable.onErrorResumeNext', () => { | ||
describe('onErrorResumeNext', () => { | ||
it('should continue with observables', () => { | ||
const source = hot('--a--b--#'); | ||
const next1 = cold( '--c--d--#'); | ||
const next2 = cold( '--e--#'); | ||
const next3 = cold( '--f--g--|'); | ||
const subs = '^ !'; | ||
const expected = '--a--b----c--d----e----f--g--|'; | ||
|
||
expectObservable(Observable.onErrorResumeNext(source, next1, next2, next3)).toBe(expected); | ||
expectSubscriptions(source.subscriptions).toBe(subs); | ||
const s1 = hot('--a--b--#'); | ||
const s2 = cold( '--c--d--#'); | ||
const s3 = cold( '--e--#'); | ||
const s4 = cold( '--f--g--|'); | ||
const subs1 = '^ !'; | ||
const subs2 = ' ^ !'; | ||
const subs3 = ' ^ !'; | ||
const subs4 = ' ^ !'; | ||
const expected = '--a--b----c--d----e----f--g--|'; | ||
|
||
expectObservable(onErrorResumeNext(s1, s2, s3, s4)).toBe(expected); | ||
expectSubscriptions(s1.subscriptions).toBe(subs1); | ||
expectSubscriptions(s2.subscriptions).toBe(subs2); | ||
expectSubscriptions(s3.subscriptions).toBe(subs3); | ||
expectSubscriptions(s4.subscriptions).toBe(subs4); | ||
}); | ||
|
||
it('should continue array of observables', () => { | ||
const source = hot('--a--b--#'); | ||
const next = [ source, | ||
cold( '--c--d--#'), | ||
cold( '--e--#'), | ||
cold( '--f--g--|')]; | ||
const subs = '^ !'; | ||
const expected = '--a--b----c--d----e----f--g--|'; | ||
|
||
expectObservable(Observable.onErrorResumeNext(next)).toBe(expected); | ||
expectSubscriptions(source.subscriptions).toBe(subs); | ||
const s1 = hot('--a--b--#'); | ||
const s2 = cold( '--c--d--#'); | ||
const s3 = cold( '--e--#'); | ||
const s4 = cold( '--f--g--|'); | ||
const subs1 = '^ !'; | ||
const subs2 = ' ^ !'; | ||
const subs3 = ' ^ !'; | ||
const subs4 = ' ^ !'; | ||
const expected = '--a--b----c--d----e----f--g--|'; | ||
|
||
expectObservable(onErrorResumeNext([s1, s2, s3, s4])).toBe(expected); | ||
expectSubscriptions(s1.subscriptions).toBe(subs1); | ||
expectSubscriptions(s2.subscriptions).toBe(subs2); | ||
expectSubscriptions(s3.subscriptions).toBe(subs3); | ||
expectSubscriptions(s4.subscriptions).toBe(subs4); | ||
}); | ||
|
||
it('should complete single observable throws', () => { | ||
const source = hot('#'); | ||
const subs = '(^!)'; | ||
const expected = '|'; | ||
|
||
expectObservable(Observable.onErrorResumeNext(source)).toBe(expected); | ||
expectObservable(onErrorResumeNext(source)).toBe(expected); | ||
expectSubscriptions(source.subscriptions).toBe(subs); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters