Skip to content

Commit

Permalink
Merge pull request #5567 from kwonoj/deprecate-old-type-test
Browse files Browse the repository at this point in the history
test(type): deprecate legacy type test
  • Loading branch information
kwonoj committed Jul 3, 2020
2 parents 45702bf + 99bd9b9 commit 7fc5312
Show file tree
Hide file tree
Showing 25 changed files with 11 additions and 674 deletions.
11 changes: 0 additions & 11 deletions spec/helpers/testScheduler-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,6 @@ module.exports = function(suite: any) {
return suite;
};

/**
* Describe a test case to test type definition
* sanity on build time. Recommended only for
* exceptional type definition won't be used in test cases.
*/

context.type = function(title: any, fn: any) {
//intentionally does not execute to avoid unexpected side effect occurs by subscription,
//or infinite source. Suffecient to check build time only.
};

function stringify(x: any): string {
return JSON.stringify(x, function (key: string, value: any) {
if (Array.isArray(value)) {
Expand Down
2 changes: 0 additions & 2 deletions spec/observables/combineLatest-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { hot, cold, expectObservable, expectSubscriptions } from '../helpers/mar
import { queueScheduler as rxQueueScheduler, combineLatest, of } from 'rxjs';
import { mergeMap } from 'rxjs/operators';

declare const type: Function;

const queueScheduler = rxQueueScheduler;

/** @test {combineLatest} */
Expand Down
2 changes: 0 additions & 2 deletions spec/observables/forkJoin-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { forkJoin, of } from 'rxjs';
import { lowerCaseO } from '../helpers/test-helper';
import { hot, expectObservable, expectSubscriptions, cold } from '../helpers/marble-testing';

declare const type: Function;

/** @test {forkJoin} */
describe('forkJoin', () => {
it('should join the last values of the provided observables into an array', () => {
Expand Down
17 changes: 1 addition & 16 deletions spec/observables/from-spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect } from 'chai';
import { TestScheduler } from 'rxjs/testing';
import { asyncScheduler, of, from, Observable, asapScheduler, Observer, observable, Subject, EMPTY } from 'rxjs';
import { asyncScheduler, of, from, Observer, observable, Subject } from 'rxjs';
import { first, concatMap, delay } from 'rxjs/operators';

// tslint:disable:no-any
declare const expectObservable: any;
declare const type: any;
declare const rxTestScheduler: TestScheduler;
// tslint:enable:no-any

Expand Down Expand Up @@ -35,20 +34,6 @@ describe('from', () => {
expect(r).to.throw();
});

type('should return T for InteropObservable objects', () => {
/* tslint:disable:no-unused-variable */
const o1: Observable<number> = from([] as number[], asapScheduler);
const o2: Observable<{ a: string }> = from(EMPTY);
const o3: Observable<{ b: number }> = from(new Promise<{b: number}>(resolve => resolve()));
/* tslint:enable:no-unused-variable */
});

type('should return T for arrays', () => {
/* tslint:disable:no-unused-variable */
const o1: Observable<number> = from([] as number[], asapScheduler);
/* tslint:enable:no-unused-variable */
});

const fakervable = <T>(...values: T[]) => ({
[observable]: () => ({
subscribe: (observer: Observer<T>) => {
Expand Down
46 changes: 1 addition & 45 deletions spec/observables/fromEvent-spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { expect } from 'chai';
import { expectObservable } from '../helpers/marble-testing';
import { Observable, fromEvent, NEVER, timer } from 'rxjs';
import { NodeStyleEventEmitter, NodeCompatibleEventEmitter, NodeEventHandler } from 'rxjs/internal/observable/fromEvent';
import { fromEvent, NEVER, timer } from 'rxjs';
import { mapTo, take, concat } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';

declare const type: Function;

declare const rxTestScheduler: TestScheduler;

/** @test {fromEvent} */
Expand Down Expand Up @@ -395,45 +392,4 @@ describe('fromEvent', () => {
}).to.not.throw(TypeError);
});

type('should support node style event emitters interfaces', () => {
/* tslint:disable:no-unused-variable */
let a: NodeStyleEventEmitter;
let b: Observable<any> = fromEvent(a!, 'mock');
/* tslint:enable:no-unused-variable */
});

type('should support node compatible event emitters interfaces', () => {
/* tslint:disable:no-unused-variable */
let a: NodeCompatibleEventEmitter;
let b: Observable<any> = fromEvent(a!, 'mock');
/* tslint:enable:no-unused-variable */
});

type('should support node style event emitters objects', () => {
/* tslint:disable:no-unused-variable */
interface NodeEventEmitter {
addListener(eventType: string | symbol, handler: NodeEventHandler): this;
removeListener(eventType: string | symbol, handler: NodeEventHandler): this;
}
let a: NodeEventEmitter;
let b: Observable<any> = fromEvent(a!, 'mock');
/* tslint:enable:no-unused-variable */
});

type('should support React Native event emitters', () => {
/* tslint:disable:no-unused-variable */
interface EmitterSubscription {
context: any;
}
interface ReactNativeEventEmitterListener {
addListener(eventType: string, listener: (...args: any[]) => any, context?: any): EmitterSubscription;
}
interface ReactNativeEventEmitter extends ReactNativeEventEmitterListener {
removeListener(eventType: string, listener: (...args: any[]) => any): void;
}
let a: ReactNativeEventEmitter;
let b: Observable<any> = fromEvent(a!, 'mock');
/* tslint:enable:no-unused-variable */
});

});
53 changes: 1 addition & 52 deletions spec/observables/zip-spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { expect } from 'chai';
import { hot, cold, expectObservable, expectSubscriptions } from '../helpers/marble-testing';
import { queueScheduler as rxQueueScheduler, zip, from, of, Observable } from 'rxjs';

declare const type: Function;
import { queueScheduler as rxQueueScheduler, zip, from, of } from 'rxjs';

declare const Symbol: any;

Expand Down Expand Up @@ -576,53 +574,4 @@ describe('static zip', () => {
expect(vals).to.deep.equal(r[i++]);
}, null, done);
});

type('should support observables', () => {
/* tslint:disable:no-unused-variable */
let a: Observable<number>;
let b: Observable<string>;
let c: Observable<boolean>;
let o1: Observable<[number, string, boolean]> = zip(a!, b!, c!);
/* tslint:enable:no-unused-variable */
});

type('should support mixed observables and promises', () => {
/* tslint:disable:no-unused-variable */
let a: Promise<number>;
let b: Observable<string>;
let c: Promise<boolean>;
let d: Observable<string[]>;
let o1: Observable<[number, string, boolean, string[]]> = zip(a!, b!, c!, d!);
/* tslint:enable:no-unused-variable */
});

type('should support arrays of promises', () => {
/* tslint:disable:no-unused-variable */
let a: Promise<number>[];
let o1: Observable<number[]> = zip(a!);
let o2: Observable<number[]> = zip(...a!);
/* tslint:enable:no-unused-variable */
});

type('should support arrays of observables', () => {
/* tslint:disable:no-unused-variable */
let a: Observable<number>[];
let o1: Observable<number[]> = zip(a!);
let o2: Observable<number[]> = zip(...a!);
/* tslint:enable:no-unused-variable */
});

type('should return Array<T> when given a single promise', () => {
/* tslint:disable:no-unused-variable */
let a: Promise<number>;
let o1: Observable<number[]> = zip(a!);
/* tslint:enable:no-unused-variable */
});

type('should return Array<T> when given a single observable', () => {
/* tslint:disable:no-unused-variable */
let a: Observable<number>;
let o1: Observable<number[]> = zip(a!);
/* tslint:enable:no-unused-variable */
});
});
102 changes: 1 addition & 101 deletions spec/operators/combineAll-spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { expect } from 'chai';
import { queueScheduler, of, Observable } from 'rxjs';
import { queueScheduler, of } from 'rxjs';
import { combineAll, mergeMap } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { observableMatcher } from '../helpers/observableMatcher';

declare const type: Function;

/** @test {combineAll} */
describe('combineAll operator', () => {
let testScheduler: TestScheduler;
Expand Down Expand Up @@ -543,102 +541,4 @@ describe('combineAll operator', () => {
done();
});
});

type(() => {
/* tslint:disable:no-unused-variable */
const source1 = of(1, 2, 3);
const source2 = [1, 2, 3];
const source3 = new Promise<number>(d => d(1));

let result: Observable<number[]> = of(source1, source2, source3).pipe(combineAll());
/* tslint:enable:no-unused-variable */
});

type(() => {
/* tslint:disable:no-unused-variable */
const source1 = of(1, 2, 3);
const source2 = [1, 2, 3];
const source3 = new Promise<number>(d => d(1));

let result: Observable<number> = of(source1, source2, source3).pipe(
combineAll((...args) => args.reduce((acc, x) => acc + x, 0))
);
/* tslint:enable:no-unused-variable */
});

type(() => {
/* tslint:disable:no-unused-variable */
const source1 = of(1, 2, 3);
const source2 = [1, 2, 3];
const source3 = new Promise<number>(d => d(1));

let result: Observable<number[]> = of(source1, source2, source3).pipe(
combineAll()
);
/* tslint:enable:no-unused-variable */
});

type(() => {
/* tslint:disable:no-unused-variable */
const source1 = of(1, 2, 3);
const source2 = [1, 2, 3];
const source3 = new Promise<number>(d => d(1));

let result: Observable<number> = of(source1, source2, source3).pipe(
combineAll((...args) => args.reduce((acc, x) => acc + x, 0))
);
/* tslint:enable:no-unused-variable */
});

type(() => {
// coerce type to a specific type
/* tslint:disable:no-unused-variable */
const source1 = of(1, 2, 3);
const source2 = [1, 2, 3];
const source3 = new Promise<number>(d => d(1));

let result: Observable<string[]> = of(<any>source1, <any>source2, <any>source3).pipe(
combineAll<string>()
);
/* tslint:enable:no-unused-variable */
});

type(() => {
// coerce type to a specific type
/* tslint:disable:no-unused-variable */
const source1 = of(1, 2, 3);
const source2 = [1, 2, 3];
const source3 = new Promise<number>(d => d(1));

let result: Observable<string> = of(<any>source1, <any>source2, <any>source3).pipe(
combineAll<string>((...args) => args.reduce((acc, x) => acc + x, 0))
);
/* tslint:enable:no-unused-variable */
});

type(() => {
// coerce type to a specific type
/* tslint:disable:no-unused-variable */
const source1 = of(1, 2, 3);
const source2 = [1, 2, 3];
const source3 = new Promise<number>(d => d(1));

let result: Observable<string[]> = of(<any>source1, <any>source2, <any>source3).pipe(
combineAll<string>()
);
/* tslint:enable:no-unused-variable */
});

type(() => {
// coerce type to a specific type
/* tslint:disable:no-unused-variable */
const source1 = of(1, 2, 3);
const source2 = [1, 2, 3];
const source3 = new Promise<number>(d => d(1));

let result: Observable<string> = of(<any>source1, <any>source2, <any>source3).pipe(
combineAll<string>((...args) => args.reduce((acc, x) => acc + x, 0))
);
/* tslint:enable:no-unused-variable */
});
});
57 changes: 1 addition & 56 deletions spec/operators/concatAll-spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { expect } from 'chai';
import { from, throwError, of, Observable } from 'rxjs';
import { from, throwError, of } from 'rxjs';
import { concatAll, take, mergeMap } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { observableMatcher } from '../helpers/observableMatcher';

declare const type: Function;
declare const rxTestScheduler: TestScheduler;

/** @test {concatAll} */
Expand Down Expand Up @@ -523,58 +522,4 @@ describe('concatAll operator', () => {
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});
});

