From 34deda594fdbac149bfeda0d46776269131508eb Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Thu, 3 Sep 2015 14:45:25 -0700 Subject: [PATCH] fix(test_lib): add missing types --- modules/angular2/core.ts | 1 + .../angular2/src/core/debug/debug_element.ts | 6 +++++ .../core/debug/debug_element_view_listener.ts | 2 +- modules/angular2/src/test_lib/fake_async.ts | 2 +- modules/angular2/src/test_lib/test_lib.ts | 22 +++++++++---------- modules/angular2/src/test_lib/utils.ts | 4 ++-- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/modules/angular2/core.ts b/modules/angular2/core.ts index 9765aa8776..f8fbb63a6a 100644 --- a/modules/angular2/core.ts +++ b/modules/angular2/core.ts @@ -28,3 +28,4 @@ export {ComponentRef} from 'angular2/src/core/compiler/dynamic_component_loader' export {NgZone} from 'angular2/src/core/zone/ng_zone'; export {Observable, EventEmitter} from 'angular2/src/core/facade/async'; +export {Predicate} from 'angular2/src/core/facade/collection'; diff --git a/modules/angular2/src/core/debug/debug_element.ts b/modules/angular2/src/core/debug/debug_element.ts index 39a6787b5e..cd9dbe3ea7 100644 --- a/modules/angular2/src/core/debug/debug_element.ts +++ b/modules/angular2/src/core/debug/debug_element.ts @@ -137,6 +137,12 @@ export class DebugElement { } } +/** + * Returns a DebugElement for a ElementRef. + * + * @param {ElementRef}: elementRef + * @return {DebugElement} + */ export function inspectElement(elementRef: ElementRef): DebugElement { return DebugElement.create(elementRef); } diff --git a/modules/angular2/src/core/debug/debug_element_view_listener.ts b/modules/angular2/src/core/debug/debug_element_view_listener.ts index 9e9711723b..e3cb8d9a63 100644 --- a/modules/angular2/src/core/debug/debug_element_view_listener.ts +++ b/modules/angular2/src/core/debug/debug_element_view_listener.ts @@ -68,7 +68,7 @@ export class DebugElementViewListener implements AppViewListener { } } -export const ELEMENT_PROBE_BINDINGS = CONST_EXPR([ +export const ELEMENT_PROBE_BINDINGS: any[] = CONST_EXPR([ DebugElementViewListener, CONST_EXPR(new Binding(AppViewListener, {toAlias: DebugElementViewListener})), ]); diff --git a/modules/angular2/src/test_lib/fake_async.ts b/modules/angular2/src/test_lib/fake_async.ts index 1200b37a97..7bd169f274 100644 --- a/modules/angular2/src/test_lib/fake_async.ts +++ b/modules/angular2/src/test_lib/fake_async.ts @@ -65,7 +65,7 @@ export function fakeAsync(fn: Function): Function { } // TODO we should fix tick to dequeue the failed timer instead of relying on clearPendingTimers -export function clearPendingTimers() { +export function clearPendingTimers(): void { ListWrapper.clear(_microtasks); ListWrapper.clear(_pendingPeriodicTimers); ListWrapper.clear(_pendingTimers); diff --git a/modules/angular2/src/test_lib/test_lib.ts b/modules/angular2/src/test_lib/test_lib.ts index 1076218547..048244489a 100644 --- a/modules/angular2/src/test_lib/test_lib.ts +++ b/modules/angular2/src/test_lib/test_lib.ts @@ -16,9 +16,9 @@ export var proxy: ClassDecorator = (t) => t; var _global: jasmine.GlobalPolluter = (typeof window === 'undefined' ? global : window); -export var afterEach = _global.afterEach; +export var afterEach: Function = _global.afterEach; -type SyncTestFn = () => void; +export type SyncTestFn = () => void; type AsyncTestFn = (done: () => void) => void; type AnyTestFn = SyncTestFn | AsyncTestFn; @@ -88,19 +88,19 @@ function _describe(jsmFn, ...args) { return suite; } -export function describe(...args) { +export function describe(...args): void { return _describe(jsmDescribe, ...args); } -export function ddescribe(...args) { +export function ddescribe(...args): void { return _describe(jsmDDescribe, ...args); } -export function xdescribe(...args) { +export function xdescribe(...args): void { return _describe(jsmXDescribe, ...args); } -export function beforeEach(fn: FunctionWithParamTokens | SyncTestFn) { +export function beforeEach(fn: FunctionWithParamTokens | SyncTestFn): void { if (runnerStack.length > 0) { // Inside a describe block, beforeEach() uses a BeforeEachRunner runnerStack[runnerStack.length - 1].beforeEach(fn); @@ -122,7 +122,7 @@ export function beforeEach(fn: FunctionWithParamTokens | SyncTestFn) { * bind(SomeToken).toValue(myValue), * ]); */ -export function beforeEachBindings(fn) { +export function beforeEachBindings(fn): void { jsmBeforeEach(() => { var bindings = fn(); if (!bindings) return; @@ -131,7 +131,7 @@ export function beforeEachBindings(fn) { } function _it(jsmFn: Function, name: string, testFn: FunctionWithParamTokens | AnyTestFn, - timeOut: number) { + timeOut: number): void { var runner = runnerStack[runnerStack.length - 1]; if (testFn instanceof FunctionWithParamTokens) { @@ -183,15 +183,15 @@ function _it(jsmFn: Function, name: string, testFn: FunctionWithParamTokens | An } } -export function it(name, fn, timeOut = null) { +export function it(name, fn, timeOut = null): void { return _it(jsmIt, name, fn, timeOut); } -export function xit(name, fn, timeOut = null) { +export function xit(name, fn, timeOut = null): void { return _it(jsmXIt, name, fn, timeOut); } -export function iit(name, fn, timeOut = null) { +export function iit(name, fn, timeOut = null): void { return _it(jsmIIt, name, fn, timeOut); } diff --git a/modules/angular2/src/test_lib/utils.ts b/modules/angular2/src/test_lib/utils.ts index 6baa3ab309..7b61878078 100644 --- a/modules/angular2/src/test_lib/utils.ts +++ b/modules/angular2/src/test_lib/utils.ts @@ -58,9 +58,9 @@ export class BrowserDetection { return this._ua.indexOf('Chrome/4') > -1 && this._ua.indexOf('Edge') == -1; } } -export var browserDetection = new BrowserDetection(null); +export var browserDetection: BrowserDetection = new BrowserDetection(null); -export function dispatchEvent(element, eventType) { +export function dispatchEvent(element, eventType): void { DOM.dispatchEvent(element, DOM.createEvent(eventType)); }