[6a3a178] | 1 | /**
|
---|
| 2 | * @license Angular v12.2.9
|
---|
| 3 | * (c) 2010-2021 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/compiler')) :
|
---|
| 9 | typeof define === 'function' && define.amd ? define('@angular/compiler/testing', ['exports', '@angular/compiler'], factory) :
|
---|
| 10 | (global = global || self, factory((global.ng = global.ng || {}, global.ng.compiler = global.ng.compiler || {}, global.ng.compiler.testing = {}), global.ng.compiler));
|
---|
| 11 | }(this, (function (exports, compiler) { 'use strict';
|
---|
| 12 |
|
---|
| 13 | /*! *****************************************************************************
|
---|
| 14 | Copyright (c) Microsoft Corporation.
|
---|
| 15 |
|
---|
| 16 | Permission to use, copy, modify, and/or distribute this software for any
|
---|
| 17 | purpose with or without fee is hereby granted.
|
---|
| 18 |
|
---|
| 19 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
---|
| 20 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
---|
| 21 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
---|
| 22 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
---|
| 23 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
---|
| 24 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
---|
| 25 | PERFORMANCE OF THIS SOFTWARE.
|
---|
| 26 | ***************************************************************************** */
|
---|
| 27 | /* global Reflect, Promise */
|
---|
| 28 | var extendStatics = function (d, b) {
|
---|
| 29 | extendStatics = Object.setPrototypeOf ||
|
---|
| 30 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
---|
| 31 | function (d, b) { for (var p in b)
|
---|
| 32 | if (Object.prototype.hasOwnProperty.call(b, p))
|
---|
| 33 | d[p] = b[p]; };
|
---|
| 34 | return extendStatics(d, b);
|
---|
| 35 | };
|
---|
| 36 | function __extends(d, b) {
|
---|
| 37 | if (typeof b !== "function" && b !== null)
|
---|
| 38 | throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
---|
| 39 | extendStatics(d, b);
|
---|
| 40 | function __() { this.constructor = d; }
|
---|
| 41 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
---|
| 42 | }
|
---|
| 43 | var __assign = function () {
|
---|
| 44 | __assign = Object.assign || function __assign(t) {
|
---|
| 45 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
---|
| 46 | s = arguments[i];
|
---|
| 47 | for (var p in s)
|
---|
| 48 | if (Object.prototype.hasOwnProperty.call(s, p))
|
---|
| 49 | t[p] = s[p];
|
---|
| 50 | }
|
---|
| 51 | return t;
|
---|
| 52 | };
|
---|
| 53 | return __assign.apply(this, arguments);
|
---|
| 54 | };
|
---|
| 55 | function __rest(s, e) {
|
---|
| 56 | var t = {};
|
---|
| 57 | for (var p in s)
|
---|
| 58 | if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
---|
| 59 | t[p] = s[p];
|
---|
| 60 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
---|
| 61 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
---|
| 62 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
---|
| 63 | t[p[i]] = s[p[i]];
|
---|
| 64 | }
|
---|
| 65 | return t;
|
---|
| 66 | }
|
---|
| 67 | function __decorate(decorators, target, key, desc) {
|
---|
| 68 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
---|
| 69 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
---|
| 70 | r = Reflect.decorate(decorators, target, key, desc);
|
---|
| 71 | else
|
---|
| 72 | for (var i = decorators.length - 1; i >= 0; i--)
|
---|
| 73 | if (d = decorators[i])
|
---|
| 74 | r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
---|
| 75 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
---|
| 76 | }
|
---|
| 77 | function __param(paramIndex, decorator) {
|
---|
| 78 | return function (target, key) { decorator(target, key, paramIndex); };
|
---|
| 79 | }
|
---|
| 80 | function __metadata(metadataKey, metadataValue) {
|
---|
| 81 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
---|
| 82 | return Reflect.metadata(metadataKey, metadataValue);
|
---|
| 83 | }
|
---|
| 84 | function __awaiter(thisArg, _arguments, P, generator) {
|
---|
| 85 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
---|
| 86 | return new (P || (P = Promise))(function (resolve, reject) {
|
---|
| 87 | function fulfilled(value) { try {
|
---|
| 88 | step(generator.next(value));
|
---|
| 89 | }
|
---|
| 90 | catch (e) {
|
---|
| 91 | reject(e);
|
---|
| 92 | } }
|
---|
| 93 | function rejected(value) { try {
|
---|
| 94 | step(generator["throw"](value));
|
---|
| 95 | }
|
---|
| 96 | catch (e) {
|
---|
| 97 | reject(e);
|
---|
| 98 | } }
|
---|
| 99 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
---|
| 100 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
---|
| 101 | });
|
---|
| 102 | }
|
---|
| 103 | function __generator(thisArg, body) {
|
---|
| 104 | var _ = { label: 0, sent: function () { if (t[0] & 1)
|
---|
| 105 | throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
---|
| 106 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
---|
| 107 | function verb(n) { return function (v) { return step([n, v]); }; }
|
---|
| 108 | function step(op) {
|
---|
| 109 | if (f)
|
---|
| 110 | throw new TypeError("Generator is already executing.");
|
---|
| 111 | while (_)
|
---|
| 112 | try {
|
---|
| 113 | 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)
|
---|
| 114 | return t;
|
---|
| 115 | if (y = 0, t)
|
---|
| 116 | op = [op[0] & 2, t.value];
|
---|
| 117 | switch (op[0]) {
|
---|
| 118 | case 0:
|
---|
| 119 | case 1:
|
---|
| 120 | t = op;
|
---|
| 121 | break;
|
---|
| 122 | case 4:
|
---|
| 123 | _.label++;
|
---|
| 124 | return { value: op[1], done: false };
|
---|
| 125 | case 5:
|
---|
| 126 | _.label++;
|
---|
| 127 | y = op[1];
|
---|
| 128 | op = [0];
|
---|
| 129 | continue;
|
---|
| 130 | case 7:
|
---|
| 131 | op = _.ops.pop();
|
---|
| 132 | _.trys.pop();
|
---|
| 133 | continue;
|
---|
| 134 | default:
|
---|
| 135 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
---|
| 136 | _ = 0;
|
---|
| 137 | continue;
|
---|
| 138 | }
|
---|
| 139 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
---|
| 140 | _.label = op[1];
|
---|
| 141 | break;
|
---|
| 142 | }
|
---|
| 143 | if (op[0] === 6 && _.label < t[1]) {
|
---|
| 144 | _.label = t[1];
|
---|
| 145 | t = op;
|
---|
| 146 | break;
|
---|
| 147 | }
|
---|
| 148 | if (t && _.label < t[2]) {
|
---|
| 149 | _.label = t[2];
|
---|
| 150 | _.ops.push(op);
|
---|
| 151 | break;
|
---|
| 152 | }
|
---|
| 153 | if (t[2])
|
---|
| 154 | _.ops.pop();
|
---|
| 155 | _.trys.pop();
|
---|
| 156 | continue;
|
---|
| 157 | }
|
---|
| 158 | op = body.call(thisArg, _);
|
---|
| 159 | }
|
---|
| 160 | catch (e) {
|
---|
| 161 | op = [6, e];
|
---|
| 162 | y = 0;
|
---|
| 163 | }
|
---|
| 164 | finally {
|
---|
| 165 | f = t = 0;
|
---|
| 166 | }
|
---|
| 167 | if (op[0] & 5)
|
---|
| 168 | throw op[1];
|
---|
| 169 | return { value: op[0] ? op[1] : void 0, done: true };
|
---|
| 170 | }
|
---|
| 171 | }
|
---|
| 172 | var __createBinding = Object.create ? (function (o, m, k, k2) {
|
---|
| 173 | if (k2 === undefined)
|
---|
| 174 | k2 = k;
|
---|
| 175 | Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
---|
| 176 | }) : (function (o, m, k, k2) {
|
---|
| 177 | if (k2 === undefined)
|
---|
| 178 | k2 = k;
|
---|
| 179 | o[k2] = m[k];
|
---|
| 180 | });
|
---|
| 181 | function __exportStar(m, o) {
|
---|
| 182 | for (var p in m)
|
---|
| 183 | if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
---|
| 184 | __createBinding(o, m, p);
|
---|
| 185 | }
|
---|
| 186 | function __values(o) {
|
---|
| 187 | var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
---|
| 188 | if (m)
|
---|
| 189 | return m.call(o);
|
---|
| 190 | if (o && typeof o.length === "number")
|
---|
| 191 | return {
|
---|
| 192 | next: function () {
|
---|
| 193 | if (o && i >= o.length)
|
---|
| 194 | o = void 0;
|
---|
| 195 | return { value: o && o[i++], done: !o };
|
---|
| 196 | }
|
---|
| 197 | };
|
---|
| 198 | throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
---|
| 199 | }
|
---|
| 200 | function __read(o, n) {
|
---|
| 201 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
---|
| 202 | if (!m)
|
---|
| 203 | return o;
|
---|
| 204 | var i = m.call(o), r, ar = [], e;
|
---|
| 205 | try {
|
---|
| 206 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
---|
| 207 | ar.push(r.value);
|
---|
| 208 | }
|
---|
| 209 | catch (error) {
|
---|
| 210 | e = { error: error };
|
---|
| 211 | }
|
---|
| 212 | finally {
|
---|
| 213 | try {
|
---|
| 214 | if (r && !r.done && (m = i["return"]))
|
---|
| 215 | m.call(i);
|
---|
| 216 | }
|
---|
| 217 | finally {
|
---|
| 218 | if (e)
|
---|
| 219 | throw e.error;
|
---|
| 220 | }
|
---|
| 221 | }
|
---|
| 222 | return ar;
|
---|
| 223 | }
|
---|
| 224 | /** @deprecated */
|
---|
| 225 | function __spread() {
|
---|
| 226 | for (var ar = [], i = 0; i < arguments.length; i++)
|
---|
| 227 | ar = ar.concat(__read(arguments[i]));
|
---|
| 228 | return ar;
|
---|
| 229 | }
|
---|
| 230 | /** @deprecated */
|
---|
| 231 | function __spreadArrays() {
|
---|
| 232 | for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
---|
| 233 | s += arguments[i].length;
|
---|
| 234 | for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
---|
| 235 | for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
---|
| 236 | r[k] = a[j];
|
---|
| 237 | return r;
|
---|
| 238 | }
|
---|
| 239 | function __spreadArray(to, from, pack) {
|
---|
| 240 | if (pack || arguments.length === 2)
|
---|
| 241 | for (var i = 0, l = from.length, ar; i < l; i++) {
|
---|
| 242 | if (ar || !(i in from)) {
|
---|
| 243 | if (!ar)
|
---|
| 244 | ar = Array.prototype.slice.call(from, 0, i);
|
---|
| 245 | ar[i] = from[i];
|
---|
| 246 | }
|
---|
| 247 | }
|
---|
| 248 | return to.concat(ar || Array.prototype.slice.call(from));
|
---|
| 249 | }
|
---|
| 250 | function __await(v) {
|
---|
| 251 | return this instanceof __await ? (this.v = v, this) : new __await(v);
|
---|
| 252 | }
|
---|
| 253 | function __asyncGenerator(thisArg, _arguments, generator) {
|
---|
| 254 | if (!Symbol.asyncIterator)
|
---|
| 255 | throw new TypeError("Symbol.asyncIterator is not defined.");
|
---|
| 256 | var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
---|
| 257 | return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
---|
| 258 | function verb(n) { if (g[n])
|
---|
| 259 | i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
---|
| 260 | function resume(n, v) { try {
|
---|
| 261 | step(g[n](v));
|
---|
| 262 | }
|
---|
| 263 | catch (e) {
|
---|
| 264 | settle(q[0][3], e);
|
---|
| 265 | } }
|
---|
| 266 | function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
---|
| 267 | function fulfill(value) { resume("next", value); }
|
---|
| 268 | function reject(value) { resume("throw", value); }
|
---|
| 269 | function settle(f, v) { if (f(v), q.shift(), q.length)
|
---|
| 270 | resume(q[0][0], q[0][1]); }
|
---|
| 271 | }
|
---|
| 272 | function __asyncDelegator(o) {
|
---|
| 273 | var i, p;
|
---|
| 274 | return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
---|
| 275 | 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; }
|
---|
| 276 | }
|
---|
| 277 | function __asyncValues(o) {
|
---|
| 278 | if (!Symbol.asyncIterator)
|
---|
| 279 | throw new TypeError("Symbol.asyncIterator is not defined.");
|
---|
| 280 | var m = o[Symbol.asyncIterator], i;
|
---|
| 281 | 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);
|
---|
| 282 | 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); }); }; }
|
---|
| 283 | function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
---|
| 284 | }
|
---|
| 285 | function __makeTemplateObject(cooked, raw) {
|
---|
| 286 | if (Object.defineProperty) {
|
---|
| 287 | Object.defineProperty(cooked, "raw", { value: raw });
|
---|
| 288 | }
|
---|
| 289 | else {
|
---|
| 290 | cooked.raw = raw;
|
---|
| 291 | }
|
---|
| 292 | return cooked;
|
---|
| 293 | }
|
---|
| 294 | ;
|
---|
| 295 | var __setModuleDefault = Object.create ? (function (o, v) {
|
---|
| 296 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
---|
| 297 | }) : function (o, v) {
|
---|
| 298 | o["default"] = v;
|
---|
| 299 | };
|
---|
| 300 | function __importStar(mod) {
|
---|
| 301 | if (mod && mod.__esModule)
|
---|
| 302 | return mod;
|
---|
| 303 | var result = {};
|
---|
| 304 | if (mod != null)
|
---|
| 305 | for (var k in mod)
|
---|
| 306 | if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
---|
| 307 | __createBinding(result, mod, k);
|
---|
| 308 | __setModuleDefault(result, mod);
|
---|
| 309 | return result;
|
---|
| 310 | }
|
---|
| 311 | function __importDefault(mod) {
|
---|
| 312 | return (mod && mod.__esModule) ? mod : { default: mod };
|
---|
| 313 | }
|
---|
| 314 | function __classPrivateFieldGet(receiver, state, kind, f) {
|
---|
| 315 | if (kind === "a" && !f)
|
---|
| 316 | throw new TypeError("Private accessor was defined without a getter");
|
---|
| 317 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
---|
| 318 | throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
---|
| 319 | return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
---|
| 320 | }
|
---|
| 321 | function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
---|
| 322 | if (kind === "m")
|
---|
| 323 | throw new TypeError("Private method is not writable");
|
---|
| 324 | if (kind === "a" && !f)
|
---|
| 325 | throw new TypeError("Private accessor was defined without a setter");
|
---|
| 326 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
---|
| 327 | throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
---|
| 328 | return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
---|
| 329 | }
|
---|
| 330 |
|
---|
| 331 | /**
|
---|
| 332 | * A mock implementation of {@link ResourceLoader} that allows outgoing requests to be mocked
|
---|
| 333 | * and responded to within a single test, without going to the network.
|
---|
| 334 | */
|
---|
| 335 | var MockResourceLoader = /** @class */ (function (_super) {
|
---|
| 336 | __extends(MockResourceLoader, _super);
|
---|
| 337 | function MockResourceLoader() {
|
---|
| 338 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
---|
| 339 | _this._expectations = [];
|
---|
| 340 | _this._definitions = new Map();
|
---|
| 341 | _this._requests = [];
|
---|
| 342 | return _this;
|
---|
| 343 | }
|
---|
| 344 | MockResourceLoader.prototype.get = function (url) {
|
---|
| 345 | var request = new _PendingRequest(url);
|
---|
| 346 | this._requests.push(request);
|
---|
| 347 | return request.getPromise();
|
---|
| 348 | };
|
---|
| 349 | MockResourceLoader.prototype.hasPendingRequests = function () {
|
---|
| 350 | return !!this._requests.length;
|
---|
| 351 | };
|
---|
| 352 | /**
|
---|
| 353 | * Add an expectation for the given URL. Incoming requests will be checked against
|
---|
| 354 | * the next expectation (in FIFO order). The `verifyNoOutstandingExpectations` method
|
---|
| 355 | * can be used to check if any expectations have not yet been met.
|
---|
| 356 | *
|
---|
| 357 | * The response given will be returned if the expectation matches.
|
---|
| 358 | */
|
---|
| 359 | MockResourceLoader.prototype.expect = function (url, response) {
|
---|
| 360 | var expectation = new _Expectation(url, response);
|
---|
| 361 | this._expectations.push(expectation);
|
---|
| 362 | };
|
---|
| 363 | /**
|
---|
| 364 | * Add a definition for the given URL to return the given response. Unlike expectations,
|
---|
| 365 | * definitions have no order and will satisfy any matching request at any time. Also
|
---|
| 366 | * unlike expectations, unused definitions do not cause `verifyNoOutstandingExpectations`
|
---|
| 367 | * to return an error.
|
---|
| 368 | */
|
---|
| 369 | MockResourceLoader.prototype.when = function (url, response) {
|
---|
| 370 | this._definitions.set(url, response);
|
---|
| 371 | };
|
---|
| 372 | /**
|
---|
| 373 | * Process pending requests and verify there are no outstanding expectations. Also fails
|
---|
| 374 | * if no requests are pending.
|
---|
| 375 | */
|
---|
| 376 | MockResourceLoader.prototype.flush = function () {
|
---|
| 377 | if (this._requests.length === 0) {
|
---|
| 378 | throw new Error('No pending requests to flush');
|
---|
| 379 | }
|
---|
| 380 | do {
|
---|
| 381 | this._processRequest(this._requests.shift());
|
---|
| 382 | } while (this._requests.length > 0);
|
---|
| 383 | this.verifyNoOutstandingExpectations();
|
---|
| 384 | };
|
---|
| 385 | /**
|
---|
| 386 | * Throw an exception if any expectations have not been satisfied.
|
---|
| 387 | */
|
---|
| 388 | MockResourceLoader.prototype.verifyNoOutstandingExpectations = function () {
|
---|
| 389 | if (this._expectations.length === 0)
|
---|
| 390 | return;
|
---|
| 391 | var urls = [];
|
---|
| 392 | for (var i = 0; i < this._expectations.length; i++) {
|
---|
| 393 | var expectation = this._expectations[i];
|
---|
| 394 | urls.push(expectation.url);
|
---|
| 395 | }
|
---|
| 396 | throw new Error("Unsatisfied requests: " + urls.join(', '));
|
---|
| 397 | };
|
---|
| 398 | MockResourceLoader.prototype._processRequest = function (request) {
|
---|
| 399 | var url = request.url;
|
---|
| 400 | if (this._expectations.length > 0) {
|
---|
| 401 | var expectation = this._expectations[0];
|
---|
| 402 | if (expectation.url == url) {
|
---|
| 403 | remove(this._expectations, expectation);
|
---|
| 404 | request.complete(expectation.response);
|
---|
| 405 | return;
|
---|
| 406 | }
|
---|
| 407 | }
|
---|
| 408 | if (this._definitions.has(url)) {
|
---|
| 409 | var response = this._definitions.get(url);
|
---|
| 410 | request.complete(response == null ? null : response);
|
---|
| 411 | return;
|
---|
| 412 | }
|
---|
| 413 | throw new Error("Unexpected request " + url);
|
---|
| 414 | };
|
---|
| 415 | return MockResourceLoader;
|
---|
| 416 | }(compiler.ResourceLoader));
|
---|
| 417 | var _PendingRequest = /** @class */ (function () {
|
---|
| 418 | function _PendingRequest(url) {
|
---|
| 419 | var _this = this;
|
---|
| 420 | this.url = url;
|
---|
| 421 | this.promise = new Promise(function (res, rej) {
|
---|
| 422 | _this.resolve = res;
|
---|
| 423 | _this.reject = rej;
|
---|
| 424 | });
|
---|
| 425 | }
|
---|
| 426 | _PendingRequest.prototype.complete = function (response) {
|
---|
| 427 | if (response == null) {
|
---|
| 428 | this.reject("Failed to load " + this.url);
|
---|
| 429 | }
|
---|
| 430 | else {
|
---|
| 431 | this.resolve(response);
|
---|
| 432 | }
|
---|
| 433 | };
|
---|
| 434 | _PendingRequest.prototype.getPromise = function () {
|
---|
| 435 | return this.promise;
|
---|
| 436 | };
|
---|
| 437 | return _PendingRequest;
|
---|
| 438 | }());
|
---|
| 439 | var _Expectation = /** @class */ (function () {
|
---|
| 440 | function _Expectation(url, response) {
|
---|
| 441 | this.url = url;
|
---|
| 442 | this.response = response;
|
---|
| 443 | }
|
---|
| 444 | return _Expectation;
|
---|
| 445 | }());
|
---|
| 446 | function remove(list, el) {
|
---|
| 447 | var index = list.indexOf(el);
|
---|
| 448 | if (index > -1) {
|
---|
| 449 | list.splice(index, 1);
|
---|
| 450 | }
|
---|
| 451 | }
|
---|
| 452 |
|
---|
| 453 | /**
|
---|
| 454 | * @license
|
---|
| 455 | * Copyright Google LLC All Rights Reserved.
|
---|
| 456 | *
|
---|
| 457 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 458 | * found in the LICENSE file at https://angular.io/license
|
---|
| 459 | */
|
---|
| 460 | var MockSchemaRegistry = /** @class */ (function () {
|
---|
| 461 | function MockSchemaRegistry(existingProperties, attrPropMapping, existingElements, invalidProperties, invalidAttributes) {
|
---|
| 462 | this.existingProperties = existingProperties;
|
---|
| 463 | this.attrPropMapping = attrPropMapping;
|
---|
| 464 | this.existingElements = existingElements;
|
---|
| 465 | this.invalidProperties = invalidProperties;
|
---|
| 466 | this.invalidAttributes = invalidAttributes;
|
---|
| 467 | }
|
---|
| 468 | MockSchemaRegistry.prototype.hasProperty = function (tagName, property, schemas) {
|
---|
| 469 | var value = this.existingProperties[property];
|
---|
| 470 | return value === void 0 ? true : value;
|
---|
| 471 | };
|
---|
| 472 | MockSchemaRegistry.prototype.hasElement = function (tagName, schemaMetas) {
|
---|
| 473 | var value = this.existingElements[tagName.toLowerCase()];
|
---|
| 474 | return value === void 0 ? true : value;
|
---|
| 475 | };
|
---|
| 476 | MockSchemaRegistry.prototype.allKnownElementNames = function () {
|
---|
| 477 | return Object.keys(this.existingElements);
|
---|
| 478 | };
|
---|
| 479 | MockSchemaRegistry.prototype.securityContext = function (selector, property, isAttribute) {
|
---|
| 480 | return compiler.core.SecurityContext.NONE;
|
---|
| 481 | };
|
---|
| 482 | MockSchemaRegistry.prototype.getMappedPropName = function (attrName) {
|
---|
| 483 | return this.attrPropMapping[attrName] || attrName;
|
---|
| 484 | };
|
---|
| 485 | MockSchemaRegistry.prototype.getDefaultComponentElementName = function () {
|
---|
| 486 | return 'ng-component';
|
---|
| 487 | };
|
---|
| 488 | MockSchemaRegistry.prototype.validateProperty = function (name) {
|
---|
| 489 | if (this.invalidProperties.indexOf(name) > -1) {
|
---|
| 490 | return { error: true, msg: "Binding to property '" + name + "' is disallowed for security reasons" };
|
---|
| 491 | }
|
---|
| 492 | else {
|
---|
| 493 | return { error: false };
|
---|
| 494 | }
|
---|
| 495 | };
|
---|
| 496 | MockSchemaRegistry.prototype.validateAttribute = function (name) {
|
---|
| 497 | if (this.invalidAttributes.indexOf(name) > -1) {
|
---|
| 498 | return {
|
---|
| 499 | error: true,
|
---|
| 500 | msg: "Binding to attribute '" + name + "' is disallowed for security reasons"
|
---|
| 501 | };
|
---|
| 502 | }
|
---|
| 503 | else {
|
---|
| 504 | return { error: false };
|
---|
| 505 | }
|
---|
| 506 | };
|
---|
| 507 | MockSchemaRegistry.prototype.normalizeAnimationStyleProperty = function (propName) {
|
---|
| 508 | return propName;
|
---|
| 509 | };
|
---|
| 510 | MockSchemaRegistry.prototype.normalizeAnimationStyleValue = function (camelCaseProp, userProvidedProp, val) {
|
---|
| 511 | return { error: null, value: val.toString() };
|
---|
| 512 | };
|
---|
| 513 | return MockSchemaRegistry;
|
---|
| 514 | }());
|
---|
| 515 |
|
---|
| 516 | /**
|
---|
| 517 | * An implementation of {@link DirectiveResolver} that allows overriding
|
---|
| 518 | * various properties of directives.
|
---|
| 519 | */
|
---|
| 520 | var MockDirectiveResolver = /** @class */ (function (_super) {
|
---|
| 521 | __extends(MockDirectiveResolver, _super);
|
---|
| 522 | function MockDirectiveResolver(reflector) {
|
---|
| 523 | var _this = _super.call(this, reflector) || this;
|
---|
| 524 | _this._directives = new Map();
|
---|
| 525 | return _this;
|
---|
| 526 | }
|
---|
| 527 | MockDirectiveResolver.prototype.resolve = function (type, throwIfNotFound) {
|
---|
| 528 | if (throwIfNotFound === void 0) { throwIfNotFound = true; }
|
---|
| 529 | return this._directives.get(type) || _super.prototype.resolve.call(this, type, throwIfNotFound);
|
---|
| 530 | };
|
---|
| 531 | /**
|
---|
| 532 | * Overrides the {@link core.Directive} for a directive.
|
---|
| 533 | */
|
---|
| 534 | MockDirectiveResolver.prototype.setDirective = function (type, metadata) {
|
---|
| 535 | this._directives.set(type, metadata);
|
---|
| 536 | };
|
---|
| 537 | return MockDirectiveResolver;
|
---|
| 538 | }(compiler.DirectiveResolver));
|
---|
| 539 |
|
---|
| 540 | var MockNgModuleResolver = /** @class */ (function (_super) {
|
---|
| 541 | __extends(MockNgModuleResolver, _super);
|
---|
| 542 | function MockNgModuleResolver(reflector) {
|
---|
| 543 | var _this = _super.call(this, reflector) || this;
|
---|
| 544 | _this._ngModules = new Map();
|
---|
| 545 | return _this;
|
---|
| 546 | }
|
---|
| 547 | /**
|
---|
| 548 | * Overrides the {@link NgModule} for a module.
|
---|
| 549 | */
|
---|
| 550 | MockNgModuleResolver.prototype.setNgModule = function (type, metadata) {
|
---|
| 551 | this._ngModules.set(type, metadata);
|
---|
| 552 | };
|
---|
| 553 | /**
|
---|
| 554 | * Returns the {@link NgModule} for a module:
|
---|
| 555 | * - Set the {@link NgModule} to the overridden view when it exists or fallback to the
|
---|
| 556 | * default
|
---|
| 557 | * `NgModuleResolver`, see `setNgModule`.
|
---|
| 558 | */
|
---|
| 559 | MockNgModuleResolver.prototype.resolve = function (type, throwIfNotFound) {
|
---|
| 560 | if (throwIfNotFound === void 0) { throwIfNotFound = true; }
|
---|
| 561 | return this._ngModules.get(type) || _super.prototype.resolve.call(this, type, throwIfNotFound);
|
---|
| 562 | };
|
---|
| 563 | return MockNgModuleResolver;
|
---|
| 564 | }(compiler.NgModuleResolver));
|
---|
| 565 |
|
---|
| 566 | var MockPipeResolver = /** @class */ (function (_super) {
|
---|
| 567 | __extends(MockPipeResolver, _super);
|
---|
| 568 | function MockPipeResolver(refector) {
|
---|
| 569 | var _this = _super.call(this, refector) || this;
|
---|
| 570 | _this._pipes = new Map();
|
---|
| 571 | return _this;
|
---|
| 572 | }
|
---|
| 573 | /**
|
---|
| 574 | * Overrides the {@link Pipe} for a pipe.
|
---|
| 575 | */
|
---|
| 576 | MockPipeResolver.prototype.setPipe = function (type, metadata) {
|
---|
| 577 | this._pipes.set(type, metadata);
|
---|
| 578 | };
|
---|
| 579 | /**
|
---|
| 580 | * Returns the {@link Pipe} for a pipe:
|
---|
| 581 | * - Set the {@link Pipe} to the overridden view when it exists or fallback to the
|
---|
| 582 | * default
|
---|
| 583 | * `PipeResolver`, see `setPipe`.
|
---|
| 584 | */
|
---|
| 585 | MockPipeResolver.prototype.resolve = function (type, throwIfNotFound) {
|
---|
| 586 | if (throwIfNotFound === void 0) { throwIfNotFound = true; }
|
---|
| 587 | var metadata = this._pipes.get(type);
|
---|
| 588 | if (!metadata) {
|
---|
| 589 | metadata = _super.prototype.resolve.call(this, type, throwIfNotFound);
|
---|
| 590 | }
|
---|
| 591 | return metadata;
|
---|
| 592 | };
|
---|
| 593 | return MockPipeResolver;
|
---|
| 594 | }(compiler.PipeResolver));
|
---|
| 595 |
|
---|
| 596 | /**
|
---|
| 597 | * @license
|
---|
| 598 | * Copyright Google LLC All Rights Reserved.
|
---|
| 599 | *
|
---|
| 600 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 601 | * found in the LICENSE file at https://angular.io/license
|
---|
| 602 | */
|
---|
| 603 |
|
---|
| 604 | /**
|
---|
| 605 | * @license
|
---|
| 606 | * Copyright Google LLC All Rights Reserved.
|
---|
| 607 | *
|
---|
| 608 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 609 | * found in the LICENSE file at https://angular.io/license
|
---|
| 610 | */
|
---|
| 611 | // This file only reexports content of the `src` folder. Keep it that way.
|
---|
| 612 |
|
---|
| 613 | /**
|
---|
| 614 | * @license
|
---|
| 615 | * Copyright Google LLC All Rights Reserved.
|
---|
| 616 | *
|
---|
| 617 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 618 | * found in the LICENSE file at https://angular.io/license
|
---|
| 619 | */
|
---|
| 620 |
|
---|
| 621 | /**
|
---|
| 622 | * Generated bundle index. Do not edit.
|
---|
| 623 | */
|
---|
| 624 |
|
---|
| 625 | exports.MockDirectiveResolver = MockDirectiveResolver;
|
---|
| 626 | exports.MockNgModuleResolver = MockNgModuleResolver;
|
---|
| 627 | exports.MockPipeResolver = MockPipeResolver;
|
---|
| 628 | exports.MockResourceLoader = MockResourceLoader;
|
---|
| 629 | exports.MockSchemaRegistry = MockSchemaRegistry;
|
---|
| 630 |
|
---|
| 631 | Object.defineProperty(exports, '__esModule', { value: true });
|
---|
| 632 |
|
---|
| 633 | })));
|
---|
| 634 | //# sourceMappingURL=compiler-testing.umd.js.map
|
---|