@ -6,8 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {CompileMetadataResolver, CompileReflector, CompilerConfig, DirectiveNormalizer, DirectiveResolver, DomElementSchemaRegistry, ElementSchemaRegistry, HtmlParser, I18NHtmlParser, JitCompiler, JitEvaluator, JitSummaryResolver, Lexer, NgModuleCompiler, NgModuleResolver, Parser, PipeResolver, ProviderMeta, ResourceLoader, StaticSymbolCache, StyleCompiler, SummaryResolver, TemplateParser, UrlResolver, ViewCompiler} from '@angular/compiler';
|
||||
import {Compiler, CompilerFactory, CompilerOptions, ComponentFactory, Inject, InjectionToken, Injector, MissingTranslationStrategy, ModuleWithComponentFactories, NgModuleFactory, Optional, PACKAGE_ROOT_URL, StaticProvider, TRANSLATIONS, TRANSLATIONS_FORMAT, Type, ViewEncapsulation, isDevMode, ɵConsole as Console} from '@angular/core';
|
||||
import {CompileMetadataResolver, CompilerConfig, CompileReflector, DirectiveNormalizer, DirectiveResolver, DomElementSchemaRegistry, ElementSchemaRegistry, HtmlParser, I18NHtmlParser, JitCompiler, JitEvaluator, JitSummaryResolver, Lexer, NgModuleCompiler, NgModuleResolver, Parser, PipeResolver, ProviderMeta, ResourceLoader, StaticSymbolCache, StyleCompiler, SummaryResolver, TemplateParser, UrlResolver, ViewCompiler} from '@angular/compiler';
|
||||
import {Compiler, CompilerFactory, CompilerOptions, ComponentFactory, Inject, InjectionToken, Injector, isDevMode, MissingTranslationStrategy, ModuleWithComponentFactories, NgModuleFactory, Optional, PACKAGE_ROOT_URL, StaticProvider, TRANSLATIONS, TRANSLATIONS_FORMAT, Type, ViewEncapsulation, ɵConsole as Console} from '@angular/core';
|
||||
|
||||
import {JitReflector} from './compiler_reflector';
|
||||
|
||||
@ -22,9 +22,10 @@ export const DEFAULT_PACKAGE_URL_PROVIDER = {
|
||||
};
|
||||
|
||||
const _NO_RESOURCE_LOADER: ResourceLoader = {
|
||||
get(url: string): Promise<string>{
|
||||
throw new Error(
|
||||
`No ResourceLoader implementation has been provided. Can't read the url "${url}"`);}
|
||||
get(url: string): Promise<string> {
|
||||
throw new Error(
|
||||
`No ResourceLoader implementation has been provided. Can't read the url "${url}"`);
|
||||
}
|
||||
};
|
||||
|
||||
const baseHtmlParser = new InjectionToken('HtmlParser');
|
||||
@ -71,13 +72,21 @@ export class CompilerImpl implements Compiler {
|
||||
componentFactories: result.componentFactories as ComponentFactory<any>[],
|
||||
}));
|
||||
}
|
||||
loadAotSummaries(summaries: () => any[]) { this._delegate.loadAotSummaries(summaries); }
|
||||
hasAotSummary(ref: Type<any>): boolean { return this._delegate.hasAotSummary(ref); }
|
||||
loadAotSummaries(summaries: () => any[]) {
|
||||
this._delegate.loadAotSummaries(summaries);
|
||||
}
|
||||
hasAotSummary(ref: Type<any>): boolean {
|
||||
return this._delegate.hasAotSummary(ref);
|
||||
}
|
||||
getComponentFactory<T>(component: Type<T>): ComponentFactory<T> {
|
||||
return this._delegate.getComponentFactory(component) as ComponentFactory<T>;
|
||||
}
|
||||
clearCache(): void { this._delegate.clearCache(); }
|
||||
clearCacheFor(type: Type<any>) { this._delegate.clearCacheFor(type); }
|
||||
clearCache(): void {
|
||||
this._delegate.clearCache();
|
||||
}
|
||||
clearCacheFor(type: Type<any>) {
|
||||
this._delegate.clearCacheFor(type);
|
||||
}
|
||||
getModuleId(moduleType: Type<any>): string|undefined {
|
||||
const meta = this._metadataResolver.getNgModuleMetadata(moduleType);
|
||||
return meta && meta.id || undefined;
|
||||
@ -102,13 +111,14 @@ const COMPILER_PROVIDERS__PRE_R3__ = <StaticProvider[]>[
|
||||
},
|
||||
{
|
||||
provide: I18NHtmlParser,
|
||||
useFactory: (parser: HtmlParser, translations: string | null, format: string,
|
||||
config: CompilerConfig, console: Console) => {
|
||||
translations = translations || '';
|
||||
const missingTranslation =
|
||||
translations ? config.missingTranslation ! : MissingTranslationStrategy.Ignore;
|
||||
return new I18NHtmlParser(parser, translations, format, missingTranslation, console);
|
||||
},
|
||||
useFactory:
|
||||
(parser: HtmlParser, translations: string|null, format: string, config: CompilerConfig,
|
||||
console: Console) => {
|
||||
translations = translations || '';
|
||||
const missingTranslation =
|
||||
translations ? config.missingTranslation! : MissingTranslationStrategy.Ignore;
|
||||
return new I18NHtmlParser(parser, translations, format, missingTranslation, console);
|
||||
},
|
||||
deps: [
|
||||
baseHtmlParser,
|
||||
[new Optional(), new Inject(TRANSLATIONS)],
|
||||
@ -122,36 +132,38 @@ const COMPILER_PROVIDERS__PRE_R3__ = <StaticProvider[]>[
|
||||
useExisting: I18NHtmlParser,
|
||||
},
|
||||
{
|
||||
provide: TemplateParser, deps: [CompilerConfig, CompileReflector,
|
||||
Parser, ElementSchemaRegistry,
|
||||
I18NHtmlParser, Console]
|
||||
provide: TemplateParser,
|
||||
deps: [CompilerConfig, CompileReflector, Parser, ElementSchemaRegistry, I18NHtmlParser, Console]
|
||||
},
|
||||
{provide: JitEvaluator, useClass: JitEvaluator, deps: []},
|
||||
{provide: DirectiveNormalizer, deps: [ResourceLoader, UrlResolver, HtmlParser, CompilerConfig]},
|
||||
{
|
||||
provide: CompileMetadataResolver,
|
||||
deps: [
|
||||
CompilerConfig, HtmlParser, NgModuleResolver, DirectiveResolver, PipeResolver,
|
||||
SummaryResolver, ElementSchemaRegistry, DirectiveNormalizer, Console,
|
||||
[Optional, StaticSymbolCache], CompileReflector, [Optional, ERROR_COLLECTOR_TOKEN]
|
||||
]
|
||||
},
|
||||
{ provide: JitEvaluator, useClass: JitEvaluator, deps: [] },
|
||||
{ provide: DirectiveNormalizer, deps: [ResourceLoader, UrlResolver, HtmlParser, CompilerConfig]},
|
||||
{ provide: CompileMetadataResolver, deps: [CompilerConfig, HtmlParser, NgModuleResolver,
|
||||
DirectiveResolver, PipeResolver,
|
||||
SummaryResolver,
|
||||
ElementSchemaRegistry,
|
||||
DirectiveNormalizer, Console,
|
||||
[Optional, StaticSymbolCache],
|
||||
CompileReflector,
|
||||
[Optional, ERROR_COLLECTOR_TOKEN]]},
|
||||
DEFAULT_PACKAGE_URL_PROVIDER,
|
||||
{ provide: StyleCompiler, deps: [UrlResolver]},
|
||||
{ provide: ViewCompiler, deps: [CompileReflector]},
|
||||
{ provide: NgModuleCompiler, deps: [CompileReflector] },
|
||||
{ provide: CompilerConfig, useValue: new CompilerConfig()},
|
||||
{ provide: Compiler, useClass: CompilerImpl, deps: [Injector, CompileMetadataResolver,
|
||||
TemplateParser, StyleCompiler,
|
||||
ViewCompiler, NgModuleCompiler,
|
||||
SummaryResolver, CompileReflector, JitEvaluator, CompilerConfig,
|
||||
Console]},
|
||||
{ provide: DomElementSchemaRegistry, deps: []},
|
||||
{ provide: ElementSchemaRegistry, useExisting: DomElementSchemaRegistry},
|
||||
{ provide: UrlResolver, deps: [PACKAGE_ROOT_URL]},
|
||||
{ provide: DirectiveResolver, deps: [CompileReflector]},
|
||||
{ provide: PipeResolver, deps: [CompileReflector]},
|
||||
{ provide: NgModuleResolver, deps: [CompileReflector]},
|
||||
{provide: StyleCompiler, deps: [UrlResolver]},
|
||||
{provide: ViewCompiler, deps: [CompileReflector]},
|
||||
{provide: NgModuleCompiler, deps: [CompileReflector]},
|
||||
{provide: CompilerConfig, useValue: new CompilerConfig()},
|
||||
{
|
||||
provide: Compiler,
|
||||
useClass: CompilerImpl,
|
||||
deps: [
|
||||
Injector, CompileMetadataResolver, TemplateParser, StyleCompiler, ViewCompiler,
|
||||
NgModuleCompiler, SummaryResolver, CompileReflector, JitEvaluator, CompilerConfig, Console
|
||||
]
|
||||
},
|
||||
{provide: DomElementSchemaRegistry, deps: []},
|
||||
{provide: ElementSchemaRegistry, useExisting: DomElementSchemaRegistry},
|
||||
{provide: UrlResolver, deps: [PACKAGE_ROOT_URL]},
|
||||
{provide: DirectiveResolver, deps: [CompileReflector]},
|
||||
{provide: PipeResolver, deps: [CompileReflector]},
|
||||
{provide: NgModuleResolver, deps: [CompileReflector]},
|
||||
];
|
||||
|
||||
export const COMPILER_PROVIDERS__POST_R3__ =
|
||||
@ -193,7 +205,7 @@ export class JitCompilerFactory implements CompilerFactory {
|
||||
},
|
||||
deps: []
|
||||
},
|
||||
opts.providers !
|
||||
opts.providers!
|
||||
]);
|
||||
return injector.get(Compiler);
|
||||
}
|
||||
@ -203,7 +215,7 @@ function _mergeOptions(optionsArr: CompilerOptions[]): CompilerOptions {
|
||||
return {
|
||||
useJit: _lastDefined(optionsArr.map(options => options.useJit)),
|
||||
defaultEncapsulation: _lastDefined(optionsArr.map(options => options.defaultEncapsulation)),
|
||||
providers: _mergeArrays(optionsArr.map(options => options.providers !)),
|
||||
providers: _mergeArrays(optionsArr.map(options => options.providers!)),
|
||||
missingTranslation: _lastDefined(optionsArr.map(options => options.missingTranslation)),
|
||||
preserveWhitespaces: _lastDefined(optionsArr.map(options => options.preserveWhitespaces)),
|
||||
};
|
||||
|
@ -6,8 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {CompileReflector, ExternalReference, Identifiers, getUrlScheme, syntaxError} from '@angular/compiler';
|
||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, ChangeDetectionStrategy, ChangeDetectorRef, Component, ComponentFactory, ComponentFactoryResolver, ComponentRef, ElementRef, Injector, LOCALE_ID, NgModuleFactory, NgModuleRef, QueryList, Renderer2, SecurityContext, TRANSLATIONS_FORMAT, TemplateRef, ViewContainerRef, ViewEncapsulation, ɵCodegenComponentFactoryResolver, ɵEMPTY_ARRAY, ɵEMPTY_MAP, ɵReflectionCapabilities as ReflectionCapabilities, ɵand, ɵccf, ɵcmf, ɵcrt, ɵdid, ɵeld, ɵinlineInterpolate, ɵinterpolate, ɵmod, ɵmpd, ɵncd, ɵnov, ɵpad, ɵpid, ɵpod, ɵppd, ɵprd, ɵqud, ɵregisterModuleFactory, ɵstringify as stringify, ɵted, ɵunv, ɵvid} from '@angular/core';
|
||||
import {CompileReflector, ExternalReference, getUrlScheme, Identifiers, syntaxError} from '@angular/compiler';
|
||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, ChangeDetectionStrategy, ChangeDetectorRef, Component, ComponentFactory, ComponentFactoryResolver, ComponentRef, ElementRef, Injector, LOCALE_ID, NgModuleFactory, NgModuleRef, QueryList, Renderer2, SecurityContext, TemplateRef, TRANSLATIONS_FORMAT, ViewContainerRef, ViewEncapsulation, ɵand, ɵccf, ɵcmf, ɵCodegenComponentFactoryResolver, ɵcrt, ɵdid, ɵeld, ɵEMPTY_ARRAY, ɵEMPTY_MAP, ɵinlineInterpolate, ɵinterpolate, ɵmod, ɵmpd, ɵncd, ɵnov, ɵpad, ɵpid, ɵpod, ɵppd, ɵprd, ɵqud, ɵReflectionCapabilities as ReflectionCapabilities, ɵregisterModuleFactory, ɵstringify as stringify, ɵted, ɵunv, ɵvid} from '@angular/core';
|
||||
|
||||
export const MODULE_SUFFIX = '';
|
||||
const builtinExternalReferences = createBuiltinExternalReferencesMap();
|
||||
@ -23,7 +23,8 @@ export class JitReflector implements CompileReflector {
|
||||
return scheme ? moduleId : `package:${moduleId}${MODULE_SUFFIX}`;
|
||||
} else if (moduleId !== null && moduleId !== void 0) {
|
||||
throw syntaxError(
|
||||
`moduleId should be a string in "${stringify(type)}". See https://goo.gl/wIDDiL for more information.\n` +
|
||||
`moduleId should be a string in "${
|
||||
stringify(type)}". See https://goo.gl/wIDDiL for more information.\n` +
|
||||
`If you're using Webpack you should inline the template and the styles, see https://goo.gl/X2J8zc.`);
|
||||
}
|
||||
|
||||
@ -32,7 +33,9 @@ export class JitReflector implements CompileReflector {
|
||||
parameters(typeOrFunc: /*Type*/ any): any[][] {
|
||||
return this.reflectionCapabilities.parameters(typeOrFunc);
|
||||
}
|
||||
tryAnnotations(typeOrFunc: /*Type*/ any): any[] { return this.annotations(typeOrFunc); }
|
||||
tryAnnotations(typeOrFunc: /*Type*/ any): any[] {
|
||||
return this.annotations(typeOrFunc);
|
||||
}
|
||||
annotations(typeOrFunc: /*Type*/ any): any[] {
|
||||
return this.reflectionCapabilities.annotations(typeOrFunc);
|
||||
}
|
||||
@ -45,7 +48,9 @@ export class JitReflector implements CompileReflector {
|
||||
hasLifecycleHook(type: any, lcProperty: string): boolean {
|
||||
return this.reflectionCapabilities.hasLifecycleHook(type, lcProperty);
|
||||
}
|
||||
guards(type: any): {[key: string]: any} { return this.reflectionCapabilities.guards(type); }
|
||||
guards(type: any): {[key: string]: any} {
|
||||
return this.reflectionCapabilities.guards(type);
|
||||
}
|
||||
resolveExternalReference(ref: ExternalReference): any {
|
||||
return builtinExternalReferences.get(ref) || ref.runtime;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {ResourceLoader} from '@angular/compiler';
|
||||
import {CompilerFactory, PlatformRef, Provider, StaticProvider, createPlatformFactory, platformCore} from '@angular/core';
|
||||
import {CompilerFactory, createPlatformFactory, platformCore, PlatformRef, Provider, StaticProvider} from '@angular/core';
|
||||
|
||||
import {platformCoreDynamic} from './platform_core_dynamic';
|
||||
import {INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from './platform_providers';
|
||||
|
@ -6,7 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {COMPILER_OPTIONS, CompilerFactory, PlatformRef, StaticProvider, createPlatformFactory, platformCore} from '@angular/core';
|
||||
import {COMPILER_OPTIONS, CompilerFactory, createPlatformFactory, platformCore, PlatformRef, StaticProvider} from '@angular/core';
|
||||
|
||||
import {JitCompilerFactory} from './compiler_factory';
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,9 @@ export class ResourceLoaderImpl extends ResourceLoader {
|
||||
}
|
||||
};
|
||||
|
||||
xhr.onerror = function() { reject(`Failed to load ${url}`); };
|
||||
xhr.onerror = function() {
|
||||
reject(`Failed to load ${url}`);
|
||||
};
|
||||
|
||||
xhr.send();
|
||||
return promise;
|
||||
|
@ -25,9 +25,9 @@ class SomeMetadata implements SomeMetadataType {
|
||||
arrayProp: any[];
|
||||
|
||||
constructor(options: SomeMetadataType) {
|
||||
this.plainProp = options.plainProp !;
|
||||
this._getterProp = options.getterProp !;
|
||||
this.arrayProp = options.arrayProp !;
|
||||
this.plainProp = options.plainProp!;
|
||||
this._getterProp = options.getterProp!;
|
||||
this.arrayProp = options.arrayProp!;
|
||||
Object.defineProperty(this, 'getterProp', {
|
||||
enumerable: true, // getters are non-enumerable by default in es2015
|
||||
get: () => this._getterProp,
|
||||
@ -45,7 +45,7 @@ class OtherMetadata extends SomeMetadata implements OtherMetadataType {
|
||||
arrayProp: options.arrayProp
|
||||
});
|
||||
|
||||
this.otherPlainProp = options.otherPlainProp !;
|
||||
this.otherPlainProp = options.otherPlainProp!;
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +53,9 @@ class OtherMetadata extends SomeMetadata implements OtherMetadataType {
|
||||
describe('metadata overrider', () => {
|
||||
let overrider: MetadataOverrider;
|
||||
|
||||
beforeEach(() => { overrider = new MetadataOverrider(); });
|
||||
beforeEach(() => {
|
||||
overrider = new MetadataOverrider();
|
||||
});
|
||||
|
||||
it('should return a new instance with the same values', () => {
|
||||
const oldInstance = new SomeMetadata({plainProp: 'somePlainProp', getterProp: 'someInput'});
|
||||
@ -130,7 +132,6 @@ class OtherMetadata extends SomeMetadata implements OtherMetadataType {
|
||||
const instance3 =
|
||||
overrider.overrideMetadata(SomeMetadata, instance2, {remove: {arrayProp: [Class3]}});
|
||||
expect(instance3).toEqual(new SomeMetadata({arrayProp: [Class2]}));
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@ -149,7 +150,6 @@ class OtherMetadata extends SomeMetadata implements OtherMetadataType {
|
||||
otherPlainProp: 'newOtherProp'
|
||||
}));
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {ResourceLoader, UrlResolver} from '@angular/compiler';
|
||||
import {Component} from '@angular/core';
|
||||
import {TestBed, async, fakeAsync, tick} from '@angular/core/testing';
|
||||
import {async, fakeAsync, TestBed, tick} from '@angular/core/testing';
|
||||
import {CachedResourceLoader} from '@angular/platform-browser-dynamic/src/resource_loader/resource_loader_cache';
|
||||
import {setTemplateCache} from '@angular/platform-browser-dynamic/test/resource_loader/resource_loader_cache_setter';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
@ -31,7 +31,9 @@ if (isBrowser) {
|
||||
|
||||
it('should resolve the Promise with the cached file content on success', async(() => {
|
||||
resourceLoader = createCachedResourceLoader();
|
||||
resourceLoader.get('test.html').then((text) => { expect(text).toBe('<div>Hello</div>'); });
|
||||
resourceLoader.get('test.html').then((text) => {
|
||||
expect(text).toBe('<div>Hello</div>');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should reject the Promise on failure', async(() => {
|
||||
|
@ -22,7 +22,9 @@ if (isBrowser) {
|
||||
const url200 = '/base/angular/packages/platform-browser/test/browser/static_assets/200.html';
|
||||
const url404 = '/bad/path/404.html';
|
||||
|
||||
beforeEach(() => { resourceLoader = new ResourceLoaderImpl(); });
|
||||
beforeEach(() => {
|
||||
resourceLoader = new ResourceLoaderImpl();
|
||||
});
|
||||
|
||||
it('should resolve the Promise with the file content on success',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
import {ResourceLoader} from '@angular/compiler';
|
||||
import {Compiler, Component, NgModule} from '@angular/core';
|
||||
import {TestBed, async, fakeAsync, inject, tick} from '@angular/core/testing';
|
||||
|
||||
import {async, fakeAsync, inject, TestBed, tick} from '@angular/core/testing';
|
||||
import {ResourceLoaderImpl} from '@angular/platform-browser-dynamic/src/resource_loader/resource_loader_impl';
|
||||
|
||||
|
||||
@ -17,10 +16,15 @@ import {ResourceLoaderImpl} from '@angular/platform-browser-dynamic/src/resource
|
||||
// Components for the tests.
|
||||
class FancyService {
|
||||
value: string = 'real value';
|
||||
getAsyncValue() { return Promise.resolve('async value'); }
|
||||
getAsyncValue() {
|
||||
return Promise.resolve('async value');
|
||||
}
|
||||
getTimeoutValue() {
|
||||
return new Promise(
|
||||
(resolve, reject) => { setTimeout(() => { resolve('timeout value'); }, 10); });
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve('timeout value');
|
||||
}, 10);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,15 +46,21 @@ if (isBrowser) {
|
||||
describe('using the async helper', () => {
|
||||
let actuallyDone: boolean;
|
||||
|
||||
beforeEach(() => { actuallyDone = false; });
|
||||
beforeEach(() => {
|
||||
actuallyDone = false;
|
||||
});
|
||||
|
||||
afterEach(() => { expect(actuallyDone).toEqual(true); });
|
||||
afterEach(() => {
|
||||
expect(actuallyDone).toEqual(true);
|
||||
});
|
||||
|
||||
it('should run async tests with ResourceLoaders', async(() => {
|
||||
const resourceLoader = new ResourceLoaderImpl();
|
||||
resourceLoader
|
||||
.get('/base/angular/packages/platform-browser/test/static_assets/test.html')
|
||||
.then(() => { actuallyDone = true; });
|
||||
.then(() => {
|
||||
actuallyDone = true;
|
||||
});
|
||||
}),
|
||||
10000); // Long timeout here because this test makes an actual ResourceLoader.
|
||||
});
|
||||
@ -70,7 +80,9 @@ if (isBrowser) {
|
||||
it('should allow the use of fakeAsync',
|
||||
fakeAsync(inject([FancyService], (service: any /** TODO #9100 */) => {
|
||||
let value: any /** TODO #9100 */;
|
||||
service.getAsyncValue().then(function(val: any /** TODO #9100 */) { value = val; });
|
||||
service.getAsyncValue().then(function(val: any /** TODO #9100 */) {
|
||||
value = val;
|
||||
});
|
||||
tick();
|
||||
expect(value).toEqual('async value');
|
||||
})));
|
||||
@ -113,7 +125,9 @@ if (isBrowser) {
|
||||
return promise;
|
||||
};
|
||||
|
||||
const restoreJasmineIt = () => { jasmine.getEnv().it = originalJasmineIt; };
|
||||
const restoreJasmineIt = () => {
|
||||
jasmine.getEnv().it = originalJasmineIt;
|
||||
};
|
||||
|
||||
it('should fail when an ResourceLoader fails', done => {
|
||||
const itPromise = patchJasmineIt();
|
||||
@ -124,7 +138,9 @@ if (isBrowser) {
|
||||
}));
|
||||
|
||||
itPromise.then(
|
||||
() => { done.fail('Expected test to fail, but it did not'); },
|
||||
() => {
|
||||
done.fail('Expected test to fail, but it did not');
|
||||
},
|
||||
(err: any) => {
|
||||
expect(err.message)
|
||||
.toEqual('Uncaught (in promise): Failed to load non-existent.html');
|
||||
|
@ -39,7 +39,9 @@ export class TestingCompilerImpl implements TestingCompiler {
|
||||
constructor(
|
||||
private _compiler: CompilerImpl, private _directiveResolver: MockDirectiveResolver,
|
||||
private _pipeResolver: MockPipeResolver, private _moduleResolver: MockNgModuleResolver) {}
|
||||
get injector(): Injector { return this._compiler.injector; }
|
||||
get injector(): Injector {
|
||||
return this._compiler.injector;
|
||||
}
|
||||
|
||||
compileModuleSync<T>(moduleType: Type<T>): NgModuleFactory<T> {
|
||||
return this._compiler.compileModuleSync(moduleType);
|
||||
@ -78,14 +80,14 @@ export class TestingCompilerImpl implements TestingCompiler {
|
||||
this.checkOverrideAllowed(directive);
|
||||
const oldMetadata = this._directiveResolver.resolve(directive, false);
|
||||
this._directiveResolver.setDirective(
|
||||
directive, this._overrider.overrideMetadata(Directive, oldMetadata !, override));
|
||||
directive, this._overrider.overrideMetadata(Directive, oldMetadata!, override));
|
||||
this.clearCacheFor(directive);
|
||||
}
|
||||
overrideComponent(component: Type<any>, override: MetadataOverride<Component>): void {
|
||||
this.checkOverrideAllowed(component);
|
||||
const oldMetadata = this._directiveResolver.resolve(component, false);
|
||||
this._directiveResolver.setDirective(
|
||||
component, this._overrider.overrideMetadata(Component, oldMetadata !, override));
|
||||
component, this._overrider.overrideMetadata(Component, oldMetadata!, override));
|
||||
this.clearCacheFor(component);
|
||||
}
|
||||
overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>): void {
|
||||
@ -94,11 +96,19 @@ export class TestingCompilerImpl implements TestingCompiler {
|
||||
this._pipeResolver.setPipe(pipe, this._overrider.overrideMetadata(Pipe, oldMetadata, override));
|
||||
this.clearCacheFor(pipe);
|
||||
}
|
||||
loadAotSummaries(summaries: () => any[]) { this._compiler.loadAotSummaries(summaries); }
|
||||
clearCache(): void { this._compiler.clearCache(); }
|
||||
clearCacheFor(type: Type<any>) { this._compiler.clearCacheFor(type); }
|
||||
loadAotSummaries(summaries: () => any[]) {
|
||||
this._compiler.loadAotSummaries(summaries);
|
||||
}
|
||||
clearCache(): void {
|
||||
this._compiler.clearCache();
|
||||
}
|
||||
clearCacheFor(type: Type<any>) {
|
||||
this._compiler.clearCacheFor(type);
|
||||
}
|
||||
|
||||
getComponentFromError(error: Error) { return (error as any)[ERROR_COMPONENT_TYPE] || null; }
|
||||
getComponentFromError(error: Error) {
|
||||
return (error as any)[ERROR_COMPONENT_TYPE] || null;
|
||||
}
|
||||
|
||||
getModuleId(moduleType: Type<any>): string|undefined {
|
||||
return this._moduleResolver.resolve(moduleType, true).id;
|
||||
|
@ -15,7 +15,9 @@ import {TestComponentRenderer} from '@angular/core/testing';
|
||||
*/
|
||||
@Injectable()
|
||||
export class DOMTestComponentRenderer extends TestComponentRenderer {
|
||||
constructor(@Inject(DOCUMENT) private _doc: any) { super(); }
|
||||
constructor(@Inject(DOCUMENT) private _doc: any) {
|
||||
super();
|
||||
}
|
||||
|
||||
insertRootElement(rootElId: string) {
|
||||
const template = getDOM().getDefaultDocument().createElement('template');
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {COMPILER_OPTIONS, CompilerFactory, Injector, PlatformRef, createPlatformFactory} from '@angular/core';
|
||||
import {COMPILER_OPTIONS, CompilerFactory, createPlatformFactory, Injector, PlatformRef} from '@angular/core';
|
||||
import {ɵTestingCompilerFactory as TestingCompilerFactory} from '@angular/core/testing';
|
||||
import {ɵplatformCoreDynamic as platformCoreDynamic} from '@angular/platform-browser-dynamic';
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {NgModule, PlatformRef, StaticProvider, createPlatformFactory} from '@angular/core';
|
||||
import {createPlatformFactory, NgModule, PlatformRef, StaticProvider} from '@angular/core';
|
||||
import {TestComponentRenderer} from '@angular/core/testing';
|
||||
import {ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS as INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from '@angular/platform-browser-dynamic';
|
||||
import {BrowserTestingModule} from '@angular/platform-browser/testing';
|
||||
|
Reference in New Issue
Block a user