Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(typings): Added tests for typings. #1189

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"build_closure": "java -jar ./node_modules/google-closure-compiler/compiler.jar ./dist/global/Rx.umd.js --language_in ECMASCRIPT5 --create_source_map ./dist/global/Rx.umd.min.js.map --js_output_file ./dist/global/Rx.umd.min.js",
"build_global": "rm -rf dist/global && mkdir \"dist/global\" && node tools/make-umd-bundle.js && node tools/make-system-bundle.js && npm run build_closure",
"build_perf": "npm run build_cjs && npm run build_global && webdriver-manager update && npm run perf",
"build_test": "rm -rf dist/ && npm run lint && npm run build_cjs && jasmine",
"build_test": "rm -rf dist/ && npm run lint && npm run build_cjs && tsc spec/typings/typing-tpecs.ts --outDir dist/tpec --target ES6 --diagnostics --pretty && jasmine",
"build_cover": "rm -rf dist/ && npm run lint && npm run build_cjs && npm run cover",
"build_docs": "./docgen.sh",
"lint_perf": "eslint perf/",
Expand Down
47 changes: 47 additions & 0 deletions spec/typings/observable/bindCallback-tpec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {BoundCallbackObservable} from '../../../src/observable/bindCallback';
import {Observable} from '../../../src/Observable';
import {asap} from '../../../src/scheduler/asap';

type t = { a: string };
type t2 = { b: string };
type t3 = { c: string };
type t4 = { d: string };
type t5 = { e: string };
type t6 = { f: string };

let observable: Observable<t>;
let observable2: Observable<t2>;
let observable3: Observable<t3>;
let observable4: Observable<t4>;
let observable5: Observable<t5>;
let observable6: Observable<t6>;
let numberObservable: Observable<number>;
let booleanObservable: Observable<boolean>;

/* tslint:disable:no-unused-variable *//* tslint:disable:max-line-length */
observable = BoundCallbackObservable.create((callback: (a: t) => void) => { /* */ })();
observable2 = BoundCallbackObservable.create((a: string, callback: (a: t2) => void) => { /* */ })('a');
observable3 = BoundCallbackObservable.create((a: string, b: number, callback: (r: t3) => void) => { /* */ })('a', 2);
observable4 = BoundCallbackObservable.create((a: string, b: number, c: boolean, callback: (r: t4) => void) => { /* */ })('a', 2, false);
observable5 = BoundCallbackObservable.create((a: string, b: number, c: boolean, d: number, callback: (r: t5) => void) => { /* */ })('a', 2, false, 4);
observable6 = BoundCallbackObservable.create((a: string, b: number, c: boolean, d: number, e: string, callback: (r: t6) => void) => { /* */ })('a', 2, false, 4, 'e');
numberObservable = BoundCallbackObservable.create((a: string, b: number, c: boolean, d: number, e: string, f: boolean, callback: (r: number) => void) => { /* */ })('a', 2, false, 4, 'e', true);

observable = BoundCallbackObservable.create((callback: (a: t) => void) => { /* */ }, null, asap)();
observable2 = BoundCallbackObservable.create((a: string, callback: (a: t2) => void) => { /* */ }, null, asap)('a');
observable3 = BoundCallbackObservable.create((a: string, b: number, callback: (r: t3) => void) => { /* */ }, null, asap)('a', 2);
observable4 = BoundCallbackObservable.create((a: string, b: number, c: boolean, callback: (r: t4) => void) => { /* */ }, null, asap)('a', 2, false);
observable5 = BoundCallbackObservable.create((a: string, b: number, c: boolean, d: number, callback: (r: t5) => void) => { /* */ }, null, asap)('a', 2, false, 4);
observable6 = BoundCallbackObservable.create((a: string, b: number, c: boolean, d: number, e: string, callback: (r: t6) => void) => { /* */ }, null, asap)('a', 2, false, 4, 'e');
numberObservable = BoundCallbackObservable.create((a: string, b: number, c: boolean, d: number, e: string, f: boolean, callback: (r: number) => void) => { /* */ }, null, asap)('a', 2, false, 4, 'e', true);

let observableArr: Observable<t[]>;
observableArr = BoundCallbackObservable.create<t[]>((callback: (...args: t2[]) => void) => { /* */ })();

