From 296273fb279519407472c4feb41e11ef2c0b37c5 Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Mon, 22 Feb 2021 21:04:39 -0600 Subject: [PATCH] test(buffer): add additional test for final buffer emit --- spec/operators/buffer-spec.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spec/operators/buffer-spec.ts b/spec/operators/buffer-spec.ts index 243be1b852..56652ba3ce 100644 --- a/spec/operators/buffer-spec.ts +++ b/spec/operators/buffer-spec.ts @@ -27,6 +27,27 @@ describe('Observable.prototype.buffer', () => { }); }); + it('should emit all buffered values if the source completes before the closingNotifier does', () => { + testScheduler.run(({ hot, expectObservable, expectSubscriptions }) => { + const source = hot('---^---a---b---c---d---e--f----|'); + const sourceSubs = ' ^---------------------------!'; + const closer = hot('---^-------------B----------------'); + const closerSubs = ' ^---------------------------!'; + const expected = ' --------------x-------------(F|)'; + + const result = source.pipe(buffer(closer)); + + const expectedValues = { + x: ['a', 'b', 'c'], + F: ['d', 'e', 'f'], + }; + + expectObservable(result).toBe(expected, expectedValues); + expectSubscriptions(source.subscriptions).toBe(sourceSubs); + expectSubscriptions(closer.subscriptions).toBe(closerSubs); + }); + }); + it('should work with empty and empty selector', () => { testScheduler.run(({ expectObservable }) => { const a = EMPTY;