UNPKG

22.6 kBJavaScriptView Raw
1/**
2 * @license Angular v9.1.1
3 * (c) 2010-2020 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7(function (global, factory) {
8 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/compiler'), require('@angular/compiler/testing')) :
9 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/compiler', '@angular/compiler/testing'], factory) :
10 (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.compiler, global.ng.compiler.testing));
11}(this, (function (exports, core, testing, platformBrowserDynamic, testing$1, common, compiler, testing$2) { 'use strict';
12
13 /*! *****************************************************************************
14 Copyright (c) Microsoft Corporation. All rights reserved.
15 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
16 this file except in compliance with the License. You may obtain a copy of the
17 License at http://www.apache.org/licenses/LICENSE-2.0
18
19 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
21 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
22 MERCHANTABLITY OR NON-INFRINGEMENT.
23
24 See the Apache Version 2.0 License for specific language governing permissions
25 and limitations under the License.
26 ***************************************************************************** */
27 /* global Reflect, Promise */
28
29 var extendStatics = function(d, b) {
30 extendStatics = Object.setPrototypeOf ||
31 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33 return extendStatics(d, b);
34 };
35
36 function __extends(d, b) {
37 extendStatics(d, b);
38 function __() { this.constructor = d; }
39 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
40 }
41
42 var __assign = function() {
43 __assign = Object.assign || function __assign(t) {
44 for (var s, i = 1, n = arguments.length; i < n; i++) {
45 s = arguments[i];
46 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
47 }
48 return t;
49 };
50 return __assign.apply(this, arguments);
51 };
52
53 function __rest(s, e) {
54 var t = {};
55 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
56 t[p] = s[p];
57 if (s != null && typeof Object.getOwnPropertySymbols === "function")
58 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
59 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
60 t[p[i]] = s[p[i]];
61 }
62 return t;
63 }
64
65 function __decorate(decorators, target, key, desc) {
66 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
67 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
68 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;
69 return c > 3 && r && Object.defineProperty(target, key, r), r;
70 }
71
72 function __param(paramIndex, decorator) {
73 return function (target, key) { decorator(target, key, paramIndex); }
74 }
75
76 function __metadata(metadataKey, metadataValue) {
77 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
78 }
79
80 function __awaiter(thisArg, _arguments, P, generator) {
81 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
82 return new (P || (P = Promise))(function (resolve, reject) {
83 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
84 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
85 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
86 step((generator = generator.apply(thisArg, _arguments || [])).next());
87 });
88 }
89
90 function __generator(thisArg, body) {
91 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
92 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
93 function verb(n) { return function (v) { return step([n, v]); }; }
94 function step(op) {
95 if (f) throw new TypeError("Generator is already executing.");
96 while (_) try {
97 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
98 if (y = 0, t) op = [op[0] & 2, t.value];
99 switch (op[0]) {
100 case 0: case 1: t = op; break;
101 case 4: _.label++; return { value: op[1], done: false };
102 case 5: _.label++; y = op[1]; op = [0]; continue;
103 case 7: op = _.ops.pop(); _.trys.pop(); continue;
104 default:
105 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
106 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
107 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
108 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
109 if (t[2]) _.ops.pop();
110 _.trys.pop(); continue;
111 }
112 op = body.call(thisArg, _);
113 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
114 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
115 }
116 }
117
118 function __exportStar(m, exports) {
119 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
120 }
121
122 function __values(o) {
123 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
124 if (m) return m.call(o);
125 if (o && typeof o.length === "number") return {
126 next: function () {
127 if (o && i >= o.length) o = void 0;
128 return { value: o && o[i++], done: !o };
129 }
130 };
131 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
132 }
133
134 function __read(o, n) {
135 var m = typeof Symbol === "function" && o[Symbol.iterator];
136 if (!m) return o;
137 var i = m.call(o), r, ar = [], e;
138 try {
139 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
140 }
141 catch (error) { e = { error: error }; }
142 finally {
143 try {
144 if (r && !r.done && (m = i["return"])) m.call(i);
145 }
146 finally { if (e) throw e.error; }
147 }
148 return ar;
149 }
150
151 function __spread() {
152 for (var ar = [], i = 0; i < arguments.length; i++)
153 ar = ar.concat(__read(arguments[i]));
154 return ar;
155 }
156
157 function __spreadArrays() {
158 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
159 for (var r = Array(s), k = 0, i = 0; i < il; i++)
160 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
161 r[k] = a[j];
162 return r;
163 };
164
165 function __await(v) {
166 return this instanceof __await ? (this.v = v, this) : new __await(v);
167 }
168
169 function __asyncGenerator(thisArg, _arguments, generator) {
170 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
171 var g = generator.apply(thisArg, _arguments || []), i, q = [];
172 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
173 function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
174 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
175 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
176 function fulfill(value) { resume("next", value); }
177 function reject(value) { resume("throw", value); }
178 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
179 }
180
181 function __asyncDelegator(o) {
182 var i, p;
183 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
184 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
185 }
186
187 function __asyncValues(o) {
188 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
189 var m = o[Symbol.asyncIterator], i;
190 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
191 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
192 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
193 }
194
195 function __makeTemplateObject(cooked, raw) {
196 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
197 return cooked;
198 };
199
200 function __importStar(mod) {
201 if (mod && mod.__esModule) return mod;
202 var result = {};
203 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
204 result.default = mod;
205 return result;
206 }
207
208 function __importDefault(mod) {
209 return (mod && mod.__esModule) ? mod : { default: mod };
210 }
211
212 function __classPrivateFieldGet(receiver, privateMap) {
213 if (!privateMap.has(receiver)) {
214 throw new TypeError("attempted to get private field on non-instance");
215 }
216 return privateMap.get(receiver);
217 }
218
219 function __classPrivateFieldSet(receiver, privateMap, value) {
220 if (!privateMap.has(receiver)) {
221 throw new TypeError("attempted to set private field on non-instance");
222 }
223 privateMap.set(receiver, value);
224 return value;
225 }
226
227 /**
228 * @license
229 * Copyright Google Inc. All Rights Reserved.
230 *
231 * Use of this source code is governed by an MIT-style license that can be
232 * found in the LICENSE file at https://angular.io/license
233 */
234 /**
235 * A DOM based implementation of the TestComponentRenderer.
236 */
237 var DOMTestComponentRenderer = /** @class */ (function (_super) {
238 __extends(DOMTestComponentRenderer, _super);
239 function DOMTestComponentRenderer(_doc) {
240 var _this = _super.call(this) || this;
241 _this._doc = _doc;
242 return _this;
243 }
244 DOMTestComponentRenderer.prototype.insertRootElement = function (rootElId) {
245 var template = common.ɵgetDOM().getDefaultDocument().createElement('template');
246 template.innerHTML = "<div id=\"" + rootElId + "\"></div>";
247 var rootEl = getContent(template).firstChild;
248 // TODO(juliemr): can/should this be optional?
249 var oldRoots = this._doc.querySelectorAll('[id^=root]');
250 for (var i = 0; i < oldRoots.length; i++) {
251 common.ɵgetDOM().remove(oldRoots[i]);
252 }
253 this._doc.body.appendChild(rootEl);
254 };
255 DOMTestComponentRenderer = __decorate([
256 core.Injectable(),
257 __param(0, core.Inject(common.DOCUMENT)),
258 __metadata("design:paramtypes", [Object])
259 ], DOMTestComponentRenderer);
260 return DOMTestComponentRenderer;
261 }(testing.TestComponentRenderer));
262 function getContent(node) {
263 if ('content' in node) {
264 return node.content;
265 }
266 else {
267 return node;
268 }
269 }
270
271 /**
272 * @license
273 * Copyright Google Inc. All Rights Reserved.
274 *
275 * Use of this source code is governed by an MIT-style license that can be
276 * found in the LICENSE file at https://angular.io/license
277 */
278
279 /**
280 * @license
281 * Copyright Google Inc. All Rights Reserved.
282 *
283 * Use of this source code is governed by an MIT-style license that can be
284 * found in the LICENSE file at https://angular.io/license
285 */
286 var COMPILER_PROVIDERS = [
287 { provide: testing$2.MockPipeResolver, deps: [compiler.CompileReflector] },
288 { provide: compiler.PipeResolver, useExisting: testing$2.MockPipeResolver },
289 { provide: testing$2.MockDirectiveResolver, deps: [compiler.CompileReflector] },
290 { provide: compiler.DirectiveResolver, useExisting: testing$2.MockDirectiveResolver },
291 { provide: testing$2.MockNgModuleResolver, deps: [compiler.CompileReflector] },
292 { provide: compiler.NgModuleResolver, useExisting: testing$2.MockNgModuleResolver },
293 ];
294 var TestingCompilerFactoryImpl = /** @class */ (function () {
295 function TestingCompilerFactoryImpl(_injector, _compilerFactory) {
296 this._injector = _injector;
297 this._compilerFactory = _compilerFactory;
298 }
299 TestingCompilerFactoryImpl.prototype.createTestingCompiler = function (options) {
300 var compiler = this._compilerFactory.createCompiler(options);
301 return new TestingCompilerImpl(compiler, compiler.injector.get(testing$2.MockDirectiveResolver), compiler.injector.get(testing$2.MockPipeResolver), compiler.injector.get(testing$2.MockNgModuleResolver));
302 };
303 return TestingCompilerFactoryImpl;
304 }());
305 var TestingCompilerImpl = /** @class */ (function () {
306 function TestingCompilerImpl(_compiler, _directiveResolver, _pipeResolver, _moduleResolver) {
307 this._compiler = _compiler;
308 this._directiveResolver = _directiveResolver;
309 this._pipeResolver = _pipeResolver;
310 this._moduleResolver = _moduleResolver;
311 this._overrider = new testing.ɵMetadataOverrider();
312 }
313 Object.defineProperty(TestingCompilerImpl.prototype, "injector", {
314 get: function () { return this._compiler.injector; },
315 enumerable: true,
316 configurable: true
317 });
318 TestingCompilerImpl.prototype.compileModuleSync = function (moduleType) {
319 return this._compiler.compileModuleSync(moduleType);
320 };
321 TestingCompilerImpl.prototype.compileModuleAsync = function (moduleType) {
322 return this._compiler.compileModuleAsync(moduleType);
323 };
324 TestingCompilerImpl.prototype.compileModuleAndAllComponentsSync = function (moduleType) {
325 return this._compiler.compileModuleAndAllComponentsSync(moduleType);
326 };
327 TestingCompilerImpl.prototype.compileModuleAndAllComponentsAsync = function (moduleType) {
328 return this._compiler.compileModuleAndAllComponentsAsync(moduleType);
329 };
330 TestingCompilerImpl.prototype.getComponentFactory = function (component) {
331 return this._compiler.getComponentFactory(component);
332 };
333 TestingCompilerImpl.prototype.checkOverrideAllowed = function (type) {
334 if (this._compiler.hasAotSummary(type)) {
335 throw new Error(core.ɵstringify(type) + " was AOT compiled, so its metadata cannot be changed.");
336 }
337 };
338 TestingCompilerImpl.prototype.overrideModule = function (ngModule, override) {
339 this.checkOverrideAllowed(ngModule);
340 var oldMetadata = this._moduleResolver.resolve(ngModule, false);
341 this._moduleResolver.setNgModule(ngModule, this._overrider.overrideMetadata(core.NgModule, oldMetadata, override));
342 this.clearCacheFor(ngModule);
343 };
344 TestingCompilerImpl.prototype.overrideDirective = function (directive, override) {
345 this.checkOverrideAllowed(directive);
346 var oldMetadata = this._directiveResolver.resolve(directive, false);
347 this._directiveResolver.setDirective(directive, this._overrider.overrideMetadata(core.Directive, oldMetadata, override));
348 this.clearCacheFor(directive);
349 };
350 TestingCompilerImpl.prototype.overrideComponent = function (component, override) {
351 this.checkOverrideAllowed(component);
352 var oldMetadata = this._directiveResolver.resolve(component, false);
353 this._directiveResolver.setDirective(component, this._overrider.overrideMetadata(core.Component, oldMetadata, override));
354 this.clearCacheFor(component);
355 };
356 TestingCompilerImpl.prototype.overridePipe = function (pipe, override) {
357 this.checkOverrideAllowed(pipe);
358 var oldMetadata = this._pipeResolver.resolve(pipe, false);
359 this._pipeResolver.setPipe(pipe, this._overrider.overrideMetadata(core.Pipe, oldMetadata, override));
360 this.clearCacheFor(pipe);
361 };
362 TestingCompilerImpl.prototype.loadAotSummaries = function (summaries) { this._compiler.loadAotSummaries(summaries); };
363 TestingCompilerImpl.prototype.clearCache = function () { this._compiler.clearCache(); };
364 TestingCompilerImpl.prototype.clearCacheFor = function (type) { this._compiler.clearCacheFor(type); };
365 TestingCompilerImpl.prototype.getComponentFromError = function (error) { return error[compiler.ERROR_COMPONENT_TYPE] || null; };
366 TestingCompilerImpl.prototype.getModuleId = function (moduleType) {
367 return this._moduleResolver.resolve(moduleType, true).id;
368 };
369 return TestingCompilerImpl;
370 }());
371
372 /**
373 * @license
374 * Copyright Google Inc. All Rights Reserved.
375 *
376 * Use of this source code is governed by an MIT-style license that can be
377 * found in the LICENSE file at https://angular.io/license
378 */
379 var ɵ0 = { providers: COMPILER_PROVIDERS };
380 /**
381 * Platform for dynamic tests
382 *
383 * @publicApi
384 */
385 var platformCoreDynamicTesting = core.createPlatformFactory(platformBrowserDynamic.ɵplatformCoreDynamic, 'coreDynamicTesting', [
386 { provide: core.COMPILER_OPTIONS, useValue: ɵ0, multi: true }, {
387 provide: testing.ɵTestingCompilerFactory,
388 useClass: TestingCompilerFactoryImpl,
389 deps: [core.Injector, core.CompilerFactory]
390 }
391 ]);
392
393 /**
394 * @license
395 * Copyright Google Inc. All Rights Reserved.
396 *
397 * Use of this source code is governed by an MIT-style license that can be
398 * found in the LICENSE file at https://angular.io/license
399 */
400
401 /**
402 * @license
403 * Copyright Google Inc. All Rights Reserved.
404 *
405 * Use of this source code is governed by an MIT-style license that can be
406 * found in the LICENSE file at https://angular.io/license
407 */
408 /**
409 * @publicApi
410 */
411 var platformBrowserDynamicTesting = core.createPlatformFactory(platformCoreDynamicTesting, 'browserDynamicTesting', platformBrowserDynamic.ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS);
412 /**
413 * NgModule for testing.
414 *
415 * @publicApi
416 */
417 var BrowserDynamicTestingModule = /** @class */ (function () {
418 function BrowserDynamicTestingModule() {
419 }
420 BrowserDynamicTestingModule = __decorate([
421 core.NgModule({
422 exports: [testing$1.BrowserTestingModule],
423 providers: [
424 { provide: testing.TestComponentRenderer, useClass: DOMTestComponentRenderer },
425 ]
426 })
427 ], BrowserDynamicTestingModule);
428 return BrowserDynamicTestingModule;
429 }());
430
431 /**
432 * @license
433 * Copyright Google Inc. All Rights Reserved.
434 *
435 * Use of this source code is governed by an MIT-style license that can be
436 * found in the LICENSE file at https://angular.io/license
437 */
438
439 /**
440 * @license
441 * Copyright Google Inc. All Rights Reserved.
442 *
443 * Use of this source code is governed by an MIT-style license that can be
444 * found in the LICENSE file at https://angular.io/license
445 */
446
447 /**
448 * Generated bundle index. Do not edit.
449 */
450
451 exports.BrowserDynamicTestingModule = BrowserDynamicTestingModule;
452 exports.platformBrowserDynamicTesting = platformBrowserDynamicTesting;
453 exports.ɵDOMTestComponentRenderer = DOMTestComponentRenderer;
454 exports.ɵangular_packages_platform_browser_dynamic_testing_testing_a = COMPILER_PROVIDERS;
455 exports.ɵangular_packages_platform_browser_dynamic_testing_testing_b = TestingCompilerFactoryImpl;
456 exports.ɵplatformCoreDynamicTesting = platformCoreDynamicTesting;
457
458 Object.defineProperty(exports, '__esModule', { value: true });
459
460})));
461//# sourceMappingURL=platform-browser-dynamic-testing.umd.js.map