Skip to content

Commit

Permalink
test(dtslint): add race (#4344)
Browse files Browse the repository at this point in the history
* test(dtslint): add race

* test(dtslint): remove type check
  • Loading branch information
timdeschryver authored and benlesh committed Jan 29, 2019
1 parent 441d522 commit 9b4f358
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions spec-dtslint/operators/race-spec.ts
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
});

0 comments on commit 9b4f358

Please sign in to comment.