forked from ReactiveX/rxjs
/
delayWhen-spec.ts
33 lines (26 loc) · 1.37 KB
/
delayWhen-spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { of, NEVER } from 'rxjs';
import { delayWhen } from 'rxjs/operators';
it('should infer correctly', () => {
const o = of(1, 2, 3).pipe(delayWhen(() => of('a', 'b', 'c'))); // $ExpectType Observable<number>
const p = of(1, 2, 3).pipe(delayWhen((value: number, index: number) => of('a', 'b', 'c'))); // $ExpectType Observable<number>
});
it('should support an empty notifier', () => {
const o = of(1, 2, 3).pipe(delayWhen(() => NEVER)); // $ExpectType Observable<number>
});
it('should support a subscriptionDelay parameter', () => {
const o = of(1, 2, 3).pipe(delayWhen(() => of('a', 'b', 'c'), of(new Date()))); // $ExpectType Observable<number>
});
it('should enforce types', () => {
const o = of(1, 2, 3).pipe(delayWhen()); // $ExpectError
});
it('should enforce types of delayDurationSelector', () => {
const o = of(1, 2, 3).pipe(delayWhen(of('a', 'b', 'c'))); // $ExpectError
const p = of(1, 2, 3).pipe(delayWhen((value: string, index) => of('a', 'b', 'c'))); // $ExpectError
const q = of(1, 2, 3).pipe(delayWhen((value, index: string) => of('a', 'b', 'c'))); // $ExpectError
});
it('should enforce types of subscriptionDelay', () => {
const o = of(1, 2, 3).pipe(delayWhen(() => of('a', 'b', 'c'), 'a')); // $ExpectError
});
it('should support Promises', () => {
const o = of(1, 2, 3).pipe(delayWhen(() => Promise.resolve('a'))); // $ExpectType Observable<number>
});