refactor(): use const and let instead of var
This commit is contained in:

committed by
Victor Berchet

parent
73593d4bf3
commit
77ee27c59e
@ -123,7 +123,7 @@ function bootstrap(cmpType: any, providers: Provider[] = []): Promise<any> {
|
||||
}
|
||||
|
||||
export function main() {
|
||||
var fakeDoc: any /** TODO #9100 */, el: any /** TODO #9100 */, el2: any /** TODO #9100 */,
|
||||
let fakeDoc: any /** TODO #9100 */, el: any /** TODO #9100 */, el2: any /** TODO #9100 */,
|
||||
testProviders: Provider[], lightDom: any /** TODO #9100 */;
|
||||
|
||||
describe('bootstrap factory method', () => {
|
||||
@ -151,8 +151,8 @@ export function main() {
|
||||
|
||||
it('should throw if bootstrapped Directive is not a Component',
|
||||
inject([AsyncTestCompleter], (done: AsyncTestCompleter) => {
|
||||
var logger = new MockConsole();
|
||||
var errorHandler = new ErrorHandler(false);
|
||||
const logger = new MockConsole();
|
||||
const errorHandler = new ErrorHandler(false);
|
||||
errorHandler._console = logger as any;
|
||||
bootstrap(HelloRootDirectiveIsNotCmp, [
|
||||
{provide: ErrorHandler, useValue: errorHandler}
|
||||
@ -165,8 +165,8 @@ export function main() {
|
||||
|
||||
it('should throw if no element is found',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var logger = new MockConsole();
|
||||
var errorHandler = new ErrorHandler(false);
|
||||
const logger = new MockConsole();
|
||||
const errorHandler = new ErrorHandler(false);
|
||||
errorHandler._console = logger as any;
|
||||
bootstrap(HelloRootCmp, [
|
||||
{provide: ErrorHandler, useValue: errorHandler}
|
||||
@ -180,11 +180,11 @@ export function main() {
|
||||
if (getDOM().supportsDOMEvents()) {
|
||||
it('should forward the error to promise when bootstrap fails',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var logger = new MockConsole();
|
||||
var errorHandler = new ErrorHandler(false);
|
||||
const logger = new MockConsole();
|
||||
const errorHandler = new ErrorHandler(false);
|
||||
errorHandler._console = logger as any;
|
||||
|
||||
var refPromise =
|
||||
const refPromise =
|
||||
bootstrap(HelloRootCmp, [{provide: ErrorHandler, useValue: errorHandler}]);
|
||||
refPromise.then(null, (reason: any) => {
|
||||
expect(reason.message)
|
||||
@ -195,11 +195,11 @@ export function main() {
|
||||
|
||||
it('should invoke the default exception handler when bootstrap fails',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var logger = new MockConsole();
|
||||
var errorHandler = new ErrorHandler(false);
|
||||
const logger = new MockConsole();
|
||||
const errorHandler = new ErrorHandler(false);
|
||||
errorHandler._console = logger as any;
|
||||
|
||||
var refPromise =
|
||||
const refPromise =
|
||||
bootstrap(HelloRootCmp, [{provide: ErrorHandler, useValue: errorHandler}]);
|
||||
refPromise.then(null, (reason) => {
|
||||
expect(logger.res.join(''))
|
||||
@ -211,12 +211,12 @@ export function main() {
|
||||
}
|
||||
|
||||
it('should create an injector promise', () => {
|
||||
var refPromise = bootstrap(HelloRootCmp, testProviders);
|
||||
const refPromise = bootstrap(HelloRootCmp, testProviders);
|
||||
expect(refPromise).not.toBe(null);
|
||||
});
|
||||
|
||||
it('should display hello world', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var refPromise = bootstrap(HelloRootCmp, testProviders);
|
||||
const refPromise = bootstrap(HelloRootCmp, testProviders);
|
||||
refPromise.then((ref) => {
|
||||
expect(el).toHaveText('hello world!');
|
||||
async.done();
|
||||
@ -230,7 +230,7 @@ export function main() {
|
||||
}
|
||||
bootstrap(HelloRootCmp, testProviders)
|
||||
.then((ref: ComponentRef<HelloRootCmp>) => {
|
||||
let compiler: Compiler = ref.injector.get(Compiler);
|
||||
const compiler: Compiler = ref.injector.get(Compiler);
|
||||
return compiler.compileModuleAsync(AsyncModule).then(factory => {
|
||||
expect(() => factory.create(ref.injector))
|
||||
.toThrowError(
|
||||
@ -242,8 +242,8 @@ export function main() {
|
||||
|
||||
it('should support multiple calls to bootstrap',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var refPromise1 = bootstrap(HelloRootCmp, testProviders);
|
||||
var refPromise2 = bootstrap(HelloRootCmp2, testProviders);
|
||||
const refPromise1 = bootstrap(HelloRootCmp, testProviders);
|
||||
const refPromise2 = bootstrap(HelloRootCmp2, testProviders);
|
||||
Promise.all([refPromise1, refPromise2]).then((refs) => {
|
||||
expect(el).toHaveText('hello world!');
|
||||
expect(el2).toHaveText('hello world, again!');
|
||||
@ -271,7 +271,7 @@ export function main() {
|
||||
|
||||
it('should make the provided bindings available to the application component',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var refPromise = bootstrap(
|
||||
const refPromise = bootstrap(
|
||||
HelloRootCmp3, [testProviders, {provide: 'appBinding', useValue: 'BoundValue'}]);
|
||||
|
||||
refPromise.then((ref) => {
|
||||
@ -282,7 +282,7 @@ export function main() {
|
||||
|
||||
it('should avoid cyclic dependencies when root component requires Lifecycle through DI',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var refPromise = bootstrap(HelloRootCmp4, testProviders);
|
||||
const refPromise = bootstrap(HelloRootCmp4, testProviders);
|
||||
|
||||
refPromise.then((ref) => {
|
||||
const appRef = ref.injector.get(ApplicationRef);
|
||||
@ -293,7 +293,7 @@ export function main() {
|
||||
|
||||
it('should run platform initializers',
|
||||
inject([Log, AsyncTestCompleter], (log: Log, async: AsyncTestCompleter) => {
|
||||
let p = createPlatformFactory(platformBrowserDynamic, 'someName', [
|
||||
const p = createPlatformFactory(platformBrowserDynamic, 'someName', [
|
||||
{provide: PLATFORM_INITIALIZER, useValue: log.fn('platform_init1'), multi: true},
|
||||
{provide: PLATFORM_INITIALIZER, useValue: log.fn('platform_init2'), multi: true}
|
||||
])();
|
||||
@ -319,12 +319,12 @@ export function main() {
|
||||
|
||||
it('should register each application with the testability registry',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var refPromise1: Promise<ComponentRef<any>> = bootstrap(HelloRootCmp, testProviders);
|
||||
var refPromise2: Promise<ComponentRef<any>> = bootstrap(HelloRootCmp2, testProviders);
|
||||
const refPromise1: Promise<ComponentRef<any>> = bootstrap(HelloRootCmp, testProviders);
|
||||
const refPromise2: Promise<ComponentRef<any>> = bootstrap(HelloRootCmp2, testProviders);
|
||||
|
||||
Promise.all([refPromise1, refPromise2]).then((refs: ComponentRef<any>[]) => {
|
||||
var registry = refs[0].injector.get(TestabilityRegistry);
|
||||
var testabilities =
|
||||
const registry = refs[0].injector.get(TestabilityRegistry);
|
||||
const testabilities =
|
||||
[refs[0].injector.get(Testability), refs[1].injector.get(Testability)];
|
||||
Promise.all(testabilities).then((testabilities: Testability[]) => {
|
||||
expect(registry.findTestabilityInTree(el)).toEqual(testabilities[0]);
|
||||
|
@ -14,7 +14,7 @@ import {parseCookieValue} from '../../src/browser/browser_adapter';
|
||||
export function main() {
|
||||
describe('cookies', () => {
|
||||
it('parses cookies', () => {
|
||||
let cookie = 'other-cookie=false; xsrf-token=token-value; is_awesome=true; ffo=true;';
|
||||
const cookie = 'other-cookie=false; xsrf-token=token-value; is_awesome=true; ffo=true;';
|
||||
expect(parseCookieValue(cookie, 'xsrf-token')).toBe('token-value');
|
||||
});
|
||||
it('handles encoded keys', () => {
|
||||
|
@ -14,8 +14,8 @@ import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
|
||||
export function main() {
|
||||
describe('title service', () => {
|
||||
var initialTitle = getDOM().getTitle();
|
||||
var titleService = new Title();
|
||||
const initialTitle = getDOM().getTitle();
|
||||
const titleService = new Title();
|
||||
|
||||
afterEach(() => { getDOM().setTitle(initialTitle); });
|
||||
|
||||
|
@ -12,7 +12,7 @@ import {BrowserDetection} from '../testing/browser_util';
|
||||
export function main() {
|
||||
describe('BrowserDetection', () => {
|
||||
|
||||
var browsers = [
|
||||
const browsers = [
|
||||
{
|
||||
name: 'Chrome',
|
||||
ua: 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36',
|
||||
@ -225,7 +225,7 @@ export function main() {
|
||||
|
||||
browsers.forEach((browser: {[key: string]: any}) => {
|
||||
it(`should detect ${browser[ 'name']}`, () => {
|
||||
var bd = new BrowserDetection(<string>browser['ua']);
|
||||
const bd = new BrowserDetection(<string>browser['ua']);
|
||||
expect(bd.isFirefox).toBe(browser['isFirefox']);
|
||||
expect(bd.isAndroid).toBe(browser['isAndroid']);
|
||||
expect(bd.isEdge).toBe(browser['isEdge']);
|
||||
|
@ -14,7 +14,7 @@ import {EventManager, EventManagerPlugin} from '@angular/platform-browser/src/do
|
||||
import {el} from '../../../testing/browser_util';
|
||||
|
||||
export function main() {
|
||||
var domEventPlugin: DomEventsPlugin;
|
||||
let domEventPlugin: DomEventsPlugin;
|
||||
|
||||
describe('EventManager', () => {
|
||||
|
||||
@ -22,21 +22,21 @@ export function main() {
|
||||
|
||||
it('should delegate event bindings to plugins that are passed in from the most generic one to the most specific one',
|
||||
() => {
|
||||
var element = el('<div></div>');
|
||||
var handler = (e: any /** TODO #9100 */) => e;
|
||||
var plugin = new FakeEventManagerPlugin(['click']);
|
||||
var manager = new EventManager([domEventPlugin, plugin], new FakeNgZone());
|
||||
const element = el('<div></div>');
|
||||
const handler = (e: any /** TODO #9100 */) => e;
|
||||
const plugin = new FakeEventManagerPlugin(['click']);
|
||||
const manager = new EventManager([domEventPlugin, plugin], new FakeNgZone());
|
||||
manager.addEventListener(element, 'click', handler);
|
||||
expect(plugin.eventHandler['click']).toBe(handler);
|
||||
});
|
||||
|
||||
it('should delegate event bindings to the first plugin supporting the event', () => {
|
||||
var element = el('<div></div>');
|
||||
var clickHandler = (e: any /** TODO #9100 */) => e;
|
||||
var dblClickHandler = (e: any /** TODO #9100 */) => e;
|
||||
var plugin1 = new FakeEventManagerPlugin(['dblclick']);
|
||||
var plugin2 = new FakeEventManagerPlugin(['click', 'dblclick']);
|
||||
var manager = new EventManager([plugin2, plugin1], new FakeNgZone());
|
||||
const element = el('<div></div>');
|
||||
const clickHandler = (e: any /** TODO #9100 */) => e;
|
||||
const dblClickHandler = (e: any /** TODO #9100 */) => e;
|
||||
const plugin1 = new FakeEventManagerPlugin(['dblclick']);
|
||||
const plugin2 = new FakeEventManagerPlugin(['click', 'dblclick']);
|
||||
const manager = new EventManager([plugin2, plugin1], new FakeNgZone());
|
||||
manager.addEventListener(element, 'click', clickHandler);
|
||||
manager.addEventListener(element, 'dblclick', dblClickHandler);
|
||||
expect(plugin2.eventHandler['click']).toBe(clickHandler);
|
||||
@ -44,23 +44,23 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should throw when no plugin can handle the event', () => {
|
||||
var element = el('<div></div>');
|
||||
var plugin = new FakeEventManagerPlugin(['dblclick']);
|
||||
var manager = new EventManager([plugin], new FakeNgZone());
|
||||
const element = el('<div></div>');
|
||||
const plugin = new FakeEventManagerPlugin(['dblclick']);
|
||||
const manager = new EventManager([plugin], new FakeNgZone());
|
||||
expect(() => manager.addEventListener(element, 'click', null))
|
||||
.toThrowError('No event manager plugin found for event click');
|
||||
});
|
||||
|
||||
it('events are caught when fired from a child', () => {
|
||||
var element = el('<div><div></div></div>');
|
||||
const element = el('<div><div></div></div>');
|
||||
// Workaround for https://bugs.webkit.org/show_bug.cgi?id=122755
|
||||
getDOM().appendChild(getDOM().defaultDoc().body, element);
|
||||
|
||||
var child = getDOM().firstChild(element);
|
||||
var dispatchedEvent = getDOM().createMouseEvent('click');
|
||||
var receivedEvent: any /** TODO #9100 */ = null;
|
||||
var handler = (e: any /** TODO #9100 */) => { receivedEvent = e; };
|
||||
var manager = new EventManager([domEventPlugin], new FakeNgZone());
|
||||
const child = getDOM().firstChild(element);
|
||||
const dispatchedEvent = getDOM().createMouseEvent('click');
|
||||
let receivedEvent: any /** TODO #9100 */ = null;
|
||||
const handler = (e: any /** TODO #9100 */) => { receivedEvent = e; };
|
||||
const manager = new EventManager([domEventPlugin], new FakeNgZone());
|
||||
manager.addEventListener(element, 'click', handler);
|
||||
getDOM().dispatchEvent(child, dispatchedEvent);
|
||||
|
||||
@ -68,14 +68,14 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should add and remove global event listeners', () => {
|
||||
var element = el('<div><div></div></div>');
|
||||
const element = el('<div><div></div></div>');
|
||||
getDOM().appendChild(getDOM().defaultDoc().body, element);
|
||||
var dispatchedEvent = getDOM().createMouseEvent('click');
|
||||
var receivedEvent: any /** TODO #9100 */ = null;
|
||||
var handler = (e: any /** TODO #9100 */) => { receivedEvent = e; };
|
||||
var manager = new EventManager([domEventPlugin], new FakeNgZone());
|
||||
const dispatchedEvent = getDOM().createMouseEvent('click');
|
||||
let receivedEvent: any /** TODO #9100 */ = null;
|
||||
const handler = (e: any /** TODO #9100 */) => { receivedEvent = e; };
|
||||
const manager = new EventManager([domEventPlugin], new FakeNgZone());
|
||||
|
||||
var remover = manager.addGlobalEventListener('document', 'click', handler);
|
||||
const remover = manager.addGlobalEventListener('document', 'click', handler);
|
||||
getDOM().dispatchEvent(element, dispatchedEvent);
|
||||
expect(receivedEvent).toBe(dispatchedEvent);
|
||||
|
||||
|
@ -13,9 +13,9 @@ import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
|
||||
export function main() {
|
||||
describe('DomSharedStylesHost', () => {
|
||||
var doc: any /** TODO #9100 */;
|
||||
var ssh: DomSharedStylesHost;
|
||||
var someHost: Element;
|
||||
let doc: any /** TODO #9100 */;
|
||||
let ssh: DomSharedStylesHost;
|
||||
let someHost: Element;
|
||||
beforeEach(() => {
|
||||
doc = getDOM().createHtmlDocument();
|
||||
doc.title = '';
|
||||
|
@ -38,41 +38,41 @@ function _makeKeyframe(
|
||||
|
||||
export function main() {
|
||||
describe('WebAnimationsDriver', () => {
|
||||
var driver: ExtendedWebAnimationsDriver;
|
||||
var elm: HTMLElement;
|
||||
let driver: ExtendedWebAnimationsDriver;
|
||||
let elm: HTMLElement;
|
||||
beforeEach(() => {
|
||||
driver = new ExtendedWebAnimationsDriver();
|
||||
elm = el('<div></div>');
|
||||
});
|
||||
|
||||
it('should use a fill mode of `both`', () => {
|
||||
var startingStyles = _makeStyles({});
|
||||
var styles = [_makeKeyframe(0, {'color': 'green'}), _makeKeyframe(1, {'color': 'red'})];
|
||||
const startingStyles = _makeStyles({});
|
||||
const styles = [_makeKeyframe(0, {'color': 'green'}), _makeKeyframe(1, {'color': 'red'})];
|
||||
|
||||
var player = driver.animate(elm, startingStyles, styles, 1000, 1000, 'linear');
|
||||
var details = _formatOptions(player);
|
||||
var options = details['options'];
|
||||
const player = driver.animate(elm, startingStyles, styles, 1000, 1000, 'linear');
|
||||
const details = _formatOptions(player);
|
||||
const options = details['options'];
|
||||
expect(options['fill']).toEqual('both');
|
||||
});
|
||||
|
||||
it('should apply the provided easing', () => {
|
||||
var startingStyles = _makeStyles({});
|
||||
var styles = [_makeKeyframe(0, {'color': 'green'}), _makeKeyframe(1, {'color': 'red'})];
|
||||
const startingStyles = _makeStyles({});
|
||||
const styles = [_makeKeyframe(0, {'color': 'green'}), _makeKeyframe(1, {'color': 'red'})];
|
||||
|
||||
var player = driver.animate(elm, startingStyles, styles, 1000, 1000, 'ease-out');
|
||||
var details = _formatOptions(player);
|
||||
var options = details['options'];
|
||||
const player = driver.animate(elm, startingStyles, styles, 1000, 1000, 'ease-out');
|
||||
const details = _formatOptions(player);
|
||||
const options = details['options'];
|
||||
expect(options['easing']).toEqual('ease-out');
|
||||
});
|
||||
|
||||
it('should only apply the provided easing if present', () => {
|
||||
var startingStyles = _makeStyles({});
|
||||
var styles = [_makeKeyframe(0, {'color': 'green'}), _makeKeyframe(1, {'color': 'red'})];
|
||||
const startingStyles = _makeStyles({});
|
||||
const styles = [_makeKeyframe(0, {'color': 'green'}), _makeKeyframe(1, {'color': 'red'})];
|
||||
|
||||
var player = driver.animate(elm, startingStyles, styles, 1000, 1000, null);
|
||||
var details = _formatOptions(player);
|
||||
var options = details['options'];
|
||||
var keys = Object.keys(options);
|
||||
const player = driver.animate(elm, startingStyles, styles, 1000, 1000, null);
|
||||
const details = _formatOptions(player);
|
||||
const options = details['options'];
|
||||
const keys = Object.keys(options);
|
||||
expect(keys.indexOf('easing')).toEqual(-1);
|
||||
});
|
||||
});
|
||||
|
@ -32,16 +32,16 @@ class ExtendedWebAnimationsPlayer extends WebAnimationsPlayer {
|
||||
|
||||
export function main() {
|
||||
function makePlayer(): {[key: string]: any} {
|
||||
var someElm = el('<div></div>');
|
||||
var player = new ExtendedWebAnimationsPlayer(someElm, [], {});
|
||||
const someElm = el('<div></div>');
|
||||
const player = new ExtendedWebAnimationsPlayer(someElm, [], {});
|
||||
player.init();
|
||||
return {'captures': player.domPlayer.captures, 'player': player};
|
||||
}
|
||||
|
||||
describe('WebAnimationsPlayer', () => {
|
||||
var player: any /** TODO #9100 */, captures: any /** TODO #9100 */;
|
||||
let player: any /** TODO #9100 */, captures: any /** TODO #9100 */;
|
||||
beforeEach(() => {
|
||||
var newPlayer = makePlayer();
|
||||
const newPlayer = makePlayer();
|
||||
captures = <{[key: string]: any}>newPlayer['captures'];
|
||||
player = <WebAnimationsPlayer>newPlayer['player'];
|
||||
});
|
||||
@ -68,8 +68,8 @@ export function main() {
|
||||
() => { expect(captures['onfinish'].length).toEqual(1); });
|
||||
|
||||
it('should trigger the subscribe functions when complete', () => {
|
||||
var count = 0;
|
||||
var method = () => { count++; };
|
||||
let count = 0;
|
||||
const method = () => { count++; };
|
||||
|
||||
player.onDone(method);
|
||||
player.onDone(method);
|
||||
@ -81,7 +81,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should finish right away when finish is called directly', () => {
|
||||
var completed = false;
|
||||
let completed = false;
|
||||
player.onDone(() => completed = true);
|
||||
expect(completed).toEqual(false);
|
||||
|
||||
@ -95,15 +95,15 @@ export function main() {
|
||||
|
||||
it('should trigger finish when destroy is called if the animation has not finished already',
|
||||
() => {
|
||||
var count = 0;
|
||||
var method = () => { count++; };
|
||||
let count = 0;
|
||||
const method = () => { count++; };
|
||||
|
||||
player.onDone(method);
|
||||
expect(count).toEqual(0);
|
||||
player.destroy();
|
||||
expect(count).toEqual(1);
|
||||
|
||||
var player2 = makePlayer()['player'];
|
||||
const player2 = makePlayer()['player'];
|
||||
player2.onDone(method);
|
||||
expect(count).toEqual(1);
|
||||
player2.finish();
|
||||
@ -119,11 +119,11 @@ export function main() {
|
||||
expect(captures['finish'].length).toEqual(1);
|
||||
expect(captures['cancel'].length).toEqual(0);
|
||||
|
||||
var next = makePlayer();
|
||||
var player2 = next['player'];
|
||||
const next = makePlayer();
|
||||
const player2 = next['player'];
|
||||
player2.parentPlayer = new MockAnimationPlayer();
|
||||
|
||||
var captures2 = next['captures'];
|
||||
const captures2 = next['captures'];
|
||||
captures2['cancel'] = [];
|
||||
|
||||
player2.finish();
|
||||
@ -132,7 +132,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should run the onStart method when started but only once', () => {
|
||||
var calls = 0;
|
||||
let calls = 0;
|
||||
player.onStart(() => calls++);
|
||||
expect(calls).toEqual(0);
|
||||
player.play();
|
||||
|
@ -74,12 +74,12 @@ export function main() {
|
||||
.toEqual('<p alt="% & " !">Hello</p>'); // NB: quote encoded as ASCII ".
|
||||
});
|
||||
t.describe('should strip dangerous elements', () => {
|
||||
let dangerousTags = [
|
||||
const dangerousTags = [
|
||||
'frameset', 'form', 'param', 'object', 'embed', 'textarea', 'input', 'button', 'option',
|
||||
'select', 'script', 'style', 'link', 'base', 'basefont'
|
||||
];
|
||||
|
||||
for (let tag of dangerousTags) {
|
||||
for (const tag of dangerousTags) {
|
||||
t.it(
|
||||
`${tag}`, () => { t.expect(sanitizeHtml(`<${tag}>evil!</${tag}>`)).toEqual('evil!'); });
|
||||
}
|
||||
@ -88,9 +88,9 @@ export function main() {
|
||||
});
|
||||
});
|
||||
t.describe('should strip dangerous attributes', () => {
|
||||
let dangerousAttrs = ['id', 'name', 'style'];
|
||||
const dangerousAttrs = ['id', 'name', 'style'];
|
||||
|
||||
for (let attr of dangerousAttrs) {
|
||||
for (const attr of dangerousAttrs) {
|
||||
t.it(`${attr}`, () => {
|
||||
t.expect(sanitizeHtml(`<a ${attr}="x">evil!</a>`)).toEqual('<a>evil!</a>');
|
||||
});
|
||||
|
@ -48,7 +48,7 @@ export function main() {
|
||||
'data:video/webm;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/',
|
||||
'data:audio/opus;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/',
|
||||
];
|
||||
for (let url of validUrls) {
|
||||
for (const url of validUrls) {
|
||||
t.it(`valid ${url}`, () => t.expect(sanitizeUrl(url)).toEqual(url));
|
||||
}
|
||||
});
|
||||
@ -72,7 +72,7 @@ export function main() {
|
||||
'data:text/javascript;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/',
|
||||
'data:application/x-msdownload;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/',
|
||||
];
|
||||
for (let url of invalidUrls) {
|
||||
for (const url of invalidUrls) {
|
||||
t.it(`valid ${url}`, () => t.expect(sanitizeUrl(url)).toMatch(/^unsafe:/));
|
||||
}
|
||||
});
|
||||
@ -99,7 +99,7 @@ export function main() {
|
||||
'http://angular.io/images/test.png?maxage, http://angular.io/images/test.png?maxage',
|
||||
'http://angular.io/images/test.png?maxage=234, http://angular.io/images/test.png?maxage=234',
|
||||
];
|
||||
for (let srcset of validSrcsets) {
|
||||
for (const srcset of validSrcsets) {
|
||||
t.it(`valid ${srcset}`, () => t.expect(sanitizeSrcset(srcset)).toEqual(srcset));
|
||||
}
|
||||
});
|
||||
@ -109,7 +109,7 @@ export function main() {
|
||||
'ht:tp://angular.io/images/test.png',
|
||||
'http://angular.io/images/test.png, ht:tp://angular.io/images/test.png',
|
||||
];
|
||||
for (let srcset of invalidSrcsets) {
|
||||
for (const srcset of invalidSrcsets) {
|
||||
t.it(`valid ${srcset}`, () => t.expect(sanitizeSrcset(srcset)).toMatch(/unsafe:/));
|
||||
}
|
||||
});
|
||||
|
@ -166,7 +166,7 @@ export function main() {
|
||||
it('should allow use of "done"', (done) => {
|
||||
inject([FancyService], (service: FancyService) => {
|
||||
let count = 0;
|
||||
let id = setInterval(() => {
|
||||
const id = setInterval(() => {
|
||||
count++;
|
||||
if (count > 2) {
|
||||
clearInterval(id);
|
||||
@ -201,7 +201,7 @@ export function main() {
|
||||
});
|
||||
|
||||
describe('using the test injector with modules', () => {
|
||||
let moduleConfig = {
|
||||
const moduleConfig = {
|
||||
providers: [FancyService],
|
||||
imports: [SomeLibModule],
|
||||
declarations: [SomeDirective, SomePipe, CompUsingModuleDirectiveAndPipe],
|
||||
@ -221,7 +221,7 @@ export function main() {
|
||||
|
||||
it('should use set up directives and pipes', () => {
|
||||
const compFixture = TestBed.createComponent(CompUsingModuleDirectiveAndPipe);
|
||||
let el = compFixture.debugElement;
|
||||
const el = compFixture.debugElement;
|
||||
|
||||
compFixture.detectChanges();
|
||||
expect(el.children[0].properties['title']).toBe('transformed someValue');
|
||||
@ -257,8 +257,8 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should use set up directives and pipes', withModule(moduleConfig, () => {
|
||||
let compFixture = TestBed.createComponent(CompUsingModuleDirectiveAndPipe);
|
||||
let el = compFixture.debugElement;
|
||||
const compFixture = TestBed.createComponent(CompUsingModuleDirectiveAndPipe);
|
||||
const el = compFixture.debugElement;
|
||||
|
||||
compFixture.detectChanges();
|
||||
expect(el.children[0].properties['title']).toBe('transformed someValue');
|
||||
@ -278,7 +278,7 @@ export function main() {
|
||||
|
||||
it('should allow to createSync components with templateUrl after explicit async compilation',
|
||||
() => {
|
||||
let fixture = TestBed.createComponent(CompWithUrlTemplate);
|
||||
const fixture = TestBed.createComponent(CompWithUrlTemplate);
|
||||
expect(fixture.nativeElement).toHaveText('from external template\n');
|
||||
});
|
||||
});
|
||||
@ -362,8 +362,8 @@ export function main() {
|
||||
|
||||
describe('providers', () => {
|
||||
beforeEach(() => {
|
||||
let resourceLoaderGet = jasmine.createSpy('resourceLoaderGet')
|
||||
.and.returnValue(Promise.resolve('Hello world!'));
|
||||
const resourceLoaderGet = jasmine.createSpy('resourceLoaderGet')
|
||||
.and.returnValue(Promise.resolve('Hello world!'));
|
||||
TestBed.configureTestingModule({declarations: [CompWithUrlTemplate]});
|
||||
TestBed.configureCompiler(
|
||||
{providers: [{provide: ResourceLoader, useValue: {get: resourceLoaderGet}}]});
|
||||
@ -372,7 +372,7 @@ export function main() {
|
||||
it('should use set up providers', fakeAsync(() => {
|
||||
TestBed.compileComponents();
|
||||
tick();
|
||||
let compFixture = TestBed.createComponent(CompWithUrlTemplate);
|
||||
const compFixture = TestBed.createComponent(CompWithUrlTemplate);
|
||||
expect(compFixture.nativeElement).toHaveText('Hello world!');
|
||||
}));
|
||||
});
|
||||
@ -548,7 +548,7 @@ export function main() {
|
||||
|
||||
it('should override a template', async(() => {
|
||||
TestBed.overrideComponent(ChildComp, {set: {template: '<span>Mock</span>'}});
|
||||
let componentFixture = TestBed.createComponent(ChildComp);
|
||||
const componentFixture = TestBed.createComponent(ChildComp);
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('Mock');
|
||||
|
||||
@ -586,7 +586,7 @@ export function main() {
|
||||
|
||||
it('should override component dependencies', async(() => {
|
||||
|
||||
let componentFixture = TestBed.createComponent(ParentComp);
|
||||
const componentFixture = TestBed.createComponent(ParentComp);
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('Parent(Mock)');
|
||||
}));
|
||||
|
Reference in New Issue
Block a user