Skip to content

Commit

Permalink
test(throttle): test leading: false (#6296)
Browse files Browse the repository at this point in the history
Closes #5360
  • Loading branch information
cartant committed May 4, 2021
1 parent 2f0f91e commit 6d62574
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions spec/operators/throttle-spec.ts
Expand Up @@ -455,9 +455,9 @@ describe('throttle', () => {
' ------------------^---! ',
' ----------------------^---!',
];
const expected = '-a---y----b---x---x---x---|';
const expected = '-----y--------x---x---x---|';

const result = e1.pipe(throttle(() => e2, { leading: true, trailing: true }));
const result = e1.pipe(throttle(() => e2, { leading: false, trailing: true }));

expectObservable(result).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
Expand All @@ -467,13 +467,13 @@ describe('throttle', () => {

it('should work for individual values', () => {
testScheduler.run(({ cold, hot, expectObservable, expectSubscriptions }) => {
const s1 = hot('-^-x------------------| ');
const s1Subs = ' ^--------------------! ';
const n1 = cold(' ------------------------x');
const n1Subs = ['--^------------------! '];
const exp = ' --x------------------| ';
const s1 = hot('-^-x------------------| ');
const s1Subs = ' ^--------------------! ';
const n1 = cold(' ------------------------x ');
const n1Subs = ['--^-----------------------! '];
const exp = ' --------------------------(x|)';

const result = s1.pipe(throttle(() => n1, { leading: true, trailing: true }));
const result = s1.pipe(throttle(() => n1, { leading: false, trailing: true }));
expectObservable(result).toBe(exp);
expectSubscriptions(s1.subscriptions).toBe(s1Subs);
expectSubscriptions(n1.subscriptions).toBe(n1Subs);
Expand All @@ -482,13 +482,13 @@ describe('throttle', () => {

it('should wait for trailing throttle before completing, even if source completes', () => {
testScheduler.run(({ cold, hot, expectObservable, expectSubscriptions }) => {
const source = hot(' -^--x--------y---------|');
const sourceSubs = ' ^---------------------!';
const duration = cold(' ------------------------x');
const durationSubs = ' ---^-----------------------!';
const exp = ' ---x-----------------------(y|)';
const source = hot(' -^--x--------y---------| ');
const sourceSubs = ' ^---------------------! ';
const duration = cold(' ------------------------x ');
const durationSubs = ' ---^-----------------------! ';
const exp = ' ---------------------------(y|)';

const result = source.pipe(throttle(() => duration, { leading: true, trailing: true }));
const result = source.pipe(throttle(() => duration, { leading: false, trailing: true }));
expectObservable(result).toBe(exp);
expectSubscriptions(source.subscriptions).toBe(sourceSubs);
expectSubscriptions(duration.subscriptions).toBe(durationSubs);
Expand Down

0 comments on commit 6d62574

Please sign in to comment.