Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(throttle): test leading: false #6296

Merged
merged 1 commit into from
May 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 14 additions & 14 deletions spec/operators/throttle-spec.ts
Original file line number Diff line number Diff line change
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