Skip to content

Commit

Permalink
test(buffer): add additional test for final buffer emit
Browse files Browse the repository at this point in the history
  • Loading branch information
benlesh committed Feb 23, 2021
1 parent 5a948a7 commit a83a9f0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/operators/buffer-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a83a9f0

Please sign in to comment.