From 46ca1d7c542aba3829fc15dfa1b3de0d2b0ebcee Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Tue, 10 Nov 2015 13:13:11 -0800 Subject: [PATCH] test(merge): expand test coverage for merge operator --- spec/observables/merge-spec.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/spec/observables/merge-spec.js b/spec/observables/merge-spec.js index 1c83eafa89..35b6d78fb3 100644 --- a/spec/observables/merge-spec.js +++ b/spec/observables/merge-spec.js @@ -18,6 +18,13 @@ describe('Observable.merge(...observables)', function () { expectSubscriptions(e2.subscriptions).toBe(e2subs); }); + it('should return itself when try to merge single observable', function () { + var e1 = Observable.of('a'); + var result = Observable.merge(e1); + + expect(e1).toBe(result); + }); + it('should merge hot and hot', function () { var e1 = hot('---a---^-b-----c----|'); var e1subs = '^ !'; @@ -197,7 +204,7 @@ describe('Observable.merge(...observables)', function () { }); }); -describe('Observable.merge(number, ...observables)', function () { +describe('Observable.merge(...observables, Scheduler, number)', function () { it('should handle concurrency limits', function () { var e1 = cold('---a---b---c---|'); var e2 = cold('-d---e---f--|'); @@ -205,4 +212,20 @@ describe('Observable.merge(number, ...observables)', function () { var expected = '-d-a-e-b-f-c---x---y---z---|'; expectObservable(Observable.merge(e1, e2, e3, 2)).toBe(expected); }); -}); \ No newline at end of file + + it('should handle scheduler', function () { + var e1 = Observable.of('a'); + var e2 = Observable.of('b').delay(20, rxTestScheduler); + var expected = 'a-(b|)'; + + expectObservable(Observable.merge(e1, e2, rxTestScheduler)).toBe(expected); + }); + + it('should handle scheduler with concurrency limits', function () { + var e1 = cold('---a---b---c---|'); + var e2 = cold('-d---e---f--|'); + var e3 = cold( '---x---y---z---|'); + var expected = '-d-a-e-b-f-c---x---y---z---|'; + expectObservable(Observable.merge(e1, e2, e3, 2, rxTestScheduler)).toBe(expected); + }); +});