Skip to content

Commit

Permalink
test(retry): add test cases for issue #1041
Browse files Browse the repository at this point in the history
Add test cases for repeat() and retry() operators to verify that bug #1041 should not happen.

For issue #1041.
  • Loading branch information
staltz authored and benlesh committed Jan 4, 2016
1 parent 2b5c417 commit 69ebd9a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spec/operators/repeat-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,20 @@ describe('Observable.prototype.repeat()', function () {

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

it('should repeat a synchronous source (multicasted and refCounted) multiple times', function (done) {
var expected = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3];

Observable.of(1, 2, 3)
.multicast(function () { return new Rx.Subject(); })
.refCount()
.repeat(5)
.subscribe(
function (x) { expect(x).toBe(expected.shift()); },
done.fail,
function () {
expect(expected.length).toBe(0);
done();
});
});
});
17 changes: 17 additions & 0 deletions spec/operators/retry-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,21 @@ describe('Observable.prototype.retry()', function () {
expectObservable(result, unsub).toBe(expected);
expectSubscriptions(source.subscriptions).toBe(subs);
});

it('should retry a synchronous source (multicasted and refCounted) multiple times', function (done) {
var expected = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3];

Observable.of(1, 2, 3).concat(Observable.throw('bad!'))
.multicast(function () { return new Rx.Subject(); })
.refCount()
.retry(4)
.subscribe(
function (x) { expect(x).toBe(expected.shift()); },
function (err) {
expect(err).toBe('bad!');
expect(expected.length).toBe(0);
done();
},
done.fail);
});
});

0 comments on commit 69ebd9a

Please sign in to comment.