Skip to content

Commit

Permalink
test(do): add subscription assertions on do() tests
Browse files Browse the repository at this point in the history
  • Loading branch information
staltz authored and kwonoj committed Nov 25, 2015
1 parent 07099cd commit 358a687
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion spec/operators/do-spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals describe, it, expect */
/* globals describe, it, expect, expectObservable, expectSubscriptions, hot, cold */
var Rx = require('../../dist/cjs/Rx');
var Observable = Rx.Observable;

Expand Down Expand Up @@ -126,4 +126,35 @@ describe('Observable.prototype.do()', function () {
expect(err.message).toBe('bad');
});
});

it('should allow unsubscribing explicitly and early', function () {
var e1 = hot('--1--2--3--#');
var unsub = ' ! ';
var e1subs = '^ ! ';
var expected = '--1--2-- ';

var result = e1.do();
expectObservable(result, unsub).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});

it('should mirror multiple values and complete', function () {
var e1 = cold('--1--2--3--|');
var e1subs = '^ !';
var expected = '--1--2--3--|';

var result = e1.do();
expectObservable(result).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});

it('should mirror multiple values and terminate with error', function () {
var e1 = cold('--1--2--3--#');
var e1subs = '^ !';
var expected = '--1--2--3--#';

var result = e1.do();
expectObservable(result).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});
});

0 comments on commit 358a687

Please sign in to comment.