From 686457890d38fe978e4977ed443b975c2ca5c3eb Mon Sep 17 00:00:00 2001 From: Julie Ralph Date: Sat, 31 Oct 2015 09:50:19 -0700 Subject: [PATCH] chore(test): rename RootTestComponent to ComponentFixture BREAKING CHANGE: Before: ``` testComponentBuilder.createAsync(MyComponent).then(root: RootTestComponent => { } ``` After: ``` testComponentBuilder.createAsync(MyComponent).then(fixture: ComponentFixture => { } ``` Closes #4711 --- .../src/testing/test_component_builder.ts | 14 +- .../test/core/debug/debug_element_spec.ts | 54 +- .../debug/debug_element_view_listener_spec.ts | 15 +- .../test/core/directives/ng_class_spec.ts | 242 ++++---- .../test/core/directives/ng_for_spec.ts | 209 +++---- .../test/core/directives/ng_if_spec.ts | 149 ++--- .../test/core/directives/ng_style_spec.ts | 70 +-- .../test/core/directives/ng_switch_spec.ts | 90 +-- .../test/core/directives/non_bindable_spec.ts | 20 +- .../test/core/forms/integration_spec.ts | 418 +++++++------- .../linker/dynamic_component_loader_spec.ts | 6 +- .../test/core/linker/integration_spec.ts | 517 +++++++++--------- .../linker/projection_integration_spec.ts | 6 +- .../core/linker/query_integration_spec.ts | 8 +- .../test/core/pipes/json_pipe_spec.ts | 12 +- .../test/core/pipes/slice_pipe_spec.ts | 12 +- .../router/integration/lifecycle_hook_spec.ts | 66 +-- .../router/integration/navigation_spec.ts | 67 +-- .../integration/router_integration_spec.ts | 40 +- .../router/integration/router_link_spec.ts | 70 +-- .../testing/test_component_builder_spec.ts | 54 +- .../test/testing/testing_public_spec.ts | 54 +- .../worker/renderer_integration_spec.ts | 30 +- modules/angular2/testing.ts | 2 +- modules/angular2_material/test/button_spec.ts | 24 +- 25 files changed, 1128 insertions(+), 1121 deletions(-) diff --git a/modules/angular2/src/testing/test_component_builder.ts b/modules/angular2/src/testing/test_component_builder.ts index 3c2c6aac34..b37b541090 100644 --- a/modules/angular2/src/testing/test_component_builder.ts +++ b/modules/angular2/src/testing/test_component_builder.ts @@ -22,14 +22,14 @@ import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {DebugElement, DebugElement_} from 'angular2/src/core/debug/debug_element'; -export abstract class RootTestComponent { +export abstract class ComponentFixture { debugElement: DebugElement; abstract detectChanges(): void; abstract destroy(): void; } -export class RootTestComponent_ extends RootTestComponent { +export class ComponentFixture_ extends ComponentFixture { /** @internal */ _componentRef: ComponentRef; /** @internal */ @@ -53,7 +53,7 @@ export class RootTestComponent_ extends RootTestComponent { var _nextRootElementId = 0; /** - * Builds a RootTestComponent for use in component level tests. + * Builds a ComponentFixture for use in component level tests. */ @Injectable() export class TestComponentBuilder { @@ -186,11 +186,11 @@ export class TestComponentBuilder { } /** - * Builds and returns a RootTestComponent. + * Builds and returns a ComponentFixture. * - * @return {Promise} + * @return {Promise} */ - createAsync(rootComponentType: Type): Promise { + createAsync(rootComponentType: Type): Promise { var mockDirectiveResolver = this._injector.get(DirectiveResolver); var mockViewResolver = this._injector.get(ViewResolver); this._viewOverrides.forEach((view, type) => mockViewResolver.setView(type, view)); @@ -220,6 +220,6 @@ export class TestComponentBuilder { return this._injector.get(DynamicComponentLoader) .loadAsRoot(rootComponentType, `#${rootElId}`, this._injector) - .then((componentRef) => { return new RootTestComponent_(componentRef); }); + .then((componentRef) => { return new ComponentFixture_(componentRef); }); } } diff --git a/modules/angular2/test/core/debug/debug_element_spec.ts b/modules/angular2/test/core/debug/debug_element_spec.ts index cc69f725a4..e20f928fe3 100644 --- a/modules/angular2/test/core/debug/debug_element_spec.ts +++ b/modules/angular2/test/core/debug/debug_element_spec.ts @@ -137,14 +137,14 @@ export function main() { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { tcb.createAsync(ParentComp) - .then((rootTestComponent) => { - rootTestComponent.detectChanges(); + .then((componentFixture) => { + componentFixture.detectChanges(); - var childEls = rootTestComponent.debugElement.children; + var childEls = componentFixture.debugElement.children; // The root is a lone component, and has no children in the light dom. expect(childEls.length).toEqual(0); - var rootCompChildren = rootTestComponent.debugElement.componentViewChildren; + var rootCompChildren = componentFixture.debugElement.componentViewChildren; // The root component has 4 elements in its shadow view. expect(rootCompChildren.length).toEqual(4); expect(DOM.hasClass(rootCompChildren[0].nativeElement, 'parent')).toBe(true); @@ -185,10 +185,10 @@ export function main() { it('should list child elements within viewports', inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { - tcb.createAsync(UsingFor).then((rootTestComponent) => { - rootTestComponent.detectChanges(); + tcb.createAsync(UsingFor).then((componentFixture) => { + componentFixture.detectChanges(); - var childEls = rootTestComponent.debugElement.componentViewChildren; + var childEls = componentFixture.debugElement.componentViewChildren; // TODO should this count include the