fix(platform-browser/testing): clean up public api for platform-browser/testing (#9519)

Mostly, removing things that were never intended to be exported publicy.

BREAKING CHANGE:

The following are no longer publicly exported APIs. They were intended as internal
utilities and you should use your own util:

```
browserDetection,
dispatchEvent,
el,
normalizeCSS,
stringifyElement,
expect (and custom matchers for Jasmine)
```
This commit is contained in:
Julie Ralph 2016-06-23 16:42:25 -07:00 committed by GitHub
parent 894747c34c
commit 3d8eb8cbca
32 changed files with 32 additions and 79 deletions

View File

@ -7,7 +7,6 @@
*/
import {beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {expect} from '@angular/platform-browser/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder, ComponentFixture} from '@angular/compiler/testing';
@ -16,6 +15,7 @@ import {IS_DART} from '../../src/facade/lang';
import {Component, TemplateRef, ContentChild} from '@angular/core';
import {NgFor} from '@angular/common';
import {NgIf} from '@angular/common';
import {expect} from '@angular/platform-browser/testing/matchers';
import {By} from '@angular/platform-browser/src/dom/debug/by';
export function main() {

View File

@ -7,10 +7,9 @@
*/
import {beforeEach, ddescribe, describe, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {expect} from '@angular/platform-browser/testing';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {expect} from '@angular/platform-browser/testing/matchers';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {Component} from '@angular/core';

View File

@ -17,7 +17,7 @@ import {afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {By} from '@angular/platform-browser/src/dom/debug/by';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {dispatchEvent} from '@angular/platform-browser/testing';
import {dispatchEvent} from '@angular/platform-browser/testing/browser_util';
import {ObservableWrapper, TimerWrapper} from '../../src/facade/async';
import {ListWrapper} from '../../src/facade/collection';

View File

@ -15,7 +15,7 @@ import {WrappedValue} from '@angular/core';
import {EventEmitter, ObservableWrapper, PromiseWrapper, TimerWrapper} from '../../src/facade/async';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {PromiseCompleter} from '../../src/facade/promise';
import {browserDetection} from '@angular/platform-browser/testing';
import {browserDetection} from '@angular/platform-browser/testing/browser_util';
export function main() {
describe('AsyncPipe', () => {

View File

@ -9,7 +9,7 @@
import {DatePipe} from '@angular/common';
import {PipeResolver} from '@angular/compiler/src/pipe_resolver';
import {afterEach, beforeEach, ddescribe, describe, expect, iit, it, xit} from '@angular/core/testing/testing_internal';
import {browserDetection} from '@angular/platform-browser/testing';
import {browserDetection} from '@angular/platform-browser/testing/browser_util';
import {DateWrapper} from '../../src/facade/lang';

View File

@ -7,7 +7,7 @@
*/
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach,} from '@angular/core/testing/testing_internal';
import {browserDetection} from '@angular/platform-browser/testing';
import {browserDetection} from '@angular/platform-browser/testing/browser_util';
import {DecimalPipe, PercentPipe, CurrencyPipe} from '@angular/common';

View File

@ -8,7 +8,7 @@
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
import {} from '@angular/core/testing/testing_internal';
import {browserDetection} from '@angular/platform-browser/testing';
import {browserDetection} from '@angular/platform-browser/testing/browser_util';
import {TestComponentBuilder, ComponentFixture} from '@angular/compiler/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';

View File

@ -19,7 +19,7 @@ import {EventEmitter} from '@angular/core';
import {ViewType} from '@angular/core/src/linker/view_type';
import {BaseException} from '@angular/core';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {browserDetection} from '@angular/platform-browser/testing'
import {browserDetection} from '@angular/platform-browser/testing/browser_util'
export function main() {
var outputDefs: any[] /** TODO #9100 */ = []; outputDefs.push({

View File

@ -10,7 +10,7 @@ import {HtmlElementAst} from '@angular/compiler/src/html_ast';
import {HtmlParser} from '@angular/compiler/src/html_parser';
import {DomElementSchemaRegistry} from '@angular/compiler/src/schema/dom_element_schema_registry';
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {browserDetection} from '@angular/platform-browser/testing';
import {browserDetection} from '@angular/platform-browser/testing/browser_util';
import {SecurityContext} from '../../core_private';

View File

@ -10,7 +10,7 @@ import {SelectorMatcher} from '@angular/compiler/src/selector';
import {CssSelector} from '@angular/compiler/src/selector';
import {beforeEach, ddescribe, describe, expect, iit, it, xit} from '@angular/core/testing';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {el} from '@angular/platform-browser/testing';
import {el} from '@angular/platform-browser/testing/browser_util';
export function main() {
describe('SelectorMatcher', () => {

View File

@ -10,7 +10,7 @@ import {describe, beforeEach, it, expect, ddescribe, iit,} from '@angular/core/t
import {ShadowCss, processRules, CssRule} from '@angular/compiler/src/shadow_css';
import {RegExpWrapper, StringWrapper, isPresent} from '../src/facade/lang';
import {normalizeCSS} from '@angular/platform-browser/testing';
import {normalizeCSS} from '@angular/platform-browser/testing/browser_util';
export function main() {
describe('ShadowCss', function() {

View File

@ -14,7 +14,7 @@ import {NgIf} from '@angular/common';
import {TimerWrapper} from '../src/facade/async';
import {IS_DART} from '../src/facade/lang';
import {PromiseWrapper} from '../src/facade/promise';
import {dispatchEvent} from '@angular/platform-browser/testing';
import {dispatchEvent} from '@angular/platform-browser/testing/browser_util';
import {withProviders} from '@angular/core/testing/test_injector';
@Component(

View File

@ -7,7 +7,7 @@
*/
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {el} from '@angular/platform-browser/testing';
import {el} from '@angular/platform-browser/testing/browser_util';
import {ActiveAnimationPlayersMap} from '../../src/animation/active_animation_players_map';
import {isPresent} from '../../src/facade/lang';

View File

@ -6,17 +6,11 @@
* found in the LICENSE file at https://angular.io/license
*/
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {el} from '@angular/platform-browser/testing';
import {FILL_STYLE_FLAG} from '../../src/animation/animation_constants';
import {AnimationKeyframe} from '../../src/animation/animation_keyframe';
import * as animationUtils from '../../src/animation/animation_style_util';
import {AnimationStyles} from '../../src/animation/animation_styles';
import {AUTO_STYLE} from '../../src/animation/metadata';
import {isPresent} from '../../src/facade/lang';
import {fakeAsync, flushMicrotasks} from '../../testing';
import {MockAnimationPlayer} from '../../testing/animation/mock_animation_player';
import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '../../testing/testing_internal';
export function main() {

View File

@ -9,7 +9,7 @@
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit, beforeEachProviders,} from '@angular/core/testing/testing_internal';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {el, stringifyElement} from '@angular/platform-browser/testing';
import {el, stringifyElement} from '@angular/platform-browser/testing/browser_util';
export function main() {
describe('dom adapter', () => {

View File

@ -18,7 +18,7 @@ import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {BaseException} from '../../src/facade/exceptions';
import {PromiseWrapper} from '../../src/facade/promise';
import {el} from '@angular/platform-browser/testing';
import {el} from '@angular/platform-browser/testing/browser_util';
export function main() {
describe('DynamicComponentLoader', function() {

View File

@ -36,7 +36,7 @@ import {TemplateRef, TemplateRef_} from '@angular/core/src/linker/template_ref';
import {Renderer} from '@angular/core/src/render';
import {IS_DART} from '../../src/facade/lang';
import {el, dispatchEvent} from '@angular/platform-browser/testing';
import {el, dispatchEvent} from '@angular/platform-browser/testing/browser_util';
const ANCHOR_ELEMENT = /*@ts2dart_const*/ new OpaqueToken('AnchorElement');

View File

@ -13,7 +13,7 @@ import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {OpaqueToken, ViewMetadata, Component, Directive, AfterContentInit, AfterViewInit, QueryList, ContentChildren, ViewChildren, Input} from '@angular/core';
import {NgIf} from '@angular/common';
import {CompilerConfig} from '@angular/compiler';
import {el} from '@angular/platform-browser/testing';
import {el} from '@angular/platform-browser/testing/browser_util';
const ANCHOR_ELEMENT = new OpaqueToken('AnchorElement');
@ -216,4 +216,4 @@ class Simple {
})
class MyComp {
ctxBoolProp: boolean = false;
}
}

View File

@ -14,7 +14,7 @@ import {provide, Injectable, OpaqueToken} from '@angular/core';
import {CompilerConfig} from '@angular/compiler';
import {Component, ViewMetadata} from '@angular/core/src/metadata';
import {IS_DART} from '../../src/facade/lang';
import {el} from '@angular/platform-browser/testing';
import {el} from '@angular/platform-browser/testing/browser_util';
import {DomSanitizationService} from '@angular/platform-browser';
@ -240,4 +240,4 @@ function declareTests({useJit}: {useJit: boolean}) {
});
});
});
}
}

View File

@ -12,7 +12,7 @@ import {Reflector, ReflectionInfo} from '@angular/core/src/reflection/reflection
import {ReflectionCapabilities} from '@angular/core/src/reflection/reflection_capabilities';
import {ClassDecorator, ParamDecorator, PropDecorator, classDecorator, paramDecorator, propDecorator, HasGetterAndSetterDecorators} from './reflector_common';
import {IS_DART} from '../../src/facade/lang';
import {browserDetection} from '@angular/platform-browser/testing'
import {browserDetection} from '@angular/platform-browser/testing/browser_util'
class AType {
value: any /** TODO #9100 */;

View File

@ -14,7 +14,7 @@ import {BaseException} from '../../src/facade/exceptions';
import {IS_DART, scheduleMicroTask, isPresent} from '../../src/facade/lang';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {NgZone, NgZoneError} from '@angular/core/src/zone/ng_zone';
import {browserDetection} from '@angular/platform-browser/testing';
import {browserDetection} from '@angular/platform-browser/testing/browser_util';
var needsLongerTimers = browserDetection.isSlow || browserDetection.isEdge;
var resultTimer = 1000;

View File

@ -8,7 +8,7 @@
import {describe, it, expect, beforeEach, ddescribe, iit, xit, inject,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {browserDetection} from '@angular/platform-browser/testing';
import {browserDetection} from '@angular/platform-browser/testing/browser_util';
import {ObservableWrapper, Observable, Subject, EventEmitter, PromiseWrapper} from '../src/async';
export function main() {

View File

@ -17,7 +17,7 @@ import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {ControlValueAccessor, FORM_DIRECTIVES, FORM_PROVIDERS, FormControl, FormGroup, NG_ASYNC_VALIDATORS, NG_VALIDATORS, NgControl, NgForm, NgModel, REACTIVE_FORM_DIRECTIVES, Validator, Validators, disableDeprecatedForms, provideForms} from '@angular/forms';
import {By} from '@angular/platform-browser/src/dom/debug/by';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {dispatchEvent} from '@angular/platform-browser/testing';
import {dispatchEvent} from '@angular/platform-browser/testing/browser_util';
import {ObservableWrapper, TimerWrapper} from '../src/facade/async';
import {ListWrapper} from '../src/facade/collection';

View File

@ -10,10 +10,10 @@ import {UrlResolver, XHR} from '@angular/compiler';
import {Component, provide} from '@angular/core';
import {beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {expect} from '@angular/platform-browser/testing';
import {fakeAsync, flushMicrotasks, Log, tick,} from '@angular/core/testing';
import {TestComponentBuilder, ComponentFixture} from '@angular/compiler/testing';
import {expect} from '@angular/platform-browser/testing/matchers';
import {BaseException} from '../../src/facade/exceptions';
import {CachedXHR} from '../../src/xhr/xhr_cache';
import {setTemplateCache} from './xhr_cache_setter';

View File

@ -9,7 +9,6 @@
import {TestComponentRenderer} from '@angular/compiler/testing';
import {Inject, Injectable} from '@angular/core';
import {DOCUMENT} from '@angular/platform-browser';
import {el} from '@angular/platform-browser/testing';
import {getDOM} from '../platform_browser_private';
@ -23,7 +22,8 @@ export class DOMTestComponentRenderer extends TestComponentRenderer {
constructor(@Inject(DOCUMENT) private _doc: any /** TODO #9100 */) { super(); }
insertRootElement(rootElId: string) {
let rootEl = el(`<div id="${rootElId}"></div>`);
let rootEl = <HTMLElement>getDOM().firstChild(
getDOM().content(getDOM().createTemplate(`<div id="${rootElId}"></div>`)));
// TODO(juliemr): can/should this be optional?
let oldRoots = getDOM().querySelectorAll(this._doc, '[id^=root]');

View File

@ -7,7 +7,7 @@
*/
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {el} from '@angular/platform-browser/testing';
import {el} from '@angular/platform-browser/testing/browser_util';
import {AnimationKeyframe, AnimationStyles} from '../../core_private';
import {DomAnimatePlayer} from '../../src/dom/dom_animate_player';

View File

@ -7,7 +7,7 @@
*/
import * as t from '@angular/core/testing/testing_internal';
import {browserDetection} from '@angular/platform-browser/testing';
import {browserDetection} from '@angular/platform-browser/testing/browser_util';
import {getDOM} from '../../src/dom/dom_adapter';
import {sanitizeHtml} from '../../src/security/html_sanitizer';

View File

@ -7,7 +7,7 @@
*/
import {inject, describe, it, iit, expect, beforeEach, beforeEachProviders,} from '@angular/core/testing/testing_internal';
import {browserDetection} from '@angular/platform-browser/testing';
import {browserDetection} from '@angular/platform-browser/testing/browser_util';
import {createPairedMessageBuses} from './web_worker_test_util';
import {Serializer, PRIMITIVE} from '@angular/platform-browser/src/web_workers/shared/serializer';
import {ServiceMessageBroker, ServiceMessageBroker_} from '@angular/platform-browser/src/web_workers/shared/service_message_broker';

View File

@ -6,6 +6,4 @@
* found in the LICENSE file at https://angular.io/license
*/
export * from './testing/browser_util';
export * from './testing/matchers';
export * from './testing/browser';

View File

@ -10,7 +10,6 @@ import {MockLocationStrategy} from '@angular/common/testing';
import {COMPILER_PROVIDERS, DirectiveResolver, ViewResolver, XHR} from '@angular/compiler';
import {MockDirectiveResolver, MockViewResolver, TestComponentBuilder, TestComponentRenderer} from '@angular/compiler/testing';
import {APPLICATION_COMMON_PROVIDERS, APP_ID, NgZone, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, RootRenderer} from '@angular/core';
import {BrowserDetection} from '@angular/platform-browser/testing';
import {AnimationDriver, NoOpAnimationDriver} from '../core_private';
import {DOMTestComponentRenderer} from '../platform_browser_dynamic_testing_private';
@ -23,7 +22,6 @@ import {Log} from '@angular/core/testing';
function initServerTests() {
Parse5DomAdapter.makeCurrent();
BrowserDetection.setup();
}
/**

View File

@ -5,7 +5,8 @@ import {SpyLocation} from '@angular/common/testing';
import {ComponentFixture, TestComponentBuilder} from '@angular/compiler/testing';
import {Component, Injector} from '@angular/core';
import {ComponentResolver} from '@angular/core';
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, fakeAsync, iit, inject, it, tick, xdescribe, xit} from '@angular/core/testing';
import {beforeEach, beforeEachProviders, ddescribe, describe, fakeAsync, iit, inject, it, tick, xdescribe, xit} from '@angular/core/testing';
import {expect} from '@angular/platform-browser/testing/matchers';
import {Observable} from 'rxjs/Observable';
import {of } from 'rxjs/observable/of';

View File

@ -1,40 +1,3 @@
export declare var browserDetection: BrowserDetection;
export declare class BrowserDetection {
static setup(): void;
constructor(ua: string);
isFirefox: boolean;
isAndroid: boolean;
isEdge: boolean;
isIE: boolean;
isWebkit: boolean;
isIOS7: boolean;
isSlow: boolean;
supportsIntlApi: boolean;
isChromeDesktop: boolean;
}
export declare function dispatchEvent(element: any, eventType: any): void;
export declare function el(html: string): HTMLElement;
export declare var expect: (actual: any) => NgMatchers;
export interface NgMatchers extends jasmine.Matchers {
toBePromise(): boolean;
toBeAnInstanceOf(expected: any): boolean;
toHaveText(expected: any): boolean;
toHaveCssClass(expected: any): boolean;
toHaveCssStyle(expected: any): boolean;
toImplement(expected: any): boolean;
toContainError(expected: any): boolean;
not: NgMatchers;
}
export declare function normalizeCSS(css: string): string;
export declare function stringifyElement(el: any): string;
export declare const TEST_BROWSER_APPLICATION_PROVIDERS: Array<any>;
export declare const TEST_BROWSER_PLATFORM_PROVIDERS: Array<any>;