| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569 |
- /**
- * @license Angular v5.2.11
- * (c) 2010-2018 Google, Inc. https://angular.io/
- * License: MIT
- */
- import { COMPILER_OPTIONS, CompilerFactory, Component, Directive, Inject, Injectable, Injector, NgModule, Pipe, createPlatformFactory, ɵstringify } from '@angular/core';
- import { TestComponentRenderer, ɵTestingCompilerFactory } from '@angular/core/testing';
- import { ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, ɵplatformCoreDynamic } from '@angular/platform-browser-dynamic';
- import { BrowserTestingModule } from '@angular/platform-browser/testing';
- import { __extends } from 'tslib';
- import { DOCUMENT, ɵgetDOM } from '@angular/platform-browser';
- import { CompileReflector, DirectiveResolver, ERROR_COMPONENT_TYPE, NgModuleResolver, PipeResolver } from '@angular/compiler';
- import { MockDirectiveResolver, MockNgModuleResolver, MockPipeResolver } from '@angular/compiler/testing';
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @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
- */
- /**
- * A DOM based implementation of the TestComponentRenderer.
- */
- var DOMTestComponentRenderer = /** @class */ (function (_super) {
- __extends(DOMTestComponentRenderer, _super);
- function DOMTestComponentRenderer(_doc /** TODO #9100 */) {
- var _this = _super.call(this) || this;
- _this._doc = _doc;
- return _this;
- }
- /**
- * @param {?} rootElId
- * @return {?}
- */
- DOMTestComponentRenderer.prototype.insertRootElement = /**
- * @param {?} rootElId
- * @return {?}
- */
- function (rootElId) {
- var /** @type {?} */ rootEl = /** @type {?} */ (ɵgetDOM().firstChild(ɵgetDOM().content(ɵgetDOM().createTemplate("<div id=\"" + rootElId + "\"></div>"))));
- // TODO(juliemr): can/should this be optional?
- var /** @type {?} */ oldRoots = ɵgetDOM().querySelectorAll(this._doc, '[id^=root]');
- for (var /** @type {?} */ i = 0; i < oldRoots.length; i++) {
- ɵgetDOM().remove(oldRoots[i]);
- }
- ɵgetDOM().appendChild(this._doc.body, rootEl);
- };
- DOMTestComponentRenderer.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- DOMTestComponentRenderer.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] },] },
- ]; };
- return DOMTestComponentRenderer;
- }(TestComponentRenderer));
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @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
- */
- var _nextReferenceId = 0;
- var MetadataOverrider = /** @class */ (function () {
- function MetadataOverrider() {
- this._references = new Map();
- }
- /**
- * Creates a new instance for the given metadata class
- * based on an old instance and overrides.
- */
- /**
- * Creates a new instance for the given metadata class
- * based on an old instance and overrides.
- * @template C, T
- * @param {?} metadataClass
- * @param {?} oldMetadata
- * @param {?} override
- * @return {?}
- */
- MetadataOverrider.prototype.overrideMetadata = /**
- * Creates a new instance for the given metadata class
- * based on an old instance and overrides.
- * @template C, T
- * @param {?} metadataClass
- * @param {?} oldMetadata
- * @param {?} override
- * @return {?}
- */
- function (metadataClass, oldMetadata, override) {
- var /** @type {?} */ props = {};
- if (oldMetadata) {
- _valueProps(oldMetadata).forEach(function (prop) { return props[prop] = (/** @type {?} */ (oldMetadata))[prop]; });
- }
- if (override.set) {
- if (override.remove || override.add) {
- throw new Error("Cannot set and add/remove " + ɵstringify(metadataClass) + " at the same time!");
- }
- setMetadata(props, override.set);
- }
- if (override.remove) {
- removeMetadata(props, override.remove, this._references);
- }
- if (override.add) {
- addMetadata(props, override.add);
- }
- return new metadataClass(/** @type {?} */ (props));
- };
- return MetadataOverrider;
- }());
- /**
- * @param {?} metadata
- * @param {?} remove
- * @param {?} references
- * @return {?}
- */
- function removeMetadata(metadata, remove, references) {
- var /** @type {?} */ removeObjects = new Set();
- var _loop_1 = function (prop) {
- var /** @type {?} */ removeValue = remove[prop];
- if (removeValue instanceof Array) {
- removeValue.forEach(function (value) { removeObjects.add(_propHashKey(prop, value, references)); });
- }
- else {
- removeObjects.add(_propHashKey(prop, removeValue, references));
- }
- };
- for (var /** @type {?} */ prop in remove) {
- _loop_1(prop);
- }
- var _loop_2 = function (prop) {
- var /** @type {?} */ propValue = metadata[prop];
- if (propValue instanceof Array) {
- metadata[prop] = propValue.filter(function (value) { return !removeObjects.has(_propHashKey(prop, value, references)); });
- }
- else {
- if (removeObjects.has(_propHashKey(prop, propValue, references))) {
- metadata[prop] = undefined;
- }
- }
- };
- for (var /** @type {?} */ prop in metadata) {
- _loop_2(prop);
- }
- }
- /**
- * @param {?} metadata
- * @param {?} add
- * @return {?}
- */
- function addMetadata(metadata, add) {
- for (var /** @type {?} */ prop in add) {
- var /** @type {?} */ addValue = add[prop];
- var /** @type {?} */ propValue = metadata[prop];
- if (propValue != null && propValue instanceof Array) {
- metadata[prop] = propValue.concat(addValue);
- }
- else {
- metadata[prop] = addValue;
- }
- }
- }
- /**
- * @param {?} metadata
- * @param {?} set
- * @return {?}
- */
- function setMetadata(metadata, set) {
- for (var /** @type {?} */ prop in set) {
- metadata[prop] = set[prop];
- }
- }
- /**
- * @param {?} propName
- * @param {?} propValue
- * @param {?} references
- * @return {?}
- */
- function _propHashKey(propName, propValue, references) {
- var /** @type {?} */ replacer = function (key, value) {
- if (typeof value === 'function') {
- value = _serializeReference(value, references);
- }
- return value;
- };
- return propName + ":" + JSON.stringify(propValue, replacer);
- }
- /**
- * @param {?} ref
- * @param {?} references
- * @return {?}
- */
- function _serializeReference(ref, references) {
- var /** @type {?} */ id = references.get(ref);
- if (!id) {
- id = "" + ɵstringify(ref) + _nextReferenceId++;
- references.set(ref, id);
- }
- return id;
- }
- /**
- * @param {?} obj
- * @return {?}
- */
- function _valueProps(obj) {
- var /** @type {?} */ props = [];
- // regular public props
- Object.keys(obj).forEach(function (prop) {
- if (!prop.startsWith('_')) {
- props.push(prop);
- }
- });
- // getters
- var /** @type {?} */ proto = obj;
- while (proto = Object.getPrototypeOf(proto)) {
- Object.keys(proto).forEach(function (protoProp) {
- var /** @type {?} */ desc = Object.getOwnPropertyDescriptor(proto, protoProp);
- if (!protoProp.startsWith('_') && desc && 'get' in desc) {
- props.push(protoProp);
- }
- });
- }
- return props;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @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
- */
- var COMPILER_PROVIDERS = [
- { provide: MockPipeResolver, deps: [CompileReflector] },
- { provide: PipeResolver, useExisting: MockPipeResolver },
- { provide: MockDirectiveResolver, deps: [CompileReflector] },
- { provide: DirectiveResolver, useExisting: MockDirectiveResolver },
- { provide: MockNgModuleResolver, deps: [CompileReflector] },
- { provide: NgModuleResolver, useExisting: MockNgModuleResolver },
- ];
- var TestingCompilerFactoryImpl = /** @class */ (function () {
- function TestingCompilerFactoryImpl(_injector, _compilerFactory) {
- this._injector = _injector;
- this._compilerFactory = _compilerFactory;
- }
- /**
- * @param {?} options
- * @return {?}
- */
- TestingCompilerFactoryImpl.prototype.createTestingCompiler = /**
- * @param {?} options
- * @return {?}
- */
- function (options) {
- var /** @type {?} */ compiler = /** @type {?} */ (this._compilerFactory.createCompiler(options));
- return new TestingCompilerImpl(compiler, compiler.injector.get(MockDirectiveResolver), compiler.injector.get(MockPipeResolver), compiler.injector.get(MockNgModuleResolver));
- };
- return TestingCompilerFactoryImpl;
- }());
- var TestingCompilerImpl = /** @class */ (function () {
- function TestingCompilerImpl(_compiler, _directiveResolver, _pipeResolver, _moduleResolver) {
- this._compiler = _compiler;
- this._directiveResolver = _directiveResolver;
- this._pipeResolver = _pipeResolver;
- this._moduleResolver = _moduleResolver;
- this._overrider = new MetadataOverrider();
- }
- Object.defineProperty(TestingCompilerImpl.prototype, "injector", {
- get: /**
- * @return {?}
- */
- function () { return this._compiler.injector; },
- enumerable: true,
- configurable: true
- });
- /**
- * @template T
- * @param {?} moduleType
- * @return {?}
- */
- TestingCompilerImpl.prototype.compileModuleSync = /**
- * @template T
- * @param {?} moduleType
- * @return {?}
- */
- function (moduleType) {
- return this._compiler.compileModuleSync(moduleType);
- };
- /**
- * @template T
- * @param {?} moduleType
- * @return {?}
- */
- TestingCompilerImpl.prototype.compileModuleAsync = /**
- * @template T
- * @param {?} moduleType
- * @return {?}
- */
- function (moduleType) {
- return this._compiler.compileModuleAsync(moduleType);
- };
- /**
- * @template T
- * @param {?} moduleType
- * @return {?}
- */
- TestingCompilerImpl.prototype.compileModuleAndAllComponentsSync = /**
- * @template T
- * @param {?} moduleType
- * @return {?}
- */
- function (moduleType) {
- return this._compiler.compileModuleAndAllComponentsSync(moduleType);
- };
- /**
- * @template T
- * @param {?} moduleType
- * @return {?}
- */
- TestingCompilerImpl.prototype.compileModuleAndAllComponentsAsync = /**
- * @template T
- * @param {?} moduleType
- * @return {?}
- */
- function (moduleType) {
- return this._compiler.compileModuleAndAllComponentsAsync(moduleType);
- };
- /**
- * @template T
- * @param {?} component
- * @return {?}
- */
- TestingCompilerImpl.prototype.getComponentFactory = /**
- * @template T
- * @param {?} component
- * @return {?}
- */
- function (component) {
- return this._compiler.getComponentFactory(component);
- };
- /**
- * @param {?} type
- * @return {?}
- */
- TestingCompilerImpl.prototype.checkOverrideAllowed = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- if (this._compiler.hasAotSummary(type)) {
- throw new Error(ɵstringify(type) + " was AOT compiled, so its metadata cannot be changed.");
- }
- };
- /**
- * @param {?} ngModule
- * @param {?} override
- * @return {?}
- */
- TestingCompilerImpl.prototype.overrideModule = /**
- * @param {?} ngModule
- * @param {?} override
- * @return {?}
- */
- function (ngModule, override) {
- this.checkOverrideAllowed(ngModule);
- var /** @type {?} */ oldMetadata = this._moduleResolver.resolve(ngModule, false);
- this._moduleResolver.setNgModule(ngModule, this._overrider.overrideMetadata(NgModule, oldMetadata, override));
- this.clearCacheFor(ngModule);
- };
- /**
- * @param {?} directive
- * @param {?} override
- * @return {?}
- */
- TestingCompilerImpl.prototype.overrideDirective = /**
- * @param {?} directive
- * @param {?} override
- * @return {?}
- */
- function (directive, override) {
- this.checkOverrideAllowed(directive);
- var /** @type {?} */ oldMetadata = this._directiveResolver.resolve(directive, false);
- this._directiveResolver.setDirective(directive, this._overrider.overrideMetadata(Directive, /** @type {?} */ ((oldMetadata)), override));
- this.clearCacheFor(directive);
- };
- /**
- * @param {?} component
- * @param {?} override
- * @return {?}
- */
- TestingCompilerImpl.prototype.overrideComponent = /**
- * @param {?} component
- * @param {?} override
- * @return {?}
- */
- function (component, override) {
- this.checkOverrideAllowed(component);
- var /** @type {?} */ oldMetadata = this._directiveResolver.resolve(component, false);
- this._directiveResolver.setDirective(component, this._overrider.overrideMetadata(Component, /** @type {?} */ ((oldMetadata)), override));
- this.clearCacheFor(component);
- };
- /**
- * @param {?} pipe
- * @param {?} override
- * @return {?}
- */
- TestingCompilerImpl.prototype.overridePipe = /**
- * @param {?} pipe
- * @param {?} override
- * @return {?}
- */
- function (pipe, override) {
- this.checkOverrideAllowed(pipe);
- var /** @type {?} */ oldMetadata = this._pipeResolver.resolve(pipe, false);
- this._pipeResolver.setPipe(pipe, this._overrider.overrideMetadata(Pipe, oldMetadata, override));
- this.clearCacheFor(pipe);
- };
- /**
- * @param {?} summaries
- * @return {?}
- */
- TestingCompilerImpl.prototype.loadAotSummaries = /**
- * @param {?} summaries
- * @return {?}
- */
- function (summaries) { this._compiler.loadAotSummaries(summaries); };
- /**
- * @return {?}
- */
- TestingCompilerImpl.prototype.clearCache = /**
- * @return {?}
- */
- function () { this._compiler.clearCache(); };
- /**
- * @param {?} type
- * @return {?}
- */
- TestingCompilerImpl.prototype.clearCacheFor = /**
- * @param {?} type
- * @return {?}
- */
- function (type) { this._compiler.clearCacheFor(type); };
- /**
- * @param {?} error
- * @return {?}
- */
- TestingCompilerImpl.prototype.getComponentFromError = /**
- * @param {?} error
- * @return {?}
- */
- function (error) { return (/** @type {?} */ (error))[ERROR_COMPONENT_TYPE] || null; };
- return TestingCompilerImpl;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @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
- */
- /**
- * Platform for dynamic tests
- *
- * \@experimental
- */
- var platformCoreDynamicTesting = createPlatformFactory(ɵplatformCoreDynamic, 'coreDynamicTesting', [
- { provide: COMPILER_OPTIONS, useValue: { providers: COMPILER_PROVIDERS }, multi: true }, {
- provide: ɵTestingCompilerFactory,
- useClass: TestingCompilerFactoryImpl,
- deps: [Injector, CompilerFactory]
- }
- ]);
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @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
- */
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @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
- */
- /**
- * \@stable
- */
- var platformBrowserDynamicTesting = createPlatformFactory(platformCoreDynamicTesting, 'browserDynamicTesting', ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS);
- /**
- * NgModule for testing.
- *
- * \@stable
- */
- var BrowserDynamicTestingModule = /** @class */ (function () {
- function BrowserDynamicTestingModule() {
- }
- BrowserDynamicTestingModule.decorators = [
- { type: NgModule, args: [{
- exports: [BrowserTestingModule],
- providers: [
- { provide: TestComponentRenderer, useClass: DOMTestComponentRenderer },
- ]
- },] },
- ];
- /** @nocollapse */
- BrowserDynamicTestingModule.ctorParameters = function () { return []; };
- return BrowserDynamicTestingModule;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @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
- */
- /**
- * @module
- * @description
- * Entry point for all public APIs of this package.
- */
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * Generated bundle index. Do not edit.
- */
-
- export { platformBrowserDynamicTesting, BrowserDynamicTestingModule, DOMTestComponentRenderer as ɵDOMTestComponentRenderer, platformCoreDynamicTesting as ɵplatformCoreDynamicTesting, COMPILER_PROVIDERS as ɵa, TestingCompilerFactoryImpl as ɵb };
- //# sourceMappingURL=testing.js.map
|