Skip to content

Commit

Permalink
test(dtslint): change of observable static function dtslint test to u…
Browse files Browse the repository at this point in the history
…se helper (ReactiveX#4093)
  • Loading branch information
dkosasih committed Jan 29, 2019
1 parent b3dd91e commit 1f0c8a7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 13 deletions.
23 changes: 23 additions & 0 deletions spec-dtslint/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { of } from 'rxjs';

export class A { a = 0; }
export class B { b = 0; }
export class C { c = 0; }
export class D { d = 0; }
export class E { e = 0; }
export class F { f = 0; }
export class G { g = 0; }
export class H { h = 0; }
export class I { i = 0; }
export class J { j = 0; }

export const a = of(new A());
export const b = of(new B());
export const c = of(new C());
export const d = of(new D());
export const e = of(new E());
export const f = of(new F());
export const g = of(new G());
export const h = of(new H());
export const i = of(new I());
export const j = of(new J());
38 changes: 25 additions & 13 deletions spec-dtslint/observables/of-spec.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,65 @@
import { of, animationFrameScheduler } from 'rxjs';
import { A, B, C, D, E, F, G, H, I, J } from '../helpers';

const a = new A();
const b = new B();
const c = new C();
const d = new D();
const e = new E();
const f = new F();
const g = new G();
const h = new H();
const i = new I();
const j = new J();

it('should infer correctly with 1 param', () => {
const a = of(1);
const res = of(new A()); // $ExpectType Observable<A>
});

it('should infer correcly with mixed type of 2 params', () => {
const a = of(1, 'a'); // $ExpectType Observable<string | number>
const res = of(a, b); // $ExpectType Observable<A | B>
});

it('should infer correcly with mixed type of 3 params', () => {
const a = of(1, 'a', 2); // $ExpectType Observable<string | number>
const res = of(a, b, c); // $ExpectType Observable<A | B | C>
});

it('should infer correcly with mixed type of 4 params', () => {
const a = of(1, 'a', 2, 3); // $ExpectType Observable<string | number>
const res = of(a, b, c, d); // $ExpectType Observable<A | B | C | D>
});

it('should infer correcly with mixed type of 5 params', () => {
const a = of(1, 'a', 2, 3, 4); // $ExpectType Observable<string | number>
const res = of(a, b, c, d, e); // $ExpectType Observable<A | B | C | D | E>
});

it('should infer correcly with mixed type of 6 params', () => {
const a = of(1, 'a', 2, 3, 4, 5); // $ExpectType Observable<string | number>
const res = of(a, b, c, d, e, f); // $ExpectType Observable<A | B | C | D | E | F>
});

it('should infer correcly with mixed type of 7 params', () => {
const a = of(1, 'a', 2, 3, 4, 5, 6); // $ExpectType Observable<string | number>
const res = of(a, b, c, d, e, f, g); // $ExpectType Observable<A | B | C | D | E | F | G>
});

it('should infer correcly with mixed type of 8 params', () => {
const a = of(1, 'a', 2, 3, 4, 5, 6, 7); // $ExpectType Observable<string | number>
const res = of(a, b, c, d, e, f, g, h); // $ExpectType Observable<A | B | C | D | E | F | G | H>
});

it('should infer correcly with mixed type of 9 params', () => {
const a = of(1, 'a', 2, 3, 4, 5, 6, 7, 8); // $ExpectType Observable<string | number>
const res = of(a, b, c, d, e, f, g, h, i); // $ExpectType Observable<A | B | C | D | E | F | G | H | I>
});

it('should infer correcly with mono type of more than 9 params', () => {
const a = of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); // $ExpectType Observable<number>
const res = of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); // $ExpectType Observable<number>
});

it('should not support mixed type of more than 9 params', () => {
const a = of(1, 'a', 2, 3, 4, 5, 6, 7, 8, 9); // $ExpectError
const res = of(a, b, c, d, e, f, g, h, i, j); // $ExpectError
});

it('should support scheduler', () => {
const a = of(1, animationFrameScheduler); // $ExpectType Observable<number>
const res = of(a, animationFrameScheduler); // $ExpectType Observable<A>
});

it('should infer correctly with array', () => {
const a = of([1, 2, 3]); // $ExpectType Observable<number[]>
const res = of([a, b, c]); // $ExpectType Observable<(A | B | C)[]>
});

0 comments on commit 1f0c8a7

Please sign in to comment.