Skip to content

Commit

Permalink
test(throttleTime): test single value with trailing enabled
Browse files Browse the repository at this point in the history
Test if throttleTime emits when only a single value is emitted from the
source with leading enabled/disabled and trailing enabled.
  • Loading branch information
MatthiasKunnen committed Feb 14, 2019
1 parent 82482b2 commit 2db0016
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/operators/throttleTime-spec.ts
Expand Up @@ -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 })', () => {
Expand All @@ -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);
});
});
});

0 comments on commit 2db0016

Please sign in to comment.