Skip to content

Commit

Permalink
chore: use TestScheduler#run
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed Nov 22, 2019
1 parent 59ba56d commit 1868582
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions spec/operators/catch-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as sinon from 'sinon';
import { createObservableInputs } from '../helpers/test-helper';
import { TestScheduler } from 'rxjs/testing';
import { observableMatcher } from '../helpers/observableMatcher';
import * as marbleTesting from '../helpers/marble-testing';
import { asInteropObservable } from '../helpers/interop-helper';

declare function asDiagram(arg: string): Function;
Expand Down Expand Up @@ -128,7 +127,7 @@ describe('catchError operator', () => {
testScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => {
const e1 = hot(' -1-2-3-# ');
const e1subs = ' ^------! ';
const e2 = cold(' 5-6-7-8-9-|');
const e2 = cold(' 5-6-7-8-9-|');
const e2subs = ' -------^----! ';
const expected = '-1-2-3-5-6-7- ';
const unsub = ' ------------! ';
Expand All @@ -142,19 +141,20 @@ describe('catchError operator', () => {
});

it('should unsubscribe from a caught cold caught interop observable when unsubscribed explicitly', () => {
const { hot, cold, expectObservable, expectSubscriptions } = marbleTesting;
const e1 = hot('-1-2-3-# ');
const e1subs = '^ ! ';
const e2 = cold( '5-6-7-8-9-|');
const e2subs = ' ^ ! ';
const expected = '-1-2-3-5-6-7- ';
const unsub = ' ! ';

const result = e1.pipe(catchError(() => asInteropObservable(e2)));

expectObservable(result, unsub).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
expectSubscriptions(e2.subscriptions).toBe(e2subs);
testScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => {
const e1 = hot(' -1-2-3-# ');
const e1subs = ' ^------! ';
const e2 = cold(' 5-6-7-8-9-|');
const e2subs = ' -------^----! ';
const expected = '-1-2-3-5-6-7- ';
const unsub = ' ------------! ';

const result = e1.pipe(catchError(() => asInteropObservable(e2)));

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

it('should stop listening to a synchronous observable when unsubscribed', () => {
Expand Down

0 comments on commit 1868582

Please sign in to comment.