platform-browser-dynamic-testing.umd.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /**
  2. * @license Angular v8.1.0
  3. * (c) 2010-2019 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/core/testing'), require('@angular/platform-browser-dynamic'), require('@angular/platform-browser/testing'), require('@angular/common'), require('@angular/platform-browser'), require('@angular/compiler'), require('@angular/compiler/testing')) :
  8. typeof define === 'function' && define.amd ? define('@angular/platform-browser-dynamic/testing', ['exports', '@angular/core', '@angular/core/testing', '@angular/platform-browser-dynamic', '@angular/platform-browser/testing', '@angular/common', '@angular/platform-browser', '@angular/compiler', '@angular/compiler/testing'], factory) :
  9. (global = global || self, factory((global.ng = global.ng || {}, global.ng.platformBrowserDynamic = global.ng.platformBrowserDynamic || {}, global.ng.platformBrowserDynamic.testing = {}), global.ng.core, global.ng.core.testing, global.ng.platformBrowserDynamic, global.ng.platformBrowser.testing, global.ng.common, global.ng.platformBrowser, global.ng.compiler, global.ng.compiler.testing));
  10. }(this, function (exports, core, testing, platformBrowserDynamic, testing$1, common, platformBrowser, compiler, testing$2) { 'use strict';
  11. /*! *****************************************************************************
  12. Copyright (c) Microsoft Corporation. All rights reserved.
  13. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  14. this file except in compliance with the License. You may obtain a copy of the
  15. License at http://www.apache.org/licenses/LICENSE-2.0
  16. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  18. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  19. MERCHANTABLITY OR NON-INFRINGEMENT.
  20. See the Apache Version 2.0 License for specific language governing permissions
  21. and limitations under the License.
  22. ***************************************************************************** */
  23. /* global Reflect, Promise */
  24. var extendStatics = function(d, b) {
  25. extendStatics = Object.setPrototypeOf ||
  26. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  27. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  28. return extendStatics(d, b);
  29. };
  30. function __extends(d, b) {
  31. extendStatics(d, b);
  32. function __() { this.constructor = d; }
  33. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34. }
  35. function __decorate(decorators, target, key, desc) {
  36. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  37. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  38. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  39. return c > 3 && r && Object.defineProperty(target, key, r), r;
  40. }
  41. function __param(paramIndex, decorator) {
  42. return function (target, key) { decorator(target, key, paramIndex); }
  43. }
  44. function __metadata(metadataKey, metadataValue) {
  45. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  46. }
  47. /**
  48. * @license
  49. * Copyright Google Inc. All Rights Reserved.
  50. *
  51. * Use of this source code is governed by an MIT-style license that can be
  52. * found in the LICENSE file at https://angular.io/license
  53. */
  54. /**
  55. * A DOM based implementation of the TestComponentRenderer.
  56. */
  57. var DOMTestComponentRenderer = /** @class */ (function (_super) {
  58. __extends(DOMTestComponentRenderer, _super);
  59. function DOMTestComponentRenderer(_doc) {
  60. var _this = _super.call(this) || this;
  61. _this._doc = _doc;
  62. return _this;
  63. }
  64. DOMTestComponentRenderer.prototype.insertRootElement = function (rootElId) {
  65. var rootEl = platformBrowser.ɵgetDOM().firstChild(platformBrowser.ɵgetDOM().content(platformBrowser.ɵgetDOM().createTemplate("<div id=\"" + rootElId + "\"></div>")));
  66. // TODO(juliemr): can/should this be optional?
  67. var oldRoots = platformBrowser.ɵgetDOM().querySelectorAll(this._doc, '[id^=root]');
  68. for (var i = 0; i < oldRoots.length; i++) {
  69. platformBrowser.ɵgetDOM().remove(oldRoots[i]);
  70. }
  71. platformBrowser.ɵgetDOM().appendChild(this._doc.body, rootEl);
  72. };
  73. DOMTestComponentRenderer = __decorate([
  74. core.Injectable(),
  75. __param(0, core.Inject(common.DOCUMENT)),
  76. __metadata("design:paramtypes", [Object])
  77. ], DOMTestComponentRenderer);
  78. return DOMTestComponentRenderer;
  79. }(testing.TestComponentRenderer));
  80. /**
  81. * @license
  82. * Copyright Google Inc. All Rights Reserved.
  83. *
  84. * Use of this source code is governed by an MIT-style license that can be
  85. * found in the LICENSE file at https://angular.io/license
  86. */
  87. /**
  88. * @license
  89. * Copyright Google Inc. All Rights Reserved.
  90. *
  91. * Use of this source code is governed by an MIT-style license that can be
  92. * found in the LICENSE file at https://angular.io/license
  93. */
  94. var COMPILER_PROVIDERS = [
  95. { provide: testing$2.MockPipeResolver, deps: [compiler.CompileReflector] },
  96. { provide: compiler.PipeResolver, useExisting: testing$2.MockPipeResolver },
  97. { provide: testing$2.MockDirectiveResolver, deps: [compiler.CompileReflector] },
  98. { provide: compiler.DirectiveResolver, useExisting: testing$2.MockDirectiveResolver },
  99. { provide: testing$2.MockNgModuleResolver, deps: [compiler.CompileReflector] },
  100. { provide: compiler.NgModuleResolver, useExisting: testing$2.MockNgModuleResolver },
  101. ];
  102. var TestingCompilerFactoryImpl = /** @class */ (function () {
  103. function TestingCompilerFactoryImpl(_injector, _compilerFactory) {
  104. this._injector = _injector;
  105. this._compilerFactory = _compilerFactory;
  106. }
  107. TestingCompilerFactoryImpl.prototype.createTestingCompiler = function (options) {
  108. var compiler = this._compilerFactory.createCompiler(options);
  109. return new TestingCompilerImpl(compiler, compiler.injector.get(testing$2.MockDirectiveResolver), compiler.injector.get(testing$2.MockPipeResolver), compiler.injector.get(testing$2.MockNgModuleResolver));
  110. };
  111. return TestingCompilerFactoryImpl;
  112. }());
  113. var TestingCompilerImpl = /** @class */ (function () {
  114. function TestingCompilerImpl(_compiler, _directiveResolver, _pipeResolver, _moduleResolver) {
  115. this._compiler = _compiler;
  116. this._directiveResolver = _directiveResolver;
  117. this._pipeResolver = _pipeResolver;
  118. this._moduleResolver = _moduleResolver;
  119. this._overrider = new testing.ɵMetadataOverrider();
  120. }
  121. Object.defineProperty(TestingCompilerImpl.prototype, "injector", {
  122. get: function () { return this._compiler.injector; },
  123. enumerable: true,
  124. configurable: true
  125. });
  126. TestingCompilerImpl.prototype.compileModuleSync = function (moduleType) {
  127. return this._compiler.compileModuleSync(moduleType);
  128. };
  129. TestingCompilerImpl.prototype.compileModuleAsync = function (moduleType) {
  130. return this._compiler.compileModuleAsync(moduleType);
  131. };
  132. TestingCompilerImpl.prototype.compileModuleAndAllComponentsSync = function (moduleType) {
  133. return this._compiler.compileModuleAndAllComponentsSync(moduleType);
  134. };
  135. TestingCompilerImpl.prototype.compileModuleAndAllComponentsAsync = function (moduleType) {
  136. return this._compiler.compileModuleAndAllComponentsAsync(moduleType);
  137. };
  138. TestingCompilerImpl.prototype.getComponentFactory = function (component) {
  139. return this._compiler.getComponentFactory(component);
  140. };
  141. TestingCompilerImpl.prototype.checkOverrideAllowed = function (type) {
  142. if (this._compiler.hasAotSummary(type)) {
  143. throw new Error(core.ɵstringify(type) + " was AOT compiled, so its metadata cannot be changed.");
  144. }
  145. };
  146. TestingCompilerImpl.prototype.overrideModule = function (ngModule, override) {
  147. this.checkOverrideAllowed(ngModule);
  148. var oldMetadata = this._moduleResolver.resolve(ngModule, false);
  149. this._moduleResolver.setNgModule(ngModule, this._overrider.overrideMetadata(core.NgModule, oldMetadata, override));
  150. this.clearCacheFor(ngModule);
  151. };
  152. TestingCompilerImpl.prototype.overrideDirective = function (directive, override) {
  153. this.checkOverrideAllowed(directive);
  154. var oldMetadata = this._directiveResolver.resolve(directive, false);
  155. this._directiveResolver.setDirective(directive, this._overrider.overrideMetadata(core.Directive, oldMetadata, override));
  156. this.clearCacheFor(directive);
  157. };
  158. TestingCompilerImpl.prototype.overrideComponent = function (component, override) {
  159. this.checkOverrideAllowed(component);
  160. var oldMetadata = this._directiveResolver.resolve(component, false);
  161. this._directiveResolver.setDirective(component, this._overrider.overrideMetadata(core.Component, oldMetadata, override));
  162. this.clearCacheFor(component);
  163. };
  164. TestingCompilerImpl.prototype.overridePipe = function (pipe, override) {
  165. this.checkOverrideAllowed(pipe);
  166. var oldMetadata = this._pipeResolver.resolve(pipe, false);
  167. this._pipeResolver.setPipe(pipe, this._overrider.overrideMetadata(core.Pipe, oldMetadata, override));
  168. this.clearCacheFor(pipe);
  169. };
  170. TestingCompilerImpl.prototype.loadAotSummaries = function (summaries) { this._compiler.loadAotSummaries(summaries); };
  171. TestingCompilerImpl.prototype.clearCache = function () { this._compiler.clearCache(); };
  172. TestingCompilerImpl.prototype.clearCacheFor = function (type) { this._compiler.clearCacheFor(type); };
  173. TestingCompilerImpl.prototype.getComponentFromError = function (error) { return error[compiler.ERROR_COMPONENT_TYPE] || null; };
  174. TestingCompilerImpl.prototype.getModuleId = function (moduleType) {
  175. return this._moduleResolver.resolve(moduleType, true).id;
  176. };
  177. return TestingCompilerImpl;
  178. }());
  179. /**
  180. * @license
  181. * Copyright Google Inc. All Rights Reserved.
  182. *
  183. * Use of this source code is governed by an MIT-style license that can be
  184. * found in the LICENSE file at https://angular.io/license
  185. */
  186. var ɵ0 = { providers: COMPILER_PROVIDERS };
  187. /**
  188. * Platform for dynamic tests
  189. *
  190. * @publicApi
  191. */
  192. var platformCoreDynamicTesting = core.createPlatformFactory(platformBrowserDynamic.ɵplatformCoreDynamic, 'coreDynamicTesting', [
  193. { provide: core.COMPILER_OPTIONS, useValue: ɵ0, multi: true }, {
  194. provide: testing.ɵTestingCompilerFactory,
  195. useClass: TestingCompilerFactoryImpl,
  196. deps: [core.Injector, core.CompilerFactory]
  197. }
  198. ]);
  199. /**
  200. * @license
  201. * Copyright Google Inc. All Rights Reserved.
  202. *
  203. * Use of this source code is governed by an MIT-style license that can be
  204. * found in the LICENSE file at https://angular.io/license
  205. */
  206. /**
  207. * @license
  208. * Copyright Google Inc. All Rights Reserved.
  209. *
  210. * Use of this source code is governed by an MIT-style license that can be
  211. * found in the LICENSE file at https://angular.io/license
  212. */
  213. /**
  214. * @publicApi
  215. */
  216. var platformBrowserDynamicTesting = core.createPlatformFactory(platformCoreDynamicTesting, 'browserDynamicTesting', platformBrowserDynamic.ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS);
  217. /**
  218. * NgModule for testing.
  219. *
  220. * @publicApi
  221. */
  222. var BrowserDynamicTestingModule = /** @class */ (function () {
  223. function BrowserDynamicTestingModule() {
  224. }
  225. BrowserDynamicTestingModule = __decorate([
  226. core.NgModule({
  227. exports: [testing$1.BrowserTestingModule],
  228. providers: [
  229. { provide: testing.TestComponentRenderer, useClass: DOMTestComponentRenderer },
  230. ]
  231. })
  232. ], BrowserDynamicTestingModule);
  233. return BrowserDynamicTestingModule;
  234. }());
  235. /**
  236. * @license
  237. * Copyright Google Inc. All Rights Reserved.
  238. *
  239. * Use of this source code is governed by an MIT-style license that can be
  240. * found in the LICENSE file at https://angular.io/license
  241. */
  242. /**
  243. * @license
  244. * Copyright Google Inc. All Rights Reserved.
  245. *
  246. * Use of this source code is governed by an MIT-style license that can be
  247. * found in the LICENSE file at https://angular.io/license
  248. */
  249. /**
  250. * Generated bundle index. Do not edit.
  251. */
  252. exports.ɵangular_packages_platform_browser_dynamic_testing_testing_a = COMPILER_PROVIDERS;
  253. exports.ɵangular_packages_platform_browser_dynamic_testing_testing_b = TestingCompilerFactoryImpl;
  254. exports.platformBrowserDynamicTesting = platformBrowserDynamicTesting;
  255. exports.BrowserDynamicTestingModule = BrowserDynamicTestingModule;
  256. exports.ɵDOMTestComponentRenderer = DOMTestComponentRenderer;
  257. exports.ɵplatformCoreDynamicTesting = platformCoreDynamicTesting;
  258. Object.defineProperty(exports, '__esModule', { value: true });
  259. }));
  260. //# sourceMappingURL=platform-browser-dynamic-testing.umd.js.map