Skip to content

Commit

Permalink
fix(throttleTime): add back asDiagram specs
Browse files Browse the repository at this point in the history
  • Loading branch information
sod committed Sep 26, 2017
1 parent 9cda512 commit 9fc78aa
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/operators/throttleTime-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,32 @@ describe('Observable.prototype.throttleTime', () => {
expectObservable(e1.throttleTime(50, rxTestScheduler)).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(subs);
});

describe('throttleTime(fn, { leading: true, trailing: true })', () => {
asDiagram('throttleTime(fn, { leading: true, trailing: true })')('should immediately emit the first value in each time window', () => {
const e1 = hot('-a-xy-----b--x--cxxx---|');
const e1subs = '^ !';
const t = time( '----| ');
const expected = '-a---y----b---x---x---x|';

const result = e1.throttleTime(t, rxTestScheduler, { leading: true, trailing: true });

expectObservable(result).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});
});

describe('throttleTime(fn, { leading: false, trailing: true })', () => {
asDiagram('throttleTime(fn, { leading: false, trailing: true })')('should emit last given value in each time window', () => {
const e1 = hot('-a-xy-----b--x--cxcd---|');
const e1subs = '^ !';
const t = time( '----| ');
const expected = '-----y--------x---c---d|';

const result = e1.throttleTime(t, rxTestScheduler, { leading: false, trailing: true });

expectObservable(result).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});
});
});

0 comments on commit 9fc78aa

Please sign in to comment.