diff --git a/packages/platform-browser-dynamic/test/resource_loader/resource_loader_cache_spec.ts b/packages/platform-browser-dynamic/test/resource_loader/resource_loader_cache_spec.ts index ead5fa17b2..f5b42e1b6e 100644 --- a/packages/platform-browser-dynamic/test/resource_loader/resource_loader_cache_spec.ts +++ b/packages/platform-browser-dynamic/test/resource_loader/resource_loader_cache_spec.ts @@ -21,17 +21,6 @@ if (isBrowser) { setTemplateCache({'test.html': '
Hello
'}); return new CachedResourceLoader(); } - beforeEach(fakeAsync(() => { - TestBed.configureCompiler({ - providers: [ - {provide: UrlResolver, useClass: TestUrlResolver, deps: []}, - {provide: ResourceLoader, useFactory: createCachedResourceLoader, deps: []} - ] - }); - - TestBed.configureTestingModule({declarations: [TestComponent]}); - TestBed.compileComponents(); - })); it('should throw exception if $templateCache is not found', () => { setTemplateCache(null); @@ -41,13 +30,12 @@ if (isBrowser) { }); it('should resolve the Promise with the cached file content on success', async(() => { - setTemplateCache({'test.html': '
Hello
'}); - resourceLoader = new CachedResourceLoader(); + resourceLoader = createCachedResourceLoader(); resourceLoader.get('test.html').then((text) => { expect(text).toBe('
Hello
'); }); })); it('should reject the Promise on failure', async(() => { - resourceLoader = new CachedResourceLoader(); + resourceLoader = createCachedResourceLoader(); resourceLoader.get('unknown.html') .then((text) => { throw new Error('Not expected to succeed.'); }) .catch((error) => {/** success */}); @@ -55,6 +43,12 @@ if (isBrowser) { it('should allow fakeAsync Tests to load components with templateUrl synchronously', fakeAsync(() => { + TestBed.configureCompiler({ + providers: [ + {provide: UrlResolver, useClass: TestUrlResolver, deps: []}, + {provide: ResourceLoader, useFactory: createCachedResourceLoader, deps: []} + ] + }); TestBed.configureTestingModule({declarations: [TestComponent]}); TestBed.compileComponents(); tick();