UNPKG

22.3 kBJavaScriptView Raw
1/**
2 * @license Angular v8.2.14
3 * (c) 2010-2019 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/platform-browser')) :
9 typeof define === 'function' && define.amd ? define('@angular/platform-browser/testing', ['exports', '@angular/core', '@angular/platform-browser'], factory) :
10 (global = global || self, factory((global.ng = global.ng || {}, global.ng.platformBrowser = global.ng.platformBrowser || {}, global.ng.platformBrowser.testing = {}), global.ng.core, global.ng.platformBrowser));
11}(this, function (exports, core, platformBrowser) { '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++) if (e.indexOf(p[i]) < 0)
59 t[p[i]] = s[p[i]];
60 return t;
61 }
62
63 function __decorate(decorators, target, key, desc) {
64 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
65 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
66 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;
67 return c > 3 && r && Object.defineProperty(target, key, r), r;
68 }
69
70 function __param(paramIndex, decorator) {
71 return function (target, key) { decorator(target, key, paramIndex); }
72 }
73
74 function __metadata(metadataKey, metadataValue) {
75 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
76 }
77
78 function __awaiter(thisArg, _arguments, P, generator) {
79 return new (P || (P = Promise))(function (resolve, reject) {
80 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
81 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
82 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
83 step((generator = generator.apply(thisArg, _arguments || [])).next());
84 });
85 }
86
87 function __generator(thisArg, body) {
88 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
89 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
90 function verb(n) { return function (v) { return step([n, v]); }; }
91 function step(op) {
92 if (f) throw new TypeError("Generator is already executing.");
93 while (_) try {
94 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;
95 if (y = 0, t) op = [op[0] & 2, t.value];
96 switch (op[0]) {
97 case 0: case 1: t = op; break;
98 case 4: _.label++; return { value: op[1], done: false };
99 case 5: _.label++; y = op[1]; op = [0]; continue;
100 case 7: op = _.ops.pop(); _.trys.pop(); continue;
101 default:
102 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
103 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
104 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
105 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
106 if (t[2]) _.ops.pop();
107 _.trys.pop(); continue;
108 }
109 op = body.call(thisArg, _);
110 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
111 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
112 }
113 }
114
115 function __exportStar(m, exports) {
116 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
117 }
118
119 function __values(o) {
120 var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
121 if (m) return m.call(o);
122 return {
123 next: function () {
124 if (o && i >= o.length) o = void 0;
125 return { value: o && o[i++], done: !o };
126 }
127 };
128 }
129
130 function __read(o, n) {
131 var m = typeof Symbol === "function" && o[Symbol.iterator];
132 if (!m) return o;
133 var i = m.call(o), r, ar = [], e;
134 try {
135 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
136 }
137 catch (error) { e = { error: error }; }
138 finally {
139 try {
140 if (r && !r.done && (m = i["return"])) m.call(i);
141 }
142 finally { if (e) throw e.error; }
143 }
144 return ar;
145 }
146
147 function __spread() {
148 for (var ar = [], i = 0; i < arguments.length; i++)
149 ar = ar.concat(__read(arguments[i]));
150 return ar;
151 }
152
153 function __await(v) {
154 return this instanceof __await ? (this.v = v, this) : new __await(v);
155 }
156
157 function __asyncGenerator(thisArg, _arguments, generator) {
158 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
159 var g = generator.apply(thisArg, _arguments || []), i, q = [];
160 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
161 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); }); }; }
162 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
163 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
164 function fulfill(value) { resume("next", value); }
165 function reject(value) { resume("throw", value); }
166 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
167 }
168
169 function __asyncDelegator(o) {
170 var i, p;
171 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
172 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; }
173 }
174
175 function __asyncValues(o) {
176 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
177 var m = o[Symbol.asyncIterator], i;
178 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);
179 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); }); }; }
180 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
181 }
182
183 function __makeTemplateObject(cooked, raw) {
184 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
185 return cooked;
186 };
187
188 function __importStar(mod) {
189 if (mod && mod.__esModule) return mod;
190 var result = {};
191 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
192 result.default = mod;
193 return result;
194 }
195
196 function __importDefault(mod) {
197 return (mod && mod.__esModule) ? mod : { default: mod };
198 }
199
200 /**
201 * @license
202 * Copyright Google Inc. All Rights Reserved.
203 *
204 * Use of this source code is governed by an MIT-style license that can be
205 * found in the LICENSE file at https://angular.io/license
206 */
207 var browserDetection;
208 var BrowserDetection = /** @class */ (function () {
209 function BrowserDetection(ua) {
210 this._overrideUa = ua;
211 }
212 Object.defineProperty(BrowserDetection.prototype, "_ua", {
213 get: function () {
214 if (typeof this._overrideUa === 'string') {
215 return this._overrideUa;
216 }
217 return platformBrowser.ɵgetDOM() ? platformBrowser.ɵgetDOM().getUserAgent() : '';
218 },
219 enumerable: true,
220 configurable: true
221 });
222 BrowserDetection.setup = function () { browserDetection = new BrowserDetection(null); };
223 Object.defineProperty(BrowserDetection.prototype, "isFirefox", {
224 get: function () { return this._ua.indexOf('Firefox') > -1; },
225 enumerable: true,
226 configurable: true
227 });
228 Object.defineProperty(BrowserDetection.prototype, "isAndroid", {
229 get: function () {
230 return this._ua.indexOf('Mozilla/5.0') > -1 && this._ua.indexOf('Android') > -1 &&
231 this._ua.indexOf('AppleWebKit') > -1 && this._ua.indexOf('Chrome') == -1 &&
232 this._ua.indexOf('IEMobile') == -1;
233 },
234 enumerable: true,
235 configurable: true
236 });
237 Object.defineProperty(BrowserDetection.prototype, "isEdge", {
238 get: function () { return this._ua.indexOf('Edge') > -1; },
239 enumerable: true,
240 configurable: true
241 });
242 Object.defineProperty(BrowserDetection.prototype, "isIE", {
243 get: function () { return this._ua.indexOf('Trident') > -1; },
244 enumerable: true,
245 configurable: true
246 });
247 Object.defineProperty(BrowserDetection.prototype, "isWebkit", {
248 get: function () {
249 return this._ua.indexOf('AppleWebKit') > -1 && this._ua.indexOf('Edge') == -1 &&
250 this._ua.indexOf('IEMobile') == -1;
251 },
252 enumerable: true,
253 configurable: true
254 });
255 Object.defineProperty(BrowserDetection.prototype, "isIOS7", {
256 get: function () {
257 return (this._ua.indexOf('iPhone OS 7') > -1 || this._ua.indexOf('iPad OS 7') > -1) &&
258 this._ua.indexOf('IEMobile') == -1;
259 },
260 enumerable: true,
261 configurable: true
262 });
263 Object.defineProperty(BrowserDetection.prototype, "isSlow", {
264 get: function () { return this.isAndroid || this.isIE || this.isIOS7; },
265 enumerable: true,
266 configurable: true
267 });
268 Object.defineProperty(BrowserDetection.prototype, "supportsNativeIntlApi", {
269 // The Intl API is only natively supported in Chrome, Firefox, IE11 and Edge.
270 // This detector is needed in tests to make the difference between:
271 // 1) IE11/Edge: they have a native Intl API, but with some discrepancies
272 // 2) IE9/IE10: they use the polyfill, and so no discrepancies
273 get: function () {
274 return !!core.ɵglobal.Intl && core.ɵglobal.Intl !== core.ɵglobal.IntlPolyfill;
275 },
276 enumerable: true,
277 configurable: true
278 });
279 Object.defineProperty(BrowserDetection.prototype, "isChromeDesktop", {
280 get: function () {
281 return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Mobile Safari') == -1 &&
282 this._ua.indexOf('Edge') == -1;
283 },
284 enumerable: true,
285 configurable: true
286 });
287 Object.defineProperty(BrowserDetection.prototype, "isOldChrome", {
288 // "Old Chrome" means Chrome 3X, where there are some discrepancies in the Intl API.
289 // Android 4.4 and 5.X have such browsers by default (respectively 30 and 39).
290 get: function () {
291 return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Chrome/3') > -1 &&
292 this._ua.indexOf('Edge') == -1;
293 },
294 enumerable: true,
295 configurable: true
296 });
297 Object.defineProperty(BrowserDetection.prototype, "supportsCustomElements", {
298 get: function () { return (typeof core.ɵglobal.customElements !== 'undefined'); },
299 enumerable: true,
300 configurable: true
301 });
302 Object.defineProperty(BrowserDetection.prototype, "supportsDeprecatedCustomCustomElementsV0", {
303 get: function () {
304 return (typeof document.registerElement !== 'undefined');
305 },
306 enumerable: true,
307 configurable: true
308 });
309 Object.defineProperty(BrowserDetection.prototype, "supportsRegExUnicodeFlag", {
310 get: function () { return RegExp.prototype.hasOwnProperty('unicode'); },
311 enumerable: true,
312 configurable: true
313 });
314 Object.defineProperty(BrowserDetection.prototype, "supportsShadowDom", {
315 get: function () {
316 var testEl = document.createElement('div');
317 return (typeof testEl.attachShadow !== 'undefined');
318 },
319 enumerable: true,
320 configurable: true
321 });
322 Object.defineProperty(BrowserDetection.prototype, "supportsDeprecatedShadowDomV0", {
323 get: function () {
324 var testEl = document.createElement('div');
325 return (typeof testEl.createShadowRoot !== 'undefined');
326 },
327 enumerable: true,
328 configurable: true
329 });
330 return BrowserDetection;
331 }());
332 BrowserDetection.setup();
333 function dispatchEvent(element, eventType) {
334 platformBrowser.ɵgetDOM().dispatchEvent(element, platformBrowser.ɵgetDOM().createEvent(eventType));
335 }
336 function el(html) {
337 return platformBrowser.ɵgetDOM().firstChild(platformBrowser.ɵgetDOM().content(platformBrowser.ɵgetDOM().createTemplate(html)));
338 }
339 function normalizeCSS(css) {
340 return css.replace(/\s+/g, ' ')
341 .replace(/:\s/g, ':')
342 .replace(/'/g, '"')
343 .replace(/ }/g, '}')
344 .replace(/url\((\"|\s)(.+)(\"|\s)\)(\s*)/g, function () {
345 var match = [];
346 for (var _i = 0; _i < arguments.length; _i++) {
347 match[_i] = arguments[_i];
348 }
349 return "url(\"" + match[2] + "\")";
350 })
351 .replace(/\[(.+)=([^"\]]+)\]/g, function () {
352 var match = [];
353 for (var _i = 0; _i < arguments.length; _i++) {
354 match[_i] = arguments[_i];
355 }
356 return "[" + match[1] + "=\"" + match[2] + "\"]";
357 });
358 }
359 var _selfClosingTags = ['br', 'hr', 'input'];
360 function stringifyElement(el /** TODO #9100 */) {
361 var e_1, _a;
362 var result = '';
363 if (platformBrowser.ɵgetDOM().isElementNode(el)) {
364 var tagName = platformBrowser.ɵgetDOM().tagName(el).toLowerCase();
365 // Opening tag
366 result += "<" + tagName;
367 // Attributes in an ordered way
368 var attributeMap = platformBrowser.ɵgetDOM().attributeMap(el);
369 var sortedKeys = Array.from(attributeMap.keys()).sort();
370 try {
371 for (var sortedKeys_1 = __values(sortedKeys), sortedKeys_1_1 = sortedKeys_1.next(); !sortedKeys_1_1.done; sortedKeys_1_1 = sortedKeys_1.next()) {
372 var key = sortedKeys_1_1.value;
373 var lowerCaseKey = key.toLowerCase();
374 var attValue = attributeMap.get(key);
375 if (typeof attValue !== 'string') {
376 result += " " + lowerCaseKey;
377 }
378 else {
379 // Browsers order style rules differently. Order them alphabetically for consistency.
380 if (lowerCaseKey === 'style') {
381 attValue = attValue.split(/; ?/).filter(function (s) { return !!s; }).sort().map(function (s) { return s + ";"; }).join(' ');
382 }
383 result += " " + lowerCaseKey + "=\"" + attValue + "\"";
384 }
385 }
386 }
387 catch (e_1_1) { e_1 = { error: e_1_1 }; }
388 finally {
389 try {
390 if (sortedKeys_1_1 && !sortedKeys_1_1.done && (_a = sortedKeys_1.return)) _a.call(sortedKeys_1);
391 }
392 finally { if (e_1) throw e_1.error; }
393 }
394 result += '>';
395 // Children
396 var childrenRoot = platformBrowser.ɵgetDOM().templateAwareRoot(el);
397 var children = childrenRoot ? platformBrowser.ɵgetDOM().childNodes(childrenRoot) : [];
398 for (var j = 0; j < children.length; j++) {
399 result += stringifyElement(children[j]);
400 }
401 // Closing tag
402 if (_selfClosingTags.indexOf(tagName) == -1) {
403 result += "</" + tagName + ">";
404 }
405 }
406 else if (platformBrowser.ɵgetDOM().isCommentNode(el)) {
407 result += "<!--" + platformBrowser.ɵgetDOM().nodeValue(el) + "-->";
408 }
409 else {
410 result += platformBrowser.ɵgetDOM().getText(el);
411 }
412 return result;
413 }
414 function createNgZone() {
415 return new core.NgZone({ enableLongStackTrace: true });
416 }
417
418 function initBrowserTests() {
419 platformBrowser.ɵBrowserDomAdapter.makeCurrent();
420 BrowserDetection.setup();
421 }
422 var _TEST_BROWSER_PLATFORM_PROVIDERS = [{ provide: core.PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true }];
423 /**
424 * Platform for testing
425 *
426 * @publicApi
427 */
428 var platformBrowserTesting = core.createPlatformFactory(core.platformCore, 'browserTesting', _TEST_BROWSER_PLATFORM_PROVIDERS);
429 var ɵ0 = createNgZone;
430 /**
431 * NgModule for testing.
432 *
433 * @publicApi
434 */
435 var BrowserTestingModule = /** @class */ (function () {
436 function BrowserTestingModule() {
437 }
438 BrowserTestingModule = __decorate([
439 core.NgModule({
440 exports: [platformBrowser.BrowserModule],
441 providers: [
442 { provide: core.APP_ID, useValue: 'a' },
443 platformBrowser.ɵELEMENT_PROBE_PROVIDERS,
444 { provide: core.NgZone, useFactory: ɵ0 },
445 ]
446 })
447 ], BrowserTestingModule);
448 return BrowserTestingModule;
449 }());
450
451 /**
452 * @license
453 * Copyright Google Inc. All Rights Reserved.
454 *
455 * Use of this source code is governed by an MIT-style license that can be
456 * found in the LICENSE file at https://angular.io/license
457 */
458
459 /**
460 * @license
461 * Copyright Google Inc. All Rights Reserved.
462 *
463 * Use of this source code is governed by an MIT-style license that can be
464 * found in the LICENSE file at https://angular.io/license
465 */
466
467 /**
468 * @license
469 * Copyright Google Inc. All Rights Reserved.
470 *
471 * Use of this source code is governed by an MIT-style license that can be
472 * found in the LICENSE file at https://angular.io/license
473 */
474
475 /**
476 * Generated bundle index. Do not edit.
477 */
478
479 exports.ɵangular_packages_platform_browser_testing_testing_a = createNgZone;
480 exports.platformBrowserTesting = platformBrowserTesting;
481 exports.BrowserTestingModule = BrowserTestingModule;
482 exports.ɵ0 = ɵ0;
483
484 Object.defineProperty(exports, '__esModule', { value: true });
485
486}));
487//# sourceMappingURL=platform-browser-testing.umd.js.map