-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test(dtslint): add race * test(dtslint): remove type check
- Loading branch information
1 parent
441d522
commit 9b4f358
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { of } from 'rxjs'; | ||
import { race } from 'rxjs/operators'; | ||
|
||
it('should infer correctly', () => { | ||
const o = of('a', 'b', 'c').pipe(race()); // $ExpectType Observable<string> | ||
}); | ||
|
||
it('should allow observables', () => { | ||
const o = of('a', 'b', 'c').pipe(race(of('x', 'y', 'z'))); // $ExpectType Observable<string> | ||
const p = of('a', 'b', 'c').pipe(race(of('x', 'y', 'z'), of('t', 'i', 'm'))); // $ExpectType Observable<string> | ||
}); | ||
|
||
it('should allow an array of observables', () => { | ||
const o = of('a', 'b', 'c').pipe(race([of('x', 'y', 'z')])); // $ExpectType Observable<string> | ||
const p = of('a', 'b', 'c').pipe(race([of('x', 'y', 'z'), of('t', 'i', 'm')])); // $ExpectType Observable<string> | ||
}); | ||
|
||
it('should be possible to provide a return type', () => { | ||
const o = of('a', 'b', 'c').pipe(race<string, number>([of(1, 2, 3)])); // $ExpectType Observable<number> | ||
const p = of('a', 'b', 'c').pipe(race<string, number>([of(1, 2, 3), of('t', 'i', 'm')])); // $ExpectType Observable<number> | ||
const q = of('a', 'b', 'c').pipe(race<string, number>(of(1, 2, 3), [of(1, 2, 3)])); // $ExpectType Observable<number> | ||
const r = of('a', 'b', 'c').pipe(race<string, number>([of(1, 2, 3)], of('t', 'i', 'm'))); // $ExpectType Observable<number> | ||
}); | ||
|
||
it('should be possible to use nested arrays', () => { | ||
const o = of('a', 'b', 'c').pipe(race([of('x', 'y', 'z')])); // $ExpectType Observable<string> | ||
}); | ||
|
||
it('should enforce types', () => { | ||
const o = of('a', 'b', 'c').pipe(race('aa')); // $ExpectError | ||
}); | ||
|
||
it('should enforce argument types when not provided ', () => { | ||
const o = of('a', 'b', 'c').pipe(race(of(1, 2, 3))); // $ExpectError | ||
const p = of('a', 'b', 'c').pipe(race([of(1, 2, 3)])); // $ExpectError | ||
}); |