observable6 = BoundCallbackObservable.create((callback: (a: t, b: t2, c: t3) => void) => { /* */ }, (a: t, b: t2, c: t3) => <t6>{}, asap)();
observable = BoundCallbackObservable.create((a: string, callback: (a: t2, b: t3, c: t4) => void) => { /* */ }, (a: t, b: t2, c: t3) => <t>{}, asap)('a');
observable2 = BoundCallbackObservable.create((a: string, b: number, callback: (r: t3, b: t4, c: t5) => void) => { /* */ }, (a: t, b: t2, c: t3) => <t2>{}, asap)('a', 2);
observable3 = BoundCallbackObservable.create((a: string, b: number, c: boolean, callback: (r: t4, b: t5, c: t6) => void) => { /* */ }, (a: t, b: t2, c: t3) => <t3>{}, asap)('a', 2, false);
observable4 = BoundCallbackObservable.create((a: string, b: number, c: boolean, d: number, callback: (r: t5, b: t5, c: t) => void) => { /* */ }, (a: t, b: t2, c: t3) => <t4>{}, asap)('a', 2, false, 4);
observable5 = BoundCallbackObservable.create((a: string, b: number, c: boolean, d: number, e: string, callback: (r: t6, b: t, c: t2) => void) => { /* */ }, (a: t, b: t2, c: t3) => <t5>{}, asap)('a', 2, false, 4, 'e');
booleanObservable = BoundCallbackObservable.create((a: string, b: number, c: boolean, d: number, e: string, f: boolean, callback: (r: number) => void) => { /* */ }, (a: t, b: t2, c: t3) => false, asap)('a', 2, false, 4, 'e', true);
45 changes: 45 additions & 0 deletions spec/typings/operator/combineLatest-tpec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {CombineLatestDeclaration} from '../../../src/operator/combineLatest';
import {Observable} from '../../../src/Observable';

interface Tester<T> extends Observable<T> {
combineLatest: CombineLatestDeclaration<T>;
}

type t = { a: string };
type t2 = { b: string };
type t3 = { c: string };
type t4 = { d: string };
type t5 = { e: string };
type t6 = { f: string };

let observable: Tester<t>;
let observable2: Observable<t2>;
let observable3: Observable<t3>;
let observable4: Observable<t4>;
let observable5: Observable<t5>;
let observable6: Observable<t6>;

/* tslint:disable:no-unused-variable */
let result0: Observable<[t]> = observable.combineLatest();
let result1: Observable<[t, t2]> = observable.combineLatest(observable2);
let result2: Observable<[t, t2, t3]> = observable.combineLatest(observable2, observable3);
let result3: Observable<[t, t2, t3, t4]> = observable.combineLatest(observable2, observable3, observable4);
let result4: Observable<[t, t2, t3, t4, t5]> = observable.combineLatest(observable2, observable3, observable4, observable5);
let result5: Observable<[t, t2, t3, t4, t5, t6]> = observable.combineLatest(observable2, observable3, observable4, observable5, observable6);

let project1: Observable<number> = observable.combineLatest(observable2,
(a, b) => a.a.length + b.b.length);
let project2: Observable<number> = observable.combineLatest(observable2, observable3,
(a, b, c) => a.a.length + b.b.length + c.c.length);
let project3: Observable<number> = observable.combineLatest(observable2, observable3, observable4,
(a, b, c, d) => a.a.length + b.b.length + c.c.length + d.d.length);
let project4: Observable<number> = observable.combineLatest(observable2, observable3, observable4, observable5,
(a, b, c, d, e) => a.a.length + b.b.length + c.c.length + d.d.length + e.e.length);
let project5: Observable<number> = observable.combineLatest(observable2, observable3, observable4, observable5, observable6,
(a, b, c, d, e, f) => a.a.length + b.b.length + c.c.length + d.d.length + e.e.length + f.f.length);

let array: Observable<[t, t2, t3]> = observable.combineLatest<[t, t2, t3]>([observable2, observable3]);
let arrayBool: Observable<boolean> = observable.combineLatest([observable2, observable3], (...args: any[]) => !!args.length);

let rest: Observable<[t, t2, t3]> = observable.combineLatest<[t, t2, t3]>(...[observable2, observable3]);
let restBool: Observable<boolean> = observable.combineLatest(...[observable2, observable3, (...args: any[]) => !!args.length]);
2 changes: 2 additions & 0 deletions spec/typings/typing-tpecs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './observable/bindCallback-tpec';
import './operator/combineLatest-tpec';
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"files": [
"src/Rx.ts",
"src/Rx.KitchenSink.ts"
"src/Rx.KitchenSink.ts",
"spec/typings/typing-tpecs.ts"
]
}