From 6e2a1877ab511caac2de24344cf734a41e039931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=A1ko=20Hevery?= Date: Fri, 27 Jul 2018 13:49:22 -0700 Subject: [PATCH] refactor(core): remove withBody from public testing API (#25171) PR Close #25171 --- packages/core/test/BUILD.bazel | 1 + .../test/application_ref_integration_spec.ts | 3 ++- .../core/test/bundling/hello_world/BUILD.bazel | 1 + .../bundling/hello_world/treeshaking_spec.ts | 2 +- .../test/bundling/hello_world_r2/BUILD.bazel | 1 + .../core/test/bundling/injection/BUILD.bazel | 1 + packages/core/test/bundling/todo/BUILD.bazel | 1 + .../core/test/bundling/todo/todo_e2e_spec.ts | 2 +- packages/core/test/render3/BUILD.bazel | 1 + .../core/test/render3/change_detection_spec.ts | 2 +- .../render3/compiler_canonical/small_app_spec.ts | 2 +- packages/core/test/render3/testing_spec.ts | 2 +- packages/core/testing/src/testing.ts | 1 - packages/private/testing/BUILD.bazel | 16 ++++++++++++++++ packages/private/testing/index.ts | 9 +++++++++ .../{core => private}/testing/src/render3.ts | 0 test-main.js | 1 + tools/public_api_guard/core/testing.d.ts | 9 --------- 18 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 packages/private/testing/BUILD.bazel create mode 100644 packages/private/testing/index.ts rename packages/{core => private}/testing/src/render3.ts (100%) diff --git a/packages/core/test/BUILD.bazel b/packages/core/test/BUILD.bazel index e8cfc9708e..51c52457b1 100644 --- a/packages/core/test/BUILD.bazel +++ b/packages/core/test/BUILD.bazel @@ -27,6 +27,7 @@ ts_library( "//packages/platform-browser-dynamic", "//packages/platform-browser/animations", "//packages/platform-browser/testing", + "//packages/private/testing", "//packages/router", "//packages/router/testing", "@rxjs", diff --git a/packages/core/test/application_ref_integration_spec.ts b/packages/core/test/application_ref_integration_spec.ts index 5000f8c365..cc13822f5c 100644 --- a/packages/core/test/application_ref_integration_spec.ts +++ b/packages/core/test/application_ref_integration_spec.ts @@ -7,8 +7,9 @@ */ import {ApplicationModule, ApplicationRef, DoCheck, InjectFlags, InjectorType, Input, OnInit, PlatformRef, TestabilityRegistry, Type, defineInjector, inject, ɵE as elementStart, ɵNgModuleDef as NgModuleDef, ɵRenderFlags as RenderFlags, ɵT as text, ɵdefineComponent as defineComponent, ɵe as elementEnd, ɵi1 as interpolation1, ɵt as textBinding} from '@angular/core'; -import {getTestBed, withBody} from '@angular/core/testing'; +import {getTestBed} from '@angular/core/testing'; import {BrowserModule, EVENT_MANAGER_PLUGINS, platformBrowser} from '@angular/platform-browser'; +import {withBody} from '@angular/private/testing'; import {BROWSER_MODULE_PROVIDERS} from '../../platform-browser/src/browser'; import {APPLICATION_MODULE_PROVIDERS} from '../src/application_module'; diff --git a/packages/core/test/bundling/hello_world/BUILD.bazel b/packages/core/test/bundling/hello_world/BUILD.bazel index 5b221b3b00..00cdd93ec3 100644 --- a/packages/core/test/bundling/hello_world/BUILD.bazel +++ b/packages/core/test/bundling/hello_world/BUILD.bazel @@ -38,6 +38,7 @@ ts_library( deps = [ "//packages:types", "//packages/core/testing", + "//packages/private/testing", ], ) diff --git a/packages/core/test/bundling/hello_world/treeshaking_spec.ts b/packages/core/test/bundling/hello_world/treeshaking_spec.ts index 90b309c27b..9cd1469051 100644 --- a/packages/core/test/bundling/hello_world/treeshaking_spec.ts +++ b/packages/core/test/bundling/hello_world/treeshaking_spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {withBody} from '@angular/core/testing'; +import {withBody} from '@angular/private/testing'; import * as fs from 'fs'; import * as path from 'path'; diff --git a/packages/core/test/bundling/hello_world_r2/BUILD.bazel b/packages/core/test/bundling/hello_world_r2/BUILD.bazel index 28a561e7a0..330f823f1c 100644 --- a/packages/core/test/bundling/hello_world_r2/BUILD.bazel +++ b/packages/core/test/bundling/hello_world_r2/BUILD.bazel @@ -38,6 +38,7 @@ ts_library( deps = [ "//packages:types", "//packages/core/testing", + "//packages/private/testing", ], ) diff --git a/packages/core/test/bundling/injection/BUILD.bazel b/packages/core/test/bundling/injection/BUILD.bazel index 740816265c..39112c77ce 100644 --- a/packages/core/test/bundling/injection/BUILD.bazel +++ b/packages/core/test/bundling/injection/BUILD.bazel @@ -39,6 +39,7 @@ ts_library( ":injection", "//packages:types", "//packages/core/testing", + "//packages/private/testing", ], ) diff --git a/packages/core/test/bundling/todo/BUILD.bazel b/packages/core/test/bundling/todo/BUILD.bazel index 1945a0d006..cac0c960a1 100644 --- a/packages/core/test/bundling/todo/BUILD.bazel +++ b/packages/core/test/bundling/todo/BUILD.bazel @@ -44,6 +44,7 @@ ts_library( "//packages:types", "//packages/core", "//packages/core/testing", + "//packages/private/testing", ], ) diff --git a/packages/core/test/bundling/todo/todo_e2e_spec.ts b/packages/core/test/bundling/todo/todo_e2e_spec.ts index e80bd9a3a8..b3d2d7896e 100644 --- a/packages/core/test/bundling/todo/todo_e2e_spec.ts +++ b/packages/core/test/bundling/todo/todo_e2e_spec.ts @@ -7,7 +7,7 @@ */ import {ɵwhenRendered as whenRendered} from '@angular/core'; -import {withBody} from '@angular/core/testing'; +import {withBody} from '@angular/private/testing'; import * as fs from 'fs'; import * as path from 'path'; diff --git a/packages/core/test/render3/BUILD.bazel b/packages/core/test/render3/BUILD.bazel index 52546212b3..d3e85704dd 100644 --- a/packages/core/test/render3/BUILD.bazel +++ b/packages/core/test/render3/BUILD.bazel @@ -27,6 +27,7 @@ ts_library( "//packages/platform-browser", "//packages/platform-browser/animations", "//packages/platform-browser/testing", + "//packages/private/testing", ], ) diff --git a/packages/core/test/render3/change_detection_spec.ts b/packages/core/test/render3/change_detection_spec.ts index b7dd85aba0..1a9f2b3d1c 100644 --- a/packages/core/test/render3/change_detection_spec.ts +++ b/packages/core/test/render3/change_detection_spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {withBody} from '@angular/core/testing'; +import {withBody} from '@angular/private/testing'; import {ChangeDetectionStrategy, ChangeDetectorRef, DoCheck} from '../../src/core'; import {getRenderedText, whenRendered} from '../../src/render3/component'; diff --git a/packages/core/test/render3/compiler_canonical/small_app_spec.ts b/packages/core/test/render3/compiler_canonical/small_app_spec.ts index afc631d7c9..04f45904c7 100644 --- a/packages/core/test/render3/compiler_canonical/small_app_spec.ts +++ b/packages/core/test/render3/compiler_canonical/small_app_spec.ts @@ -8,7 +8,7 @@ import {NgForOf, NgForOfContext} from '@angular/common'; import {Component, ContentChild, Directive, EventEmitter, Injectable, Input, NgModule, OnDestroy, Optional, Output, Pipe, PipeTransform, QueryList, SimpleChanges, TemplateRef, Type, ViewChild, ViewContainerRef, defineInjectable, defineInjector} from '@angular/core'; -import {withBody} from '@angular/core/testing'; +import {withBody} from '@angular/private/testing'; import * as r3 from '../../../src/render3/index'; diff --git a/packages/core/test/render3/testing_spec.ts b/packages/core/test/render3/testing_spec.ts index 28e6af9cde..8505340203 100644 --- a/packages/core/test/render3/testing_spec.ts +++ b/packages/core/test/render3/testing_spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {withBody} from '@angular/core/testing'; +import {withBody} from '@angular/private/testing'; describe('testing', () => { describe('withBody', () => { diff --git a/packages/core/testing/src/testing.ts b/packages/core/testing/src/testing.ts index d2d9476c80..9051a017e2 100644 --- a/packages/core/testing/src/testing.ts +++ b/packages/core/testing/src/testing.ts @@ -19,4 +19,3 @@ export * from './test_bed'; export * from './before_each'; export * from './metadata_override'; export * from './private_export_testing'; -export * from './render3'; diff --git a/packages/private/testing/BUILD.bazel b/packages/private/testing/BUILD.bazel new file mode 100644 index 0000000000..6383269e2d --- /dev/null +++ b/packages/private/testing/BUILD.bazel @@ -0,0 +1,16 @@ +package(default_visibility = ["//visibility:public"]) + +exports_files(["package.json"]) + +load("//tools:defaults.bzl", "ng_module") + +ng_module( + name = "testing", + srcs = glob( + ["**/*.ts"], + ), + module_name = "@angular/private/testing", + deps = [ + "//packages/core", + ], +) diff --git a/packages/private/testing/index.ts b/packages/private/testing/index.ts new file mode 100644 index 0000000000..c13a1acc3b --- /dev/null +++ b/packages/private/testing/index.ts @@ -0,0 +1,9 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +export * from './src/render3'; diff --git a/packages/core/testing/src/render3.ts b/packages/private/testing/src/render3.ts similarity index 100% rename from packages/core/testing/src/render3.ts rename to packages/private/testing/src/render3.ts diff --git a/test-main.js b/test-main.js index 17d922ea09..9514ddd330 100644 --- a/test-main.js +++ b/test-main.js @@ -62,6 +62,7 @@ System.config({ '@angular/platform-server': {main: 'index.js', defaultExtension: 'js'}, '@angular/platform-webworker': {main: 'index.js', defaultExtension: 'js'}, '@angular/platform-webworker-dynamic': {main: 'index.js', defaultExtension: 'js'}, + '@angular/private/testing': {main: 'index.js', defaultExtension: 'js'}, '@angular/elements': {main: 'index.js', defaultExtension: 'js'}, 'rxjs/ajax': {main: 'index.js', defaultExtension: 'js'}, 'rxjs/operators': {main: 'index.js', defaultExtension: 'js'}, diff --git a/tools/public_api_guard/core/testing.d.ts b/tools/public_api_guard/core/testing.d.ts index 391d63920f..e91c3737b7 100644 --- a/tools/public_api_guard/core/testing.d.ts +++ b/tools/public_api_guard/core/testing.d.ts @@ -1,8 +1,5 @@ export declare function async(fn: Function): (done: any) => any; -/** @experimental */ -export declare function cleanupDocument(): void; - export declare class ComponentFixture { changeDetectorRef: ChangeDetectorRef; componentInstance: T; @@ -30,9 +27,6 @@ export declare const ComponentFixtureNoNgZone: InjectionToken; /** @experimental */ export declare function discardPeriodicTasks(): void; -/** @experimental */ -export declare function ensureDocument(): void; - /** @experimental */ export declare function fakeAsync(fn: Function): (...args: any[]) => any; @@ -147,9 +141,6 @@ export declare type TestModuleMetadata = { /** @experimental */ export declare function tick(millis?: number): void; -/** @experimental */ -export declare function withBody(html: string, blockFn: T): T; - /** @experimental */ export declare function withModule(moduleDef: TestModuleMetadata): InjectSetupWrapper; export declare function withModule(moduleDef: TestModuleMetadata, fn: Function): () => any;