From 2db00163241ef0d5283b78e1b00808f60ac0f3e4 Mon Sep 17 00:00:00 2001 From: Matthias Kunnen Date: Wed, 13 Feb 2019 21:49:52 +0100 Subject: [PATCH] test(throttleTime): test single value with trailing enabled Test if throttleTime emits when only a single value is emitted from the source with leading enabled/disabled and trailing enabled. --- spec/operators/throttleTime-spec.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/operators/throttleTime-spec.ts b/spec/operators/throttleTime-spec.ts index fef0cd15b3..bbaab5153c 100644 --- a/spec/operators/throttleTime-spec.ts +++ b/spec/operators/throttleTime-spec.ts @@ -152,6 +152,16 @@ describe('throttleTime operator', () => { expectObservable(result).toBe(expected); expectSubscriptions(e1.subscriptions).toBe(e1subs); }); + + it('should emit the first value if only a single one is given', () => { + const e1 = hot('-a--------------------|'); + const t = time('----| '); + const expected = '-a--------------------|'; + + const result = e1.pipe(throttleTime(t, rxTestScheduler, { leading: true, trailing: true })); + + expectObservable(result).toBe(expected); + }); }); describe('throttleTime(fn, { leading: false, trailing: true })', () => { @@ -178,5 +188,15 @@ describe('throttleTime operator', () => { expectObservable(result).toBe(expected); expectSubscriptions(e1.subscriptions).toBe(e1subs); }); + + it('should emit the first value if only a single one is given', () => { + const e1 = hot('-a--------------------|'); + const t = time('----| '); + const expected = '-----a----------------|'; + + const result = e1.pipe(throttleTime(t, rxTestScheduler, { leading: false, trailing: true })); + + expectObservable(result).toBe(expected); + }); }); });