@ -7,12 +7,12 @@
|
||||
*/
|
||||
|
||||
import {DOCUMENT, isPlatformBrowser, ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, Directive, ErrorHandler, Inject, Injector, Input, LOCALE_ID, NgModule, OnDestroy, PLATFORM_ID, PLATFORM_INITIALIZER, Pipe, Provider, Sanitizer, StaticProvider, Type, VERSION, createPlatformFactory} from '@angular/core';
|
||||
import {APP_INITIALIZER, Compiler, Component, createPlatformFactory, CUSTOM_ELEMENTS_SCHEMA, Directive, ErrorHandler, Inject, Injector, Input, LOCALE_ID, NgModule, OnDestroy, Pipe, PLATFORM_ID, PLATFORM_INITIALIZER, Provider, Sanitizer, StaticProvider, Type, VERSION} from '@angular/core';
|
||||
import {ApplicationRef, destroyPlatform} from '@angular/core/src/application_ref';
|
||||
import {Console} from '@angular/core/src/console';
|
||||
import {ComponentRef} from '@angular/core/src/linker/component_factory';
|
||||
import {Testability, TestabilityRegistry} from '@angular/core/src/testability/testability';
|
||||
import {AsyncTestCompleter, Log, afterEach, beforeEach, beforeEachProviders, describe, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {afterEach, AsyncTestCompleter, beforeEach, beforeEachProviders, describe, inject, it, Log} from '@angular/core/testing/src/testing_internal';
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
@ -25,7 +25,9 @@ class NonExistentComp {
|
||||
@Component({selector: 'hello-app', template: '{{greeting}} world!'})
|
||||
class HelloRootCmp {
|
||||
greeting: string;
|
||||
constructor() { this.greeting = 'hello'; }
|
||||
constructor() {
|
||||
this.greeting = 'hello';
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'hello-app', template: 'before: <ng-content></ng-content> after: done'})
|
||||
@ -36,7 +38,9 @@ class HelloRootCmpContent {
|
||||
@Component({selector: 'hello-app-2', template: '{{greeting}} world, again!'})
|
||||
class HelloRootCmp2 {
|
||||
greeting: string;
|
||||
constructor() { this.greeting = 'hello'; }
|
||||
constructor() {
|
||||
this.greeting = 'hello';
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'hello-app', template: ''})
|
||||
@ -52,7 +56,9 @@ class HelloRootCmp3 {
|
||||
class HelloRootCmp4 {
|
||||
appRef: any /** TODO #9100 */;
|
||||
|
||||
constructor(@Inject(ApplicationRef) appRef: ApplicationRef) { this.appRef = appRef; }
|
||||
constructor(@Inject(ApplicationRef) appRef: ApplicationRef) {
|
||||
this.appRef = appRef;
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'hello-app'})
|
||||
@ -66,9 +72,13 @@ class HelloRootDirectiveIsNotCmp {
|
||||
@Component({selector: 'hello-app', template: ''})
|
||||
class HelloOnDestroyTickCmp implements OnDestroy {
|
||||
appRef: ApplicationRef;
|
||||
constructor(@Inject(ApplicationRef) appRef: ApplicationRef) { this.appRef = appRef; }
|
||||
constructor(@Inject(ApplicationRef) appRef: ApplicationRef) {
|
||||
this.appRef = appRef;
|
||||
}
|
||||
|
||||
ngOnDestroy(): void { this.appRef.tick(); }
|
||||
ngOnDestroy(): void {
|
||||
this.appRef.tick();
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'hello-app', templateUrl: './sometemplate.html'})
|
||||
@ -79,13 +89,14 @@ class HelloUrlCmp {
|
||||
@Directive({selector: '[someDir]', host: {'[title]': 'someDir'}})
|
||||
class SomeDirective {
|
||||
// TODO(issue/24571): remove '!'.
|
||||
@Input()
|
||||
someDir !: string;
|
||||
@Input() someDir!: string;
|
||||
}
|
||||
|
||||
@Pipe({name: 'somePipe'})
|
||||
class SomePipe {
|
||||
transform(value: string): any { return `transformed ${value}`; }
|
||||
transform(value: string): any {
|
||||
return `transformed ${value}`;
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'hello-app', template: `<div [someDir]="'someValue' | somePipe"></div>`})
|
||||
@ -99,7 +110,9 @@ class HelloCmpUsingCustomElement {
|
||||
|
||||
class MockConsole {
|
||||
res: any[][] = [];
|
||||
error(...s: any[]): void { this.res.push(s); }
|
||||
error(...s: any[]): void {
|
||||
this.res.push(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -107,7 +120,9 @@ class DummyConsole implements Console {
|
||||
public warnings: string[] = [];
|
||||
|
||||
log(message: string) {}
|
||||
warn(message: string) { this.warnings.push(message); }
|
||||
warn(message: string) {
|
||||
this.warnings.push(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -135,7 +150,9 @@ function bootstrap(
|
||||
if (isNode) return;
|
||||
let compilerConsole: DummyConsole;
|
||||
|
||||
beforeEachProviders(() => { return [Log]; });
|
||||
beforeEachProviders(() => {
|
||||
return [Log];
|
||||
});
|
||||
|
||||
beforeEach(inject([DOCUMENT], (doc: any) => {
|
||||
destroyPlatform();
|
||||
@ -419,7 +436,6 @@ function bootstrap(
|
||||
|
||||
it('should remove styles when transitioning from a server render',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
|
||||
@Component({
|
||||
selector: 'root',
|
||||
template: 'root',
|
||||
@ -449,8 +465,9 @@ function bootstrap(
|
||||
platform.bootstrapModule(TestModule).then(() => {
|
||||
const styles: HTMLElement[] =
|
||||
Array.prototype.slice.apply(document.getElementsByTagName('style') || []);
|
||||
styles.forEach(
|
||||
style => { expect(style.getAttribute('ng-transition')).not.toBe('my-app'); });
|
||||
styles.forEach(style => {
|
||||
expect(style.getAttribute('ng-transition')).not.toBe('my-app');
|
||||
});
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -487,7 +504,9 @@ function bootstrap(
|
||||
})
|
||||
class CompA {
|
||||
title: string = '';
|
||||
ngDoCheck() { log.push('CompA:ngDoCheck'); }
|
||||
ngDoCheck() {
|
||||
log.push('CompA:ngDoCheck');
|
||||
}
|
||||
onClick() {
|
||||
this.title = 'CompA';
|
||||
log.push('CompA:onClick');
|
||||
@ -500,7 +519,9 @@ function bootstrap(
|
||||
})
|
||||
class CompB {
|
||||
title: string = '';
|
||||
ngDoCheck() { log.push('CompB:ngDoCheck'); }
|
||||
ngDoCheck() {
|
||||
log.push('CompB:ngDoCheck');
|
||||
}
|
||||
onClick() {
|
||||
this.title = 'CompB';
|
||||
log.push('CompB:onClick');
|
||||
|
Reference in New Issue
Block a user