refactor(): use const and let instead of var

This commit is contained in:
Joao Dias
2016-11-12 14:08:58 +01:00
committed by Victor Berchet
parent 73593d4bf3
commit 77ee27c59e
435 changed files with 4637 additions and 4663 deletions

View File

@ -8,7 +8,7 @@
declare var global: any;
var _global = <any>(typeof window === 'undefined' ? global : window);
const _global = <any>(typeof window === 'undefined' ? global : window);
/**
* Wraps a test function in an asynchronous test zone. The test will automatically
@ -57,7 +57,7 @@ export function async(fn: Function): (done: any) => any {
function runInTestZone(fn: Function, finishCallback: Function, failCallback: Function) {
const currentZone = Zone.current;
var AsyncTestZoneSpec = (Zone as any)['AsyncTestZoneSpec'];
const AsyncTestZoneSpec = (Zone as any)['AsyncTestZoneSpec'];
if (AsyncTestZoneSpec === undefined) {
throw new Error(
'AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' +
@ -79,7 +79,7 @@ function runInTestZone(fn: Function, finishCallback: Function, failCallback: Fun
const proxyZone = Zone.current.getZoneWith('ProxyZoneSpec');
const previousDelegate = proxyZoneSpec.getDelegate();
proxyZone.parent.run(() => {
var testZoneSpec: ZoneSpec = new AsyncTestZoneSpec(
const testZoneSpec: ZoneSpec = new AsyncTestZoneSpec(
() => {
// Need to restore the original zone.
currentZone.run(() => {

View File

@ -120,8 +120,8 @@ export function tick(millis: number = 0): void {
* @experimental
*/
export function discardPeriodicTasks(): void {
let zoneSpec = _getFakeAsyncZoneSpec();
let pendingTimers = zoneSpec.pendingPeriodicTimers;
const zoneSpec = _getFakeAsyncZoneSpec();
const pendingTimers = zoneSpec.pendingPeriodicTimers;
zoneSpec.pendingPeriodicTimers.length = 0;
}

View File

@ -255,7 +255,7 @@ export class TestBed implements Injector {
}
if (!this._moduleWithComponentFactories) {
try {
let moduleType = this._createCompilerAndModule();
const moduleType = this._createCompilerAndModule();
this._moduleWithComponentFactories =
this._compiler.compileModuleAndAllComponentsSync(moduleType);
} catch (e) {

View File

@ -17,7 +17,7 @@ import {TestBed} from './test_bed';
declare var global: any;
var _global = <any>(typeof window === 'undefined' ? global : window);
const _global = <any>(typeof window === 'undefined' ? global : window);
// Reset the test providers and the fake async zone before each test.
if (_global.beforeEach) {

View File

@ -21,24 +21,24 @@ export * from './ng_zone_mock';
export var proxy: ClassDecorator = (t: any) => t;
var _global = <any>(typeof window === 'undefined' ? global : window);
const _global = <any>(typeof window === 'undefined' ? global : window);
export var afterEach: Function = _global.afterEach;
export var expect: (actual: any) => jasmine.Matchers = _global.expect;
var jsmBeforeEach = _global.beforeEach;
var jsmDescribe = _global.describe;
var jsmDDescribe = _global.fdescribe;
var jsmXDescribe = _global.xdescribe;
var jsmIt = _global.it;
var jsmIIt = _global.fit;
var jsmXIt = _global.xit;
const jsmBeforeEach = _global.beforeEach;
const jsmDescribe = _global.describe;
const jsmDDescribe = _global.fdescribe;
const jsmXDescribe = _global.xdescribe;
const jsmIt = _global.it;
const jsmIIt = _global.fit;
const jsmXIt = _global.xit;
var runnerStack: BeforeEachRunner[] = [];
const runnerStack: BeforeEachRunner[] = [];
jasmine.DEFAULT_TIMEOUT_INTERVAL = 3000;
var globalTimeOut = jasmine.DEFAULT_TIMEOUT_INTERVAL;
const globalTimeOut = jasmine.DEFAULT_TIMEOUT_INTERVAL;
var testBed = getTestBed();
const testBed = getTestBed();
/**
* Mechanism to run `beforeEach()` functions of Angular tests.
@ -62,10 +62,10 @@ class BeforeEachRunner {
jsmBeforeEach(() => { testBed.resetTestingModule(); });
function _describe(jsmFn: Function, ...args: any[]) {
var parentRunner = runnerStack.length === 0 ? null : runnerStack[runnerStack.length - 1];
var runner = new BeforeEachRunner(parentRunner);
const parentRunner = runnerStack.length === 0 ? null : runnerStack[runnerStack.length - 1];
const runner = new BeforeEachRunner(parentRunner);
runnerStack.push(runner);
var suite = jsmFn(...args);
const suite = jsmFn(...args);
runnerStack.pop();
return suite;
}
@ -106,7 +106,7 @@ export function beforeEach(fn: Function): void {
*/
export function beforeEachProviders(fn: Function): void {
jsmBeforeEach(() => {
var providers = fn();
const providers = fn();
if (!providers) return;
testBed.configureTestingModule({providers: providers});
});
@ -119,11 +119,11 @@ function _it(jsmFn: Function, name: string, testFn: Function, testTimeOut: numbe
debugger;
throw new Error('Empty Stack!');
}
var runner = runnerStack[runnerStack.length - 1];
var timeOut = Math.max(globalTimeOut, testTimeOut);
const runner = runnerStack[runnerStack.length - 1];
const timeOut = Math.max(globalTimeOut, testTimeOut);
jsmFn(name, (done: any) => {
var completerProvider = {
const completerProvider = {
provide: AsyncTestCompleter,
useFactory: () => {
// Mark the test as async when an AsyncTestCompleter is injected in an it()
@ -134,7 +134,7 @@ function _it(jsmFn: Function, name: string, testFn: Function, testTimeOut: numbe
runner.run();
if (testFn.length == 0) {
let retVal = testFn();
const retVal = testFn();
if (isPromise(retVal)) {
// Asynchronous test function that returns a Promise - wait for completion.
(<Promise<any>>retVal).then(done, done.fail);
@ -164,7 +164,7 @@ export function iit(name: any, fn: any, timeOut: any = null): void {
export class SpyObject {
constructor(type?: any) {
if (type) {
for (let prop in type.prototype) {
for (const prop in type.prototype) {
let m: any = null;
try {
m = type.prototype[prop];
@ -197,7 +197,7 @@ export class SpyObject {
object = new SpyObject();
}
var m = StringMapWrapper.merge(config, overrides);
const m = StringMapWrapper.merge(config, overrides);
Object.keys(m).forEach(key => { object.spy(key).and.returnValue(m[key]); });
return object;
}