From 75405ae0f5dc0050784deb0689d801e159613bb1 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Tue, 16 Aug 2016 20:19:42 -0700 Subject: [PATCH] refactor(core): update forward_ref_integration_spec not to use TestComponentBuilder --- .../core/test/forward_ref_integration_spec.ts | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/modules/@angular/core/test/forward_ref_integration_spec.ts b/modules/@angular/core/test/forward_ref_integration_spec.ts index ec0971f026..97d6c36404 100644 --- a/modules/@angular/core/test/forward_ref_integration_spec.ts +++ b/modules/@angular/core/test/forward_ref_integration_spec.ts @@ -6,38 +6,43 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgFor} from '@angular/common'; -import {Component, ContentChildren, Directive, Inject, QueryList, asNativeElements, forwardRef} from '@angular/core'; -import {AsyncTestCompleter, TestComponentBuilder, beforeEach, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; +import {CommonModule} from '@angular/common'; +import {Component, ContentChildren, Directive, Inject, NgModule, QueryList, asNativeElements, forwardRef} from '@angular/core'; +import {TestBed} from '@angular/core/testing'; import {expect} from '@angular/platform-browser/testing/matchers'; export function main() { describe('forwardRef integration', function() { - it('should instantiate components which are declared using forwardRef', - inject( - [TestComponentBuilder, AsyncTestCompleter], - (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.createAsync(App).then((tc) => { - tc.detectChanges(); - expect(asNativeElements(tc.debugElement.children)).toHaveText('frame(lock)'); - async.done(); - }); - })); + beforeEach(() => { TestBed.configureTestingModule({imports: [Module], declarations: [App]}); }); + + it('should instantiate components which are declared using forwardRef', () => { + const a = TestBed.createComponent(App); + a.detectChanges(); + expect(asNativeElements(a.debugElement.children)).toHaveText('frame(lock)'); + expect(TestBed.get(ModuleFrame)).toBeDefined(); + }); }); } +@NgModule({ + imports: [CommonModule], + providers: [forwardRef(() => ModuleFrame)], + declarations: [forwardRef(() => Door), forwardRef(() => Lock)], + exports: [forwardRef(() => Door), forwardRef(() => Lock)] +}) +class Module { +} + @Component({ selector: 'app', viewProviders: [forwardRef(() => Frame)], template: ``, - directives: [forwardRef(() => Door), forwardRef(() => Lock)], }) class App { } @Component({ selector: 'lock', - directives: [NgFor], template: `{{frame.name}}({{lock.name}})`, }) class Door { @@ -51,6 +56,10 @@ class Frame { name: string = 'frame'; } +class ModuleFrame { + name: string = 'moduleFram'; +} + @Directive({selector: 'lock'}) class Lock { name: string = 'lock';