fix(platform-browser-dynamic): Rename CACHED_TEMPLATE_PROVIDER to RESOURCE_CACHE_PROVIDER (#10866)
* fix(platform-browser-dynamic): Rename CACHED_TEMPLATE_PROVIDER to RESOURCE_CACHE_PROVIDER Closes #9741 BREAKING CHANGE: `CACHED_TEMPLATE_PROVIDER` is now renamed to `RESOURCE_CACHE_PROVIDER` Before: ```js import {CACHED_TEMPLATE_PROVIDER} from '@angular/platform-browser-dynamic'; ``` After: ```js import {RESOURCE_CACHE_PROVIDER} from '@angular/platform-browser-dynamic'; ``` * Rename XHR -> ResourceLoader
This commit is contained in:
@ -9,13 +9,13 @@
|
||||
import {CompileDirectiveMetadata, CompileStylesheetMetadata, CompileTemplateMetadata, CompileTypeMetadata} from '@angular/compiler/src/compile_metadata';
|
||||
import {CompilerConfig} from '@angular/compiler/src/config';
|
||||
import {DirectiveNormalizer} from '@angular/compiler/src/directive_normalizer';
|
||||
import {XHR} from '@angular/compiler/src/xhr';
|
||||
import {MockXHR} from '@angular/compiler/testing/xhr_mock';
|
||||
import {ResourceLoader} from '@angular/compiler/src/resource_loader';
|
||||
import {MockResourceLoader} from '@angular/compiler/testing/resource_loader_mock';
|
||||
import {ViewEncapsulation} from '@angular/core/src/metadata/view';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {SpyXHR} from './spies';
|
||||
import {SpyResourceLoader} from './spies';
|
||||
import {TEST_COMPILER_PROVIDERS} from './test_bindings';
|
||||
|
||||
export function main() {
|
||||
@ -115,9 +115,10 @@ export function main() {
|
||||
|
||||
it('should load a template from a url that is resolved against moduleUrl',
|
||||
inject(
|
||||
[AsyncTestCompleter, DirectiveNormalizer, XHR],
|
||||
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer, xhr: MockXHR) => {
|
||||
xhr.expect('package:some/module/sometplurl.html', 'a');
|
||||
[AsyncTestCompleter, DirectiveNormalizer, ResourceLoader],
|
||||
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer,
|
||||
resourceLoader: MockResourceLoader) => {
|
||||
resourceLoader.expect('package:some/module/sometplurl.html', 'a');
|
||||
normalizer
|
||||
.normalizeTemplateAsync(dirType, new CompileTemplateMetadata({
|
||||
encapsulation: null,
|
||||
@ -131,14 +132,15 @@ export function main() {
|
||||
expect(template.templateUrl).toEqual('package:some/module/sometplurl.html');
|
||||
async.done();
|
||||
});
|
||||
xhr.flush();
|
||||
resourceLoader.flush();
|
||||
}));
|
||||
|
||||
it('should resolve styles on the annotation against the moduleUrl',
|
||||
inject(
|
||||
[AsyncTestCompleter, DirectiveNormalizer, XHR],
|
||||
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer, xhr: MockXHR) => {
|
||||
xhr.expect('package:some/module/tpl/sometplurl.html', '');
|
||||
[AsyncTestCompleter, DirectiveNormalizer, ResourceLoader],
|
||||
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer,
|
||||
resourceLoader: MockResourceLoader) => {
|
||||
resourceLoader.expect('package:some/module/tpl/sometplurl.html', '');
|
||||
normalizer
|
||||
.normalizeTemplateAsync(dirType, new CompileTemplateMetadata({
|
||||
encapsulation: null,
|
||||
@ -151,14 +153,15 @@ export function main() {
|
||||
expect(template.styleUrls).toEqual(['package:some/module/test.css']);
|
||||
async.done();
|
||||
});
|
||||
xhr.flush();
|
||||
resourceLoader.flush();
|
||||
}));
|
||||
|
||||
it('should resolve styles in the template against the templateUrl',
|
||||
inject(
|
||||
[AsyncTestCompleter, DirectiveNormalizer, XHR],
|
||||
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer, xhr: MockXHR) => {
|
||||
xhr.expect(
|
||||
[AsyncTestCompleter, DirectiveNormalizer, ResourceLoader],
|
||||
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer,
|
||||
resourceLoader: MockResourceLoader) => {
|
||||
resourceLoader.expect(
|
||||
'package:some/module/tpl/sometplurl.html', '<style>@import test.css</style>');
|
||||
normalizer
|
||||
.normalizeTemplateAsync(dirType, new CompileTemplateMetadata({
|
||||
@ -172,21 +175,24 @@ export function main() {
|
||||
expect(template.styleUrls).toEqual(['package:some/module/tpl/test.css']);
|
||||
async.done();
|
||||
});
|
||||
xhr.flush();
|
||||
resourceLoader.flush();
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
describe('normalizeExternalStylesheets', () => {
|
||||
|
||||
beforeEach(
|
||||
() => { TestBed.configureCompiler({providers: [{provide: XHR, useClass: SpyXHR}]}); });
|
||||
beforeEach(() => {
|
||||
TestBed.configureCompiler(
|
||||
{providers: [{provide: ResourceLoader, useClass: SpyResourceLoader}]});
|
||||
});
|
||||
|
||||
it('should load an external stylesheet',
|
||||
inject(
|
||||
[AsyncTestCompleter, DirectiveNormalizer, XHR],
|
||||
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer, xhr: SpyXHR) => {
|
||||
programXhrSpy(xhr, {'package:some/module/test.css': 'a'});
|
||||
[AsyncTestCompleter, DirectiveNormalizer, ResourceLoader],
|
||||
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer,
|
||||
resourceLoader: SpyResourceLoader) => {
|
||||
programResourceLoaderSpy(resourceLoader, {'package:some/module/test.css': 'a'});
|
||||
normalizer
|
||||
.normalizeExternalStylesheets(new CompileTemplateMetadata({
|
||||
template: '',
|
||||
@ -206,9 +212,10 @@ export function main() {
|
||||
|
||||
it('should load stylesheets referenced by external stylesheets',
|
||||
inject(
|
||||
[AsyncTestCompleter, DirectiveNormalizer, XHR],
|
||||
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer, xhr: SpyXHR) => {
|
||||
programXhrSpy(xhr, {
|
||||
[AsyncTestCompleter, DirectiveNormalizer, ResourceLoader],
|
||||
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer,
|
||||
resourceLoader: SpyResourceLoader) => {
|
||||
programResourceLoaderSpy(resourceLoader, {
|
||||
'package:some/module/test.css': 'a@import "test2.css"',
|
||||
'package:some/module/test2.css': 'b'
|
||||
});
|
||||
@ -238,9 +245,10 @@ export function main() {
|
||||
describe('caching', () => {
|
||||
it('should work for templateUrl',
|
||||
inject(
|
||||
[AsyncTestCompleter, DirectiveNormalizer, XHR],
|
||||
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer, xhr: MockXHR) => {
|
||||
xhr.expect('package:some/module/cmp.html', 'a');
|
||||
[AsyncTestCompleter, DirectiveNormalizer, ResourceLoader],
|
||||
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer,
|
||||
resourceLoader: MockResourceLoader) => {
|
||||
resourceLoader.expect('package:some/module/cmp.html', 'a');
|
||||
var templateMeta = new CompileTemplateMetadata({
|
||||
templateUrl: 'cmp.html',
|
||||
});
|
||||
@ -254,7 +262,7 @@ export function main() {
|
||||
expect(templates[1].template).toEqual('a');
|
||||
async.done();
|
||||
});
|
||||
xhr.flush();
|
||||
resourceLoader.flush();
|
||||
}));
|
||||
|
||||
});
|
||||
@ -426,7 +434,7 @@ export function main() {
|
||||
});
|
||||
}
|
||||
|
||||
function programXhrSpy(spy: SpyXHR, results: {[key: string]: string}) {
|
||||
function programResourceLoaderSpy(spy: SpyResourceLoader, results: {[key: string]: string}) {
|
||||
spy.spy('get').andCallFake((url: string): Promise<any> => {
|
||||
var result = results[url];
|
||||
if (result) {
|
||||
|
@ -6,21 +6,21 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {DirectiveResolver, XHR, i18n} from '@angular/compiler';
|
||||
import {DirectiveResolver, ResourceLoader, i18n} from '@angular/compiler';
|
||||
import {MockDirectiveResolver} from '@angular/compiler/testing';
|
||||
import {Compiler, Component, DebugElement, Injector, TRANSLATIONS, TRANSLATIONS_FORMAT} from '@angular/core';
|
||||
import {TestBed, fakeAsync} from '@angular/core/testing';
|
||||
import {beforeEach, TestComponentBuilder, ddescribe, describe, iit, inject, it, xdescribe, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||
import {SpyXHR} from '../spies';
|
||||
import {SpyResourceLoader} from '../spies';
|
||||
import {NgLocalization} from '@angular/common';
|
||||
import {stringifyElement} from '@angular/platform-browser/testing/browser_util';
|
||||
|
||||
export function main() {
|
||||
describe('i18n integration spec', () => {
|
||||
let compiler: Compiler;
|
||||
let xhr: SpyXHR;
|
||||
let xhr: SpyResourceLoader;
|
||||
let tcb: TestComponentBuilder;
|
||||
let dirResolver: MockDirectiveResolver;
|
||||
let injector: Injector;
|
||||
@ -28,7 +28,7 @@ export function main() {
|
||||
beforeEach(() => {
|
||||
TestBed.configureCompiler({
|
||||
providers: [
|
||||
{provide: XHR, useClass: SpyXHR},
|
||||
{provide: ResourceLoader, useClass: SpyResourceLoader},
|
||||
{provide: NgLocalization, useClass: FrLocalization},
|
||||
{provide: TRANSLATIONS, useValue: XTB},
|
||||
{provide: TRANSLATIONS_FORMAT, useValue: 'xtb'},
|
||||
@ -37,8 +37,8 @@ export function main() {
|
||||
});
|
||||
|
||||
beforeEach(fakeAsync(inject(
|
||||
[Compiler, TestComponentBuilder, XHR, DirectiveResolver, Injector],
|
||||
(_compiler: Compiler, _tcb: TestComponentBuilder, _xhr: SpyXHR,
|
||||
[Compiler, TestComponentBuilder, ResourceLoader, DirectiveResolver, Injector],
|
||||
(_compiler: Compiler, _tcb: TestComponentBuilder, _xhr: SpyResourceLoader,
|
||||
_dirResolver: MockDirectiveResolver, _injector: Injector) => {
|
||||
compiler = _compiler;
|
||||
tcb = _tcb;
|
||||
|
@ -6,15 +6,15 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {MockXHR} from '@angular/compiler/testing/xhr_mock';
|
||||
import {MockResourceLoader} from '@angular/compiler/testing/resource_loader_mock';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it} from '@angular/core/testing/testing_internal';
|
||||
import {isPresent} from '../src/facade/lang';
|
||||
|
||||
export function main() {
|
||||
describe('MockXHR', () => {
|
||||
var xhr: MockXHR;
|
||||
describe('MockResourceLoader', () => {
|
||||
var resourceLoader: MockResourceLoader;
|
||||
|
||||
beforeEach(() => { xhr = new MockXHR(); });
|
||||
beforeEach(() => { resourceLoader = new MockResourceLoader(); });
|
||||
|
||||
function expectResponse(
|
||||
request: Promise<string>, url: string, response: string, done: () => void = null) {
|
||||
@ -45,70 +45,71 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var url = '/foo';
|
||||
var response = 'bar';
|
||||
xhr.when(url, response);
|
||||
expectResponse(xhr.get(url), url, response, () => async.done());
|
||||
xhr.flush();
|
||||
resourceLoader.when(url, response);
|
||||
expectResponse(resourceLoader.get(url), url, response, () => async.done());
|
||||
resourceLoader.flush();
|
||||
}));
|
||||
|
||||
it('should return an error from the definitions',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var url = '/foo';
|
||||
var response: any /** TODO #9100 */ = null;
|
||||
xhr.when(url, response);
|
||||
expectResponse(xhr.get(url), url, response, () => async.done());
|
||||
xhr.flush();
|
||||
resourceLoader.when(url, response);
|
||||
expectResponse(resourceLoader.get(url), url, response, () => async.done());
|
||||
resourceLoader.flush();
|
||||
}));
|
||||
|
||||
it('should return a response from the expectations',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var url = '/foo';
|
||||
var response = 'bar';
|
||||
xhr.expect(url, response);
|
||||
expectResponse(xhr.get(url), url, response, () => async.done());
|
||||
xhr.flush();
|
||||
resourceLoader.expect(url, response);
|
||||
expectResponse(resourceLoader.get(url), url, response, () => async.done());
|
||||
resourceLoader.flush();
|
||||
}));
|
||||
|
||||
it('should return an error from the expectations',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var url = '/foo';
|
||||
var response: any /** TODO #9100 */ = null;
|
||||
xhr.expect(url, response);
|
||||
expectResponse(xhr.get(url), url, response, () => async.done());
|
||||
xhr.flush();
|
||||
resourceLoader.expect(url, response);
|
||||
expectResponse(resourceLoader.get(url), url, response, () => async.done());
|
||||
resourceLoader.flush();
|
||||
}));
|
||||
|
||||
it('should not reuse expectations', () => {
|
||||
var url = '/foo';
|
||||
var response = 'bar';
|
||||
xhr.expect(url, response);
|
||||
xhr.get(url);
|
||||
xhr.get(url);
|
||||
expect(() => { xhr.flush(); }).toThrowError('Unexpected request /foo');
|
||||
resourceLoader.expect(url, response);
|
||||
resourceLoader.get(url);
|
||||
resourceLoader.get(url);
|
||||
expect(() => { resourceLoader.flush(); }).toThrowError('Unexpected request /foo');
|
||||
});
|
||||
|
||||
it('should return expectations before definitions',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var url = '/foo';
|
||||
xhr.when(url, 'when');
|
||||
xhr.expect(url, 'expect');
|
||||
expectResponse(xhr.get(url), url, 'expect');
|
||||
expectResponse(xhr.get(url), url, 'when', () => async.done());
|
||||
xhr.flush();
|
||||
resourceLoader.when(url, 'when');
|
||||
resourceLoader.expect(url, 'expect');
|
||||
expectResponse(resourceLoader.get(url), url, 'expect');
|
||||
expectResponse(resourceLoader.get(url), url, 'when', () => async.done());
|
||||
resourceLoader.flush();
|
||||
}));
|
||||
|
||||
it('should throw when there is no definitions or expectations', () => {
|
||||
xhr.get('/foo');
|
||||
expect(() => { xhr.flush(); }).toThrowError('Unexpected request /foo');
|
||||
resourceLoader.get('/foo');
|
||||
expect(() => { resourceLoader.flush(); }).toThrowError('Unexpected request /foo');
|
||||
});
|
||||
|
||||
it('should throw when flush is called without any pending requests',
|
||||
() => { expect(() => { xhr.flush(); }).toThrowError('No pending requests to flush'); });
|
||||
it('should throw when flush is called without any pending requests', () => {
|
||||
expect(() => { resourceLoader.flush(); }).toThrowError('No pending requests to flush');
|
||||
});
|
||||
|
||||
it('should throw on unsatisfied expectations', () => {
|
||||
xhr.expect('/foo', 'bar');
|
||||
xhr.when('/bar', 'foo');
|
||||
xhr.get('/bar');
|
||||
expect(() => { xhr.flush(); }).toThrowError('Unsatisfied requests: /foo');
|
||||
resourceLoader.expect('/foo', 'bar');
|
||||
resourceLoader.when('/bar', 'foo');
|
||||
resourceLoader.get('/bar');
|
||||
expect(() => { resourceLoader.flush(); }).toThrowError('Unsatisfied requests: /foo');
|
||||
});
|
||||
});
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {DirectiveResolver, XHR} from '@angular/compiler';
|
||||
import {DirectiveResolver, ResourceLoader} from '@angular/compiler';
|
||||
import {MockDirectiveResolver} from '@angular/compiler/testing';
|
||||
import {Compiler, Component, ComponentFactory, Injectable, Injector, Input, NgModule, NgModuleFactory, Type} from '@angular/core';
|
||||
import {ComponentFixture, TestBed, fakeAsync, tick} from '@angular/core/testing';
|
||||
@ -16,7 +16,7 @@ import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
import {ViewMetadata} from '../core_private';
|
||||
import {stringify} from '../src/facade/lang';
|
||||
|
||||
import {SpyXHR} from './spies';
|
||||
import {SpyResourceLoader} from './spies';
|
||||
|
||||
@Component({selector: 'child-cmp', template: 'childComp'})
|
||||
class ChildComp {
|
||||
@ -33,21 +33,23 @@ class SomeCompWithUrlTemplate {
|
||||
export function main() {
|
||||
describe('RuntimeCompiler', () => {
|
||||
let compiler: Compiler;
|
||||
let xhr: SpyXHR;
|
||||
let resourceLoader: SpyResourceLoader;
|
||||
let tcb: TestComponentBuilder;
|
||||
let dirResolver: MockDirectiveResolver;
|
||||
let injector: Injector;
|
||||
|
||||
beforeEach(
|
||||
() => { TestBed.configureCompiler({providers: [{provide: XHR, useClass: SpyXHR}]}); });
|
||||
beforeEach(() => {
|
||||
TestBed.configureCompiler(
|
||||
{providers: [{provide: ResourceLoader, useClass: SpyResourceLoader}]});
|
||||
});
|
||||
|
||||
beforeEach(fakeAsync(inject(
|
||||
[Compiler, TestComponentBuilder, XHR, DirectiveResolver, Injector],
|
||||
(_compiler: Compiler, _tcb: TestComponentBuilder, _xhr: SpyXHR,
|
||||
[Compiler, TestComponentBuilder, ResourceLoader, DirectiveResolver, Injector],
|
||||
(_compiler: Compiler, _tcb: TestComponentBuilder, _resourceLoader: SpyResourceLoader,
|
||||
_dirResolver: MockDirectiveResolver, _injector: Injector) => {
|
||||
compiler = _compiler;
|
||||
tcb = _tcb;
|
||||
xhr = _xhr;
|
||||
resourceLoader = _resourceLoader;
|
||||
dirResolver = _dirResolver;
|
||||
injector = _injector;
|
||||
})));
|
||||
@ -55,13 +57,13 @@ export function main() {
|
||||
describe('clearCacheFor', () => {
|
||||
it('should support changing the content of a template referenced via templateUrl',
|
||||
fakeAsync(() => {
|
||||
xhr.spy('get').andCallFake(() => Promise.resolve('init'));
|
||||
resourceLoader.spy('get').andCallFake(() => Promise.resolve('init'));
|
||||
let compFixture =
|
||||
tcb.overrideView(SomeComp, new ViewMetadata({templateUrl: '/myComp.html'}))
|
||||
.createFakeAsync(SomeComp);
|
||||
expect(compFixture.nativeElement).toHaveText('init');
|
||||
|
||||
xhr.spy('get').andCallFake(() => Promise.resolve('new content'));
|
||||
resourceLoader.spy('get').andCallFake(() => Promise.resolve('new content'));
|
||||
// Note: overrideView is calling .clearCacheFor...
|
||||
compFixture = tcb.overrideView(SomeComp, new ViewMetadata({templateUrl: '/myComp.html'}))
|
||||
.createFakeAsync(SomeComp);
|
||||
@ -91,7 +93,7 @@ export function main() {
|
||||
|
||||
describe('compileComponentSync', () => {
|
||||
it('should throw when using a templateUrl that has not been compiled before', () => {
|
||||
xhr.spy('get').andCallFake(() => Promise.resolve(''));
|
||||
resourceLoader.spy('get').andCallFake(() => Promise.resolve(''));
|
||||
expect(() => tcb.createSync(SomeCompWithUrlTemplate))
|
||||
.toThrowError(
|
||||
`Can't compile synchronously as ${stringify(SomeCompWithUrlTemplate)} is still being loaded!`);
|
||||
@ -99,7 +101,7 @@ export function main() {
|
||||
|
||||
it('should throw when using a templateUrl in a nested component that has not been compiled before',
|
||||
() => {
|
||||
xhr.spy('get').andCallFake(() => Promise.resolve(''));
|
||||
resourceLoader.spy('get').andCallFake(() => Promise.resolve(''));
|
||||
let localTcb =
|
||||
tcb.overrideView(SomeComp, new ViewMetadata({template: '', directives: [ChildComp]}))
|
||||
.overrideView(ChildComp, new ViewMetadata({templateUrl: '/someTpl.html'}));
|
||||
@ -110,7 +112,7 @@ export function main() {
|
||||
|
||||
it('should allow to use templateUrl components that have been loaded before',
|
||||
fakeAsync(() => {
|
||||
xhr.spy('get').andCallFake(() => Promise.resolve('hello'));
|
||||
resourceLoader.spy('get').andCallFake(() => Promise.resolve('hello'));
|
||||
tcb.createFakeAsync(SomeCompWithUrlTemplate);
|
||||
let compFixture = tcb.createSync(SomeCompWithUrlTemplate);
|
||||
expect(compFixture.nativeElement).toHaveText('hello');
|
||||
@ -126,7 +128,7 @@ export function main() {
|
||||
class SomeModule {
|
||||
}
|
||||
|
||||
xhr.spy('get').andCallFake(() => Promise.resolve('hello'));
|
||||
resourceLoader.spy('get').andCallFake(() => Promise.resolve('hello'));
|
||||
let ngModuleFactory: NgModuleFactory<any>;
|
||||
compiler.compileModuleAsync(SomeModule).then((f) => ngModuleFactory = f);
|
||||
tick();
|
||||
@ -141,7 +143,7 @@ export function main() {
|
||||
class SomeModule {
|
||||
}
|
||||
|
||||
xhr.spy('get').andCallFake(() => Promise.resolve(''));
|
||||
resourceLoader.spy('get').andCallFake(() => Promise.resolve(''));
|
||||
expect(() => compiler.compileModuleSync(SomeModule))
|
||||
.toThrowError(
|
||||
`Can't compile synchronously as ${stringify(SomeCompWithUrlTemplate)} is still being loaded!`);
|
||||
@ -153,7 +155,7 @@ export function main() {
|
||||
class SomeModule {
|
||||
}
|
||||
|
||||
xhr.spy('get').andCallFake(() => Promise.resolve(''));
|
||||
resourceLoader.spy('get').andCallFake(() => Promise.resolve(''));
|
||||
dirResolver.setView(SomeComp, new ViewMetadata({template: '', directives: [ChildComp]}));
|
||||
dirResolver.setView(ChildComp, new ViewMetadata({templateUrl: '/someTpl.html'}));
|
||||
expect(() => compiler.compileModuleSync(SomeModule))
|
||||
@ -170,7 +172,7 @@ export function main() {
|
||||
class SomeModule {
|
||||
}
|
||||
|
||||
xhr.spy('get').andCallFake(() => Promise.resolve('hello'));
|
||||
resourceLoader.spy('get').andCallFake(() => Promise.resolve('hello'));
|
||||
compiler.compileModuleAsync(SomeModule);
|
||||
tick();
|
||||
|
||||
|
@ -6,10 +6,10 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {XHR} from '@angular/compiler/src/xhr';
|
||||
import {ResourceLoader} from '@angular/compiler/src/resource_loader';
|
||||
|
||||
import {SpyObject, proxy} from '@angular/core/testing/testing_internal';
|
||||
|
||||
export class SpyXHR extends SpyObject {
|
||||
constructor() { super(XHR); }
|
||||
export class SpyResourceLoader extends SpyObject {
|
||||
constructor() { super(ResourceLoader); }
|
||||
}
|
||||
|
@ -6,13 +6,13 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ElementSchemaRegistry, UrlResolver, XHR} from '@angular/compiler';
|
||||
import {ElementSchemaRegistry, ResourceLoader, UrlResolver} from '@angular/compiler';
|
||||
import {createUrlResolverWithoutPackagePrefix} from '@angular/compiler/src/url_resolver';
|
||||
import {MockSchemaRegistry} from '@angular/compiler/testing';
|
||||
import {MockXHR} from '@angular/compiler/testing/xhr_mock';
|
||||
import {MockResourceLoader} from '@angular/compiler/testing/resource_loader_mock';
|
||||
|
||||
export var TEST_COMPILER_PROVIDERS: any[] = [
|
||||
{provide: ElementSchemaRegistry, useValue: new MockSchemaRegistry({}, {})},
|
||||
{provide: XHR, useClass: MockXHR},
|
||||
{provide: ResourceLoader, useClass: MockResourceLoader},
|
||||
{provide: UrlResolver, useFactory: createUrlResolverWithoutPackagePrefix}
|
||||
];
|
||||
|
Reference in New Issue
Block a user