style(lint): re-format modules/@angular
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import {BrowserDomAdapter} from '../src/browser/browser_adapter';
|
||||
import {document, window} from '../src/facade/browser';
|
||||
import {NumberWrapper, isBlank} from '../src/facade/lang';
|
||||
import {BaseException} from '../src/facade/exceptions';
|
||||
import {NumberWrapper, isBlank} from '../src/facade/lang';
|
||||
|
||||
var DOM = new BrowserDomAdapter();
|
||||
|
||||
@ -35,7 +35,9 @@ export function bindAction(selector: string, callback: Function) {
|
||||
DOM.on(el, 'click', function(_: any /** TODO #9100 */) { callback(); });
|
||||
}
|
||||
|
||||
export function microBenchmark(name: any /** TODO #9100 */, iterationCount: any /** TODO #9100 */, callback: any /** TODO #9100 */) {
|
||||
export function microBenchmark(
|
||||
name: any /** TODO #9100 */, iterationCount: any /** TODO #9100 */,
|
||||
callback: any /** TODO #9100 */) {
|
||||
var durationName = `${name}/${iterationCount}`;
|
||||
window.console.time(durationName);
|
||||
callback();
|
||||
|
@ -1,13 +1,11 @@
|
||||
import {TEST_BROWSER_STATIC_PLATFORM_PROVIDERS, ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS} from "./browser_static";
|
||||
import {BROWSER_APP_PROVIDERS, BROWSER_APP_COMPILER_PROVIDERS} from "../index";
|
||||
import {DirectiveResolver, ViewResolver} from "@angular/compiler";
|
||||
import {
|
||||
MockDirectiveResolver,
|
||||
MockViewResolver,
|
||||
TestComponentRenderer,
|
||||
TestComponentBuilder
|
||||
} from "@angular/compiler/testing";
|
||||
import {DOMTestComponentRenderer} from "./dom_test_component_renderer";
|
||||
import {DirectiveResolver, ViewResolver} from '@angular/compiler';
|
||||
import {MockDirectiveResolver, MockViewResolver, TestComponentBuilder, TestComponentRenderer} from '@angular/compiler/testing';
|
||||
|
||||
import {BROWSER_APP_COMPILER_PROVIDERS, BROWSER_APP_PROVIDERS} from '../index';
|
||||
|
||||
import {ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS, TEST_BROWSER_STATIC_PLATFORM_PROVIDERS} from './browser_static';
|
||||
import {DOMTestComponentRenderer} from './dom_test_component_renderer';
|
||||
|
||||
|
||||
/**
|
||||
* Default platform providers for testing.
|
||||
@ -26,10 +24,7 @@ export const ADDITIONAL_TEST_BROWSER_PROVIDERS = [
|
||||
/**
|
||||
* Default application providers for testing.
|
||||
*/
|
||||
export const TEST_BROWSER_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
[
|
||||
BROWSER_APP_PROVIDERS,
|
||||
BROWSER_APP_COMPILER_PROVIDERS,
|
||||
ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS,
|
||||
ADDITIONAL_TEST_BROWSER_PROVIDERS
|
||||
];
|
||||
export const TEST_BROWSER_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||
BROWSER_APP_PROVIDERS, BROWSER_APP_COMPILER_PROVIDERS, ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS,
|
||||
ADDITIONAL_TEST_BROWSER_PROVIDERS
|
||||
];
|
||||
|
@ -1,31 +1,30 @@
|
||||
import {LocationStrategy} from '@angular/common';
|
||||
import {MockLocationStrategy} from '@angular/common/testing';
|
||||
import {APP_ID, NgZone, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER} from '@angular/core';
|
||||
import {Log} from '@angular/core/testing';
|
||||
|
||||
import {AnimationDriver, NoOpAnimationDriver} from '../core_private';
|
||||
import {BROWSER_APP_PROVIDERS} from '../src/browser';
|
||||
import {BrowserDomAdapter} from '../src/browser/browser_adapter';
|
||||
import {MockLocationStrategy} from '@angular/common/testing';
|
||||
import {LocationStrategy} from '@angular/common';
|
||||
import {BrowserDetection} from './browser_util';
|
||||
import {Log} from '@angular/core/testing';
|
||||
import {ELEMENT_PROBE_PROVIDERS} from '../src/dom/debug/ng_probe';
|
||||
import {AnimationDriver, NoOpAnimationDriver} from '../core_private';
|
||||
|
||||
import {BrowserDetection} from './browser_util';
|
||||
|
||||
|
||||
/**
|
||||
* Default platform providers for testing without a compiler.
|
||||
*/
|
||||
export const TEST_BROWSER_STATIC_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
[
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}
|
||||
];
|
||||
export const TEST_BROWSER_STATIC_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}
|
||||
];
|
||||
|
||||
export const ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
[
|
||||
{provide: APP_ID, useValue: 'a'},
|
||||
ELEMENT_PROBE_PROVIDERS,
|
||||
Log,
|
||||
{provide: NgZone, useFactory: createNgZone},
|
||||
{provide: LocationStrategy, useClass: MockLocationStrategy},
|
||||
{provide: AnimationDriver, useClass: NoOpAnimationDriver}
|
||||
];
|
||||
export const ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||
{provide: APP_ID, useValue: 'a'}, ELEMENT_PROBE_PROVIDERS, Log,
|
||||
{provide: NgZone, useFactory: createNgZone},
|
||||
{provide: LocationStrategy, useClass: MockLocationStrategy},
|
||||
{provide: AnimationDriver, useClass: NoOpAnimationDriver}
|
||||
];
|
||||
|
||||
/**
|
||||
* Default application providers for testing without a compiler.
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {ListWrapper} from '../src/facade/collection';
|
||||
import {getDOM} from '../src/dom/dom_adapter';
|
||||
import {isPresent, isString, RegExpWrapper, StringWrapper, RegExp} from '../src/facade/lang';
|
||||
import {ListWrapper} from '../src/facade/collection';
|
||||
import {RegExp, RegExpWrapper, StringWrapper, isPresent, isString} from '../src/facade/lang';
|
||||
|
||||
export class BrowserDetection {
|
||||
private _overrideUa: string;
|
||||
@ -20,7 +20,7 @@ export class BrowserDetection {
|
||||
|
||||
get isAndroid(): boolean {
|
||||
return this._ua.indexOf('Mozilla/5.0') > -1 && this._ua.indexOf('Android') > -1 &&
|
||||
this._ua.indexOf('AppleWebKit') > -1 && this._ua.indexOf('Chrome') == -1;
|
||||
this._ua.indexOf('AppleWebKit') > -1 && this._ua.indexOf('Chrome') == -1;
|
||||
}
|
||||
|
||||
get isEdge(): boolean { return this._ua.indexOf('Edge') > -1; }
|
||||
@ -46,13 +46,14 @@ export class BrowserDetection {
|
||||
|
||||
get isChromeDesktop(): boolean {
|
||||
return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Mobile Safari') == -1 &&
|
||||
this._ua.indexOf('Edge') == -1;
|
||||
this._ua.indexOf('Edge') == -1;
|
||||
}
|
||||
}
|
||||
|
||||
BrowserDetection.setup();
|
||||
|
||||
export function dispatchEvent(element: any /** TODO #9100 */, eventType: any /** TODO #9100 */): void {
|
||||
export function dispatchEvent(
|
||||
element: any /** TODO #9100 */, eventType: any /** TODO #9100 */): void {
|
||||
getDOM().dispatchEvent(element, getDOM().createEvent(eventType));
|
||||
}
|
||||
|
||||
@ -65,10 +66,11 @@ export function normalizeCSS(css: string): string {
|
||||
css = StringWrapper.replaceAll(css, /:\s/g, ':');
|
||||
css = StringWrapper.replaceAll(css, /'/g, '"');
|
||||
css = StringWrapper.replaceAll(css, / }/g, '}');
|
||||
css = StringWrapper.replaceAllMapped(css, /url\((\"|\s)(.+)(\"|\s)\)(\s*)/g,
|
||||
(match: any /** TODO #9100 */) => `url("${match[2]}")`);
|
||||
css = StringWrapper.replaceAllMapped(css, /\[(.+)=([^"\]]+)\]/g,
|
||||
(match: any /** TODO #9100 */) => `[${match[1]}="${match[2]}"]`);
|
||||
css = StringWrapper.replaceAllMapped(
|
||||
css, /url\((\"|\s)(.+)(\"|\s)\)(\s*)/g,
|
||||
(match: any /** TODO #9100 */) => `url("${match[2]}")`);
|
||||
css = StringWrapper.replaceAllMapped(
|
||||
css, /\[(.+)=([^"\]]+)\]/g, (match: any /** TODO #9100 */) => `[${match[1]}="${match[2]}"]`);
|
||||
return css;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,12 @@
|
||||
import {Inject, Injectable} from '@angular/core';
|
||||
import {DOCUMENT} from '../src/dom/dom_tokens';
|
||||
import {getDOM} from '../src/dom/dom_adapter';
|
||||
import {TestComponentRenderer} from '@angular/compiler/testing';
|
||||
import {Inject, Injectable} from '@angular/core';
|
||||
|
||||
import {getDOM} from '../src/dom/dom_adapter';
|
||||
import {DOCUMENT} from '../src/dom/dom_tokens';
|
||||
|
||||
import {el} from './browser_util';
|
||||
|
||||
|
||||
/**
|
||||
* A DOM based implementation of the TestComponentRenderer.
|
||||
*/
|
||||
|
@ -1,6 +1,7 @@
|
||||
import {getDOM} from '../src/dom/dom_adapter';
|
||||
import {global, isString} from '../src/facade/lang';
|
||||
import {StringMapWrapper} from '../src/facade/collection';
|
||||
import {global, isString} from '../src/facade/lang';
|
||||
|
||||
|
||||
/**
|
||||
* Jasmine matchers that check Angular specific conditions.
|
||||
@ -133,7 +134,9 @@ _global.beforeEach(function() {
|
||||
if (actual instanceof Map) {
|
||||
var pass = actual.size === expected.size;
|
||||
if (pass) {
|
||||
actual.forEach((v: any /** TODO #???? */, k: any /** TODO #???? */) => { pass = pass && util.equals(v, expected.get(k)); });
|
||||
actual.forEach((v: any /** TODO #???? */, k: any /** TODO #???? */) => {
|
||||
pass = pass && util.equals(v, expected.get(k));
|
||||
});
|
||||
}
|
||||
return pass;
|
||||
} else {
|
||||
@ -200,9 +203,10 @@ _global.beforeEach(function() {
|
||||
allPassed = getDOM().hasStyle(actual, styles);
|
||||
} else {
|
||||
allPassed = !StringMapWrapper.isEmpty(styles);
|
||||
StringMapWrapper.forEach(styles, (style: any /** TODO #???? */, prop: any /** TODO #???? */) => {
|
||||
allPassed = allPassed && getDOM().hasStyle(actual, prop, style);
|
||||
});
|
||||
StringMapWrapper.forEach(
|
||||
styles, (style: any /** TODO #???? */, prop: any /** TODO #???? */) => {
|
||||
allPassed = allPassed && getDOM().hasStyle(actual, prop, style);
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
@ -236,7 +240,7 @@ _global.beforeEach(function() {
|
||||
actual();
|
||||
return {
|
||||
pass: false,
|
||||
get message() { return "Was expected to throw, but did not throw"; }
|
||||
get message() { return 'Was expected to throw, but did not throw'; }
|
||||
};
|
||||
} catch (e) {
|
||||
var errorMessage = e.toString();
|
||||
@ -266,7 +270,8 @@ _global.beforeEach(function() {
|
||||
|
||||
toImplement: function() {
|
||||
return {
|
||||
compare: function(actualObject: any /** TODO #???? */, expectedInterface: any /** TODO #???? */) {
|
||||
compare: function(
|
||||
actualObject: any /** TODO #???? */, expectedInterface: any /** TODO #???? */) {
|
||||
var objProps = Object.keys(actualObject.constructor.prototype);
|
||||
var intProps = Object.keys(expectedInterface.prototype);
|
||||
|
||||
@ -279,7 +284,7 @@ _global.beforeEach(function() {
|
||||
pass: missedMethods.length == 0,
|
||||
get message() {
|
||||
return 'Expected ' + actualObject + ' to have the following methods: ' +
|
||||
missedMethods.join(", ");
|
||||
missedMethods.join(', ');
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -295,7 +300,7 @@ function elementText(n: any /** TODO #???? */): any /** TODO #???? */ {
|
||||
};
|
||||
|
||||
if (n instanceof Array) {
|
||||
return n.map(elementText).join("");
|
||||
return n.map(elementText).join('');
|
||||
}
|
||||
|
||||
if (getDOM().isCommentNode(n)) {
|
||||
|
@ -6,51 +6,54 @@ var Options = benchpress.Options;
|
||||
|
||||
export function runClickBenchmark(config: any /** TODO #9100 */) {
|
||||
browser.ignoreSynchronization = !config.waitForAngular2;
|
||||
var buttons = config.buttons.map(function(selector: any /** TODO #9100 */) { return $(selector); });
|
||||
config.work = function() { buttons.forEach(function(button: any /** TODO #9100 */) { button.click(); }); };
|
||||
var buttons =
|
||||
config.buttons.map(function(selector: any /** TODO #9100 */) { return $(selector); });
|
||||
config.work = function() {
|
||||
buttons.forEach(function(button: any /** TODO #9100 */) { button.click(); });
|
||||
};
|
||||
return runBenchmark(config);
|
||||
}
|
||||
|
||||
export function runBenchmark(config: any /** TODO #9100 */) {
|
||||
return getScaleFactor(browser.params.benchmark.scaling)
|
||||
.then(function(scaleFactor) {
|
||||
var description = {};
|
||||
var urlParams: any[] /** TODO #9100 */ = [];
|
||||
if (config.params) {
|
||||
config.params.forEach(function(param: any /** TODO #9100 */) {
|
||||
var name = param.name;
|
||||
var value = applyScaleFactor(param.value, scaleFactor, param.scale);
|
||||
urlParams.push(name + '=' + value);
|
||||
(description as any /** TODO #9100 */)[name] = value;
|
||||
});
|
||||
}
|
||||
var url = encodeURI(config.url + '?' + urlParams.join('&'));
|
||||
return browser.get(url).then(function() {
|
||||
return (global as any /** TODO #9100 */)['benchpressRunner'].sample({
|
||||
id: config.id,
|
||||
execute: config.work,
|
||||
prepare: config.prepare,
|
||||
microMetrics: config.microMetrics,
|
||||
providers: [{provide: Options.SAMPLE_DESCRIPTION, useValue: description }]
|
||||
});
|
||||
});
|
||||
return getScaleFactor(browser.params.benchmark.scaling).then(function(scaleFactor) {
|
||||
var description = {};
|
||||
var urlParams: any[] /** TODO #9100 */ = [];
|
||||
if (config.params) {
|
||||
config.params.forEach(function(param: any /** TODO #9100 */) {
|
||||
var name = param.name;
|
||||
var value = applyScaleFactor(param.value, scaleFactor, param.scale);
|
||||
urlParams.push(name + '=' + value);
|
||||
(description as any /** TODO #9100 */)[name] = value;
|
||||
});
|
||||
}
|
||||
var url = encodeURI(config.url + '?' + urlParams.join('&'));
|
||||
return browser.get(url).then(function() {
|
||||
return (global as any /** TODO #9100 */)['benchpressRunner'].sample({
|
||||
id: config.id,
|
||||
execute: config.work,
|
||||
prepare: config.prepare,
|
||||
microMetrics: config.microMetrics,
|
||||
providers: [{provide: Options.SAMPLE_DESCRIPTION, useValue: description}]
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getScaleFactor(possibleScalings: any /** TODO #9100 */) {
|
||||
return browser.executeScript('return navigator.userAgent')
|
||||
.then(function(userAgent: string) {
|
||||
var scaleFactor = 1;
|
||||
possibleScalings.forEach(function(entry: any /** TODO #9100 */) {
|
||||
if (userAgent.match(entry.userAgent)) {
|
||||
scaleFactor = entry.value;
|
||||
}
|
||||
});
|
||||
return scaleFactor;
|
||||
});
|
||||
return browser.executeScript('return navigator.userAgent').then(function(userAgent: string) {
|
||||
var scaleFactor = 1;
|
||||
possibleScalings.forEach(function(entry: any /** TODO #9100 */) {
|
||||
if (userAgent.match(entry.userAgent)) {
|
||||
scaleFactor = entry.value;
|
||||
}
|
||||
});
|
||||
return scaleFactor;
|
||||
});
|
||||
}
|
||||
|
||||
function applyScaleFactor(value: any /** TODO #9100 */, scaleFactor: any /** TODO #9100 */, method: any /** TODO #9100 */) {
|
||||
function applyScaleFactor(
|
||||
value: any /** TODO #9100 */, scaleFactor: any /** TODO #9100 */,
|
||||
method: any /** TODO #9100 */) {
|
||||
if (method === 'log2') {
|
||||
return value + Math.log(scaleFactor) / Math.LN2;
|
||||
} else if (method === 'sqrt') {
|
||||
|
Reference in New Issue
Block a user