type(() => {
/* tslint:disable:no-unused-variable */
const source1 = of(1, 2, 3);
const source2 = [1, 2, 3];
const source3 = new Promise<number>(d => d(1));

let result: Observable<number> = of(source1, source2, source3).pipe(
concatAll()
);
/* tslint:enable:no-unused-variable */
});

type(() => {
/* tslint:disable:no-unused-variable */
const source1 = of(1, 2, 3);
const source2 = [1, 2, 3];
const source3 = new Promise<number>(d => d(1));

let result: Observable<number> = of(source1, source2, source3).pipe(
concatAll()
);
/* tslint:enable:no-unused-variable */
});

type(() => {
// coerce type to a specific type
/* tslint:disable:no-unused-variable */
const source1 = of(1, 2, 3);
const source2 = [1, 2, 3];
const source3 = new Promise<number>(d => d(1));

let result: Observable<string> = of(
<any>source1,
<any>source2,
<any>source3
).pipe(concatAll<string>());
/* tslint:enable:no-unused-variable */
});

type(() => {
// coerce type to a specific type
/* tslint:disable:no-unused-variable */
const source1 = of(1, 2, 3);
const source2 = [1, 2, 3];
const source3 = new Promise<number>(d => d(1));

let result: Observable<string> = of(
<any>source1,
<any>source2,
<any>source3
).pipe(concatAll<string>());
/* tslint:enable:no-unused-variable */
});
});

0 comments on commit 7fc5312

Please sign in to comment.