Skip to content

Commit

Permalink
fix subscription tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mpodlasin committed Mar 12, 2017
1 parent 85a2717 commit 270f2ad
Show file tree
Hide file tree
Showing 18 changed files with 273 additions and 272 deletions.
88 changes: 44 additions & 44 deletions spec/observables/onErrorResumeNext-spec.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
import * as Rx from '../../dist/cjs/Rx';
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', () => {
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);
});

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);
});

it('should complete single observable throws', () => {
const source = hot('#');
const subs = '(^!)';
const expected = '|';

expectObservable(Observable.onErrorResumeNext(source)).toBe(expected);
expectSubscriptions(source.subscriptions).toBe(subs);
});
import * as Rx from '../../dist/cjs/Rx';
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', () => {
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);
});

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);
});

it('should complete single observable throws', () => {
const source = hot('#');
const subs = '(^!)';
const expected = '|';

expectObservable(Observable.onErrorResumeNext(source)).toBe(expected);
expectSubscriptions(source.subscriptions).toBe(subs);
});
});
12 changes: 6 additions & 6 deletions spec/operators/concatMap-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('Observable.prototype.concatMap', () => {
const d = cold( '------(d|)');
const dsubs = ' ^ ! ';
const e1 = hot('a---b--------------------c-d----| ');
const e1subs = '^ ! ';
const e1subs = '^ ! ';
const expected = '--a-a-a-a---b--b--b-------c-c-c-----(d|)';

const observableLookup = { a: a, b: b, c: c, d: d };
Expand All @@ -52,7 +52,7 @@ describe('Observable.prototype.concatMap', () => {
it('should concatMap many outer values to many inner values', () => {
const values = {i: 'foo', j: 'bar', k: 'baz', l: 'qux'};
const e1 = hot('-a---b---c---d---| ');
const e1subs = '^ !';
const e1subs = '^ !';
const inner = cold('--i-j-k-l-| ', values);
const innersubs = [' ^ ! ',
' ^ ! ',
Expand Down Expand Up @@ -127,7 +127,7 @@ describe('Observable.prototype.concatMap', () => {

it('should return a never if the mapped inner is never', () => {
const e1 = cold( '--a-b--c-|');
const e1subs = '^ ';
const e1subs = '^ !';
const inner = cold('-');
const innersubs = ' ^ ';
const expected = '----------';
Expand Down Expand Up @@ -192,7 +192,7 @@ describe('Observable.prototype.concatMap', () => {
it('should concatMap many outer to many inner, inner never completes', () => {
const values = {i: 'foo', j: 'bar', k: 'baz', l: 'qux'};
const e1 = hot('-a---b---c---d---|');
const e1subs = '^ ';
const e1subs = '^ !';
const inner = cold('--i-j-k-l- ', values);
const innersubs = ' ^ ';
const expected = '---i-j-k-l--------';
Expand Down Expand Up @@ -266,7 +266,7 @@ describe('Observable.prototype.concatMap', () => {
const g = cold( '---1-2|');
const gsubs = ' ^ !';
const e1 = hot('-a-b--^-c-----d------e----------------f-----g| ');
const e1subs = '^ !';
const e1subs = '^ !';
const expected = '---2--3--4--5----6-----2--3-1------2--3-4-5--------1-2|';
const observableLookup = { a: a, b: b, c: c, d: d, e: e, f: f, g: g };

Expand Down Expand Up @@ -299,7 +299,7 @@ describe('Observable.prototype.concatMap', () => {
const g = cold( '---1-2|');
const gsubs = [];
const e1 = hot('-a-b--^-c-----d------e----------------f-----g| ');
const e1subs = '^ ';
const e1subs = '^ !';
const expected = '---2--3--4--5----6-----2--3----------------------------';
const observableLookup = { a: a, b: b, c: c, d: d, e: e, f: f, g: g };

Expand Down
8 changes: 4 additions & 4 deletions spec/operators/concatMapTo-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Observable.prototype.concatMapTo', () => {
it('should concatMapTo many outer values to many inner values', () => {
const values = {i: 'foo', j: 'bar', k: 'baz', l: 'qux'};
const e1 = hot('-a---b---c---d---| ');
const e1subs = '^ !';
const e1subs = '^ ! ';
const inner = cold('--i-j-k-l-| ', values);
const innersubs = [' ^ ! ',
' ^ ! ',
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('Observable.prototype.concatMapTo', () => {

it('should return a never if the mapped inner is never', () => {
const e1 = cold('--a-b--c-|');
const e1subs = '^ ';
const e1subs = '^ !';
const inner = cold('-');
const innersubs = ' ^ ';
const expected = '----------';
Expand Down Expand Up @@ -168,7 +168,7 @@ describe('Observable.prototype.concatMapTo', () => {
it('should not break unsubscription chains when result is unsubscribed explicitly', () => {
const values = {i: 'foo', j: 'bar', k: 'baz', l: 'qux'};
const e1 = hot('-a---b---c---d---| ');
const e1subs = '^ !';
const e1subs = '^ ! ';
const inner = cold('--i-j-k-l-| ', values);
const innersubs = [' ^ ! ',
' ^ !'];
Expand All @@ -188,7 +188,7 @@ describe('Observable.prototype.concatMapTo', () => {
it('should concatMapTo many outer to many inner, inner never completes', () => {
const values = {i: 'foo', j: 'bar', k: 'baz', l: 'qux'};
const e1 = hot('-a---b---c---d---|');
const e1subs = '^ ';
const e1subs = '^ !';
const inner = cold('--i-j-k-l- ', values);
const innersubs = ' ^ ';
const expected = '---i-j-k-l--------';
Expand Down
8 changes: 4 additions & 4 deletions spec/operators/delay-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Observable.prototype.delay', () => {
const e1 = hot('---a--b--| ');
const t = time( '--| ');
const expected = '-----a--b--|';
const subs = '^ !';
const subs = '^ ! ';

const result = e1.delay(t, rxTestScheduler);

Expand All @@ -27,7 +27,7 @@ describe('Observable.prototype.delay', () => {
const e1 = hot('--a--b--| ');
const t = time( '---| ');
const expected = '-----a--b--|';
const subs = '^ !';
const subs = '^ ! ';

const absoluteDelay = new Date(rxTestScheduler.now() + t);
const result = e1.delay(absoluteDelay, rxTestScheduler);
Expand All @@ -40,7 +40,7 @@ describe('Observable.prototype.delay', () => {
const e1 = hot('---^--a--b--| ');
const t = time( '---| ');
const expected = '------a--b--|';
const subs = '^ !';
const subs = '^ ! ';

const absoluteDelay = new Date(rxTestScheduler.now() + t);
const result = e1.delay(absoluteDelay, rxTestScheduler);
Expand Down Expand Up @@ -91,7 +91,7 @@ describe('Observable.prototype.delay', () => {
const e1 = hot('----| ');
const t = time( '---|');
const expected = '-------|';
const subs = '^ !';
const subs = '^ !';

const result = e1.delay(t, rxTestScheduler);

Expand Down
12 changes: 6 additions & 6 deletions spec/operators/delayWhen-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Observable.prototype.delayWhen', () => {
asDiagram('delayWhen(durationSelector)')('should delay by duration selector', () => {
const e1 = hot('---a---b---c--|');
const expected = '-----a------c----(b|)';
const subs = '^ !';
const subs = '^ !';
const selector = [cold( '--x--|'),
cold( '----------(x|)'),
cold( '-x--|')];
Expand Down Expand Up @@ -81,7 +81,7 @@ describe('Observable.prototype.delayWhen', () => {
it('should delay by selector and completes after value emits', () => {
const e1 = hot('--a--b--|');
const expected = '---------a--(b|)';
const subs = '^ !';
const subs = '^ !';
const selector = cold('-------x--|');
const selectorSubs = [' ^ !',
' ^ !'];
Expand All @@ -96,7 +96,7 @@ describe('Observable.prototype.delayWhen', () => {
it('should delay by selector completes if selector does not emits', () => {
const e1 = hot('--a--b--|');
const expected = '------a--(b|)';
const subs = '^ !';
const subs = '^ ! ';
const selector = cold( '----|');
const selectorSubs = [' ^ !',
' ^ !'];
Expand All @@ -111,7 +111,7 @@ describe('Observable.prototype.delayWhen', () => {
it('should not emit if selector never emits', () => {
const e1 = hot('--a--b--|');
const expected = '-';
const subs = '^ ';
const subs = '^ !';
const selector = cold( '-');
const selectorSubs = [' ^ ',
' ^ '];
Expand All @@ -126,7 +126,7 @@ describe('Observable.prototype.delayWhen', () => {
it('should delay by first value from selector', () => {
const e1 = hot('--a--b--|');
const expected = '------a--(b|)';
const subs = '^ !';
const subs = '^ ! ';
const selector = cold( '----x--y--|');
const selectorSubs = [' ^ !',
' ^ !'];
Expand All @@ -141,7 +141,7 @@ describe('Observable.prototype.delayWhen', () => {
it('should delay by selector does not completes', () => {
const e1 = hot('--a--b--|');
const expected = '------a--(b|)';
const subs = '^ !';
const subs = '^ ! ';
const selector = cold( '----x-----y---');
const selectorSubs = [' ^ !',
' ^ !'];
Expand Down
10 changes: 5 additions & 5 deletions spec/operators/exhaustMap-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe('Observable.prototype.exhaustMap', () => {
const z = cold( '--g--h--i-----');
const zsubs = ' ^ ';
const e1 = hot('---x---------y-----------------z---------| ');
const e1subs = '^ ';
const e1subs = '^ ! ';
const expected = '-----a--b--c---------------------g--h--i-----';

const observableLookup = { x: x, y: y, z: z };
Expand Down Expand Up @@ -235,7 +235,7 @@ describe('Observable.prototype.exhaustMap', () => {
const z = hot('---z-o-o-m-------------j---k---l---m--|');
const zsubs = ' ^ !';
const e1 = hot('---------x----y-----z--------| ');
const e1subs = '^ !';
const e1subs = '^ ! ';
const expected = '-----------c--d--e-----j---k---l---m--|';

const observableLookup = { x: x, y: y, z: z };
Expand Down Expand Up @@ -274,7 +274,7 @@ describe('Observable.prototype.exhaustMap', () => {
const xsubs = ' (^!) ';
const ysubs = ' ^ ';
const e1 = hot('---------x---------y---------|');
const e1subs = '^ ';
const e1subs = '^ !';
const expected = '------------------------------';

const observableLookup = { x: x, y: y };
Expand All @@ -293,7 +293,7 @@ describe('Observable.prototype.exhaustMap', () => {
const xsubs = ' ^ ';
const ysubs = [];
const e1 = hot('---------x---------y----------|');
const e1subs = '^ ';
const e1subs = '^ !';
const expected = '-------------------------------';

const observableLookup = { x: x, y: y };
Expand Down Expand Up @@ -349,7 +349,7 @@ describe('Observable.prototype.exhaustMap', () => {
const z = cold( '---k---l---m---n--|');
const zsubs = ' ^ !';
const e1 = hot('--x---------y------z-| ');
const e1subs = '^ !';
const e1subs = '^ ! ';
const expected = '----a--b--c--d--e-----k---l---m---n--|';

const observableLookup = { x: x, y: y, z: z };
Expand Down
Loading

0 comments on commit 270f2ad

Please sign in to comment.