Skip to content

Commit

Permalink
test(dtslint): add dtslint test for merge operator (#4093) (#4392)
Browse files Browse the repository at this point in the history
* test(dtslint): add dtslint test for merge operator (#4093)

* test(dtslint): change dtslint test for merge operator to use helpers (#4093)
  • Loading branch information
dkosasih authored and benlesh committed Aug 1, 2019
1 parent ba8a95f commit 596b0e8
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec-dtslint/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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 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());
88 changes: 88 additions & 0 deletions spec-dtslint/operators/merge-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { of, asyncScheduler } from 'rxjs';
import { merge } from 'rxjs/operators';
import { A, B, C, D, E, F, G, a, b, c, d, e, f, g } from '../helpers';

it('should accept no parameter', () => {
const res = a.pipe(merge()); // $ExpectType Observable<A>
});

it('should infer correctly with scheduler param', () => {
const res = a.pipe(merge(asyncScheduler)); // $ExpectType Observable<A>
});

it('should infer correctly with concurrent param', () => {
const res = a.pipe(merge(3)); // $ExpectType Observable<A>
});

it('should infer correctly with concurrent and scheduler param', () => {
const res = a.pipe(merge(3, asyncScheduler)); // $ExpectType Observable<A>
});

it('should infer correctly with 1 Observable param', () => {
const res = a.pipe(merge(b)); // $ExpectType Observable<A | B>
});

it('should infer correctly with 2 Observable param', () => {
const res = a.pipe(merge(b, c)); // $ExpectType Observable<A | B | C>
});

it('should infer correctly with 3 Observable param', () => {
const res = a.pipe(merge(b, c, d)); // $ExpectType Observable<A | B | C | D>
});

it('should infer correctly with 4 Observable param', () => {
const res = a.pipe(merge(b, c, d, e)); // $ExpectType Observable<A | B | C | D | E>
});

it('should infer correctly with 5 Observable param', () => {
const res = a.pipe(merge(b, c, d, e, f)); // $ExpectType Observable<A | B | C | D | E | F>
});

it('should infer correctly with 1 Observable and concurrent param', () => {
const res = a.pipe(merge(b, 1)); // $ExpectType Observable<A | B>
});

it('should infer correctly with 2 Observable and concurrent param', () => {
const res = a.pipe(merge(b, c, 1)); // $ExpectType Observable<A | B | C>
});

it('should infer correctly with 3 Observable and concurrent param', () => {
const res = a.pipe(merge(b, c, d, 1)); // $ExpectType Observable<A | B | C | D>
});

it('should infer correctly with 4 Observable and concurrent param', () => {
const res = a.pipe(merge(b, c, d, e, 1)); // $ExpectType Observable<A | B | C | D | E>
});

it('should infer correctly with 5 Observable and concurrent param', () => {
const res = a.pipe(merge(b, c, d, e, f, 1)); // $ExpectType Observable<A | B | C | D | E | F>
});

it('should infer correctly with 1 Observable, concurrent, and scheduler param', () => {
const res = a.pipe(merge(b, 1, asyncScheduler)); // $ExpectType Observable<A | B>
});

it('should infer correctly with 2 Observable, concurrent, and scheduler param', () => {
const res = a.pipe(merge(b, c, 1, asyncScheduler)); // $ExpectType Observable<A | B | C>
});

it('should infer correctly with 3 Observable, concurrent, and scheduler param', () => {
const res = a.pipe(merge(b, c, d, 1, asyncScheduler)); // $ExpectType Observable<A | B | C | D>
});

it('should infer correctly with 4 Observable, concurrent, and scheduler param', () => {
const res = a.pipe(merge(b, c, d, e, 1, asyncScheduler)); // $ExpectType Observable<A | B | C | D | E>
});

it('should infer correctly with 5 Observable, concurrent, and scheduler param', () => {
const res = a.pipe(merge(b, c, d, e, f, 1, asyncScheduler)); // $ExpectType Observable<A | B | C | D | E | F>
});

// TODO: Fix this when the both merge operator and merge creator function has been fix
// see: https://github.com/ReactiveX/rxjs/pull/4371#issuecomment-441124096
// Comment is about combineLater, but, it's the same problem to fix
// it('should infer correctly with array param', () => {
// const res = of(1, 2, 3);
// const b = [of('a', 'b', 'c')];
// const res = a.pipe(merge(b)); // $ExpectType Observable<number|Observable<string>>
// });

0 comments on commit 596b0e8

Please sign in to comment.