From 939d318242bb7ed391aad830640ff5f0a667fcf5 Mon Sep 17 00:00:00 2001 From: Hans Date: Tue, 23 Aug 2016 09:22:33 -0700 Subject: [PATCH] refactor(platform-browser-dynamic): Removed TestComponentBuilder from ResourceLoaderCache specs (#10890) --- .../resource_loader_cache_spec.ts | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/@angular/platform-browser-dynamic/test/resource_loader/resource_loader_cache_spec.ts b/modules/@angular/platform-browser-dynamic/test/resource_loader/resource_loader_cache_spec.ts index 1f195c6ef4..0f7a2b6988 100644 --- a/modules/@angular/platform-browser-dynamic/test/resource_loader/resource_loader_cache_spec.ts +++ b/modules/@angular/platform-browser-dynamic/test/resource_loader/resource_loader_cache_spec.ts @@ -9,7 +9,7 @@ import {ResourceLoader, UrlResolver} from '@angular/compiler'; import {BaseException, Component} from '@angular/core'; import {TestBed, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing'; -import {AsyncTestCompleter, TestComponentBuilder, beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {expect} from '@angular/platform-browser/testing/matchers'; import {CachedResourceLoader} from '../../src/resource_loader/resource_loader_cache'; @@ -18,33 +18,36 @@ import {setTemplateCache} from './resource_loader_cache_setter'; export function main() { describe('CachedResourceLoader', () => { - var xhr: CachedResourceLoader; + var resourceLoader: CachedResourceLoader; function createCachedResourceLoader(): CachedResourceLoader { setTemplateCache({'test.html': '
Hello
'}); return new CachedResourceLoader(); } - beforeEach(() => { + beforeEach(fakeAsync(() => { TestBed.configureCompiler({ providers: [ {provide: UrlResolver, useClass: TestUrlResolver}, {provide: ResourceLoader, useFactory: createCachedResourceLoader} ] }); - }); + + TestBed.configureTestingModule({declarations: [TestComponent]}); + TestBed.compileComponents(); + })); it('should throw exception if $templateCache is not found', () => { setTemplateCache(null); expect(() => { - xhr = new CachedResourceLoader(); + resourceLoader = new CachedResourceLoader(); }).toThrowError('CachedResourceLoader: Template cache was not found in $templateCache.'); }); it('should resolve the Promise with the cached file content on success', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { setTemplateCache({'test.html': '
Hello
'}); - xhr = new CachedResourceLoader(); - xhr.get('test.html').then((text) => { + resourceLoader = new CachedResourceLoader(); + resourceLoader.get('test.html').then((text) => { expect(text).toEqual('
Hello
'); async.done(); }); @@ -52,21 +55,18 @@ export function main() { it('should reject the Promise on failure', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { - xhr = new CachedResourceLoader(); - xhr.get('unknown.html') + resourceLoader = new CachedResourceLoader(); + resourceLoader.get('unknown.html') .then((text) => { throw new BaseException('Not expected to succeed.'); }) .catch((error) => { async.done(); }); })); it('should allow fakeAsync Tests to load components with templateUrl synchronously', - fakeAsync(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { - let fixture = tcb.createFakeAsync(TestComponent); - - // This should initialize the fixture. - tick(); - + fakeAsync(() => { + let fixture = TestBed.createComponent(TestComponent); + fixture.detectChanges(); expect(fixture.debugElement.children[0].nativeElement).toHaveText('Hello'); - }))); + })); }); }