/
compiler-testing.umd.js
executable file
·379 lines (360 loc) · 14.1 KB
/
compiler-testing.umd.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
/**
* @license Angular v6.0.0-rc.5+298.sha-5cbcb56
* (c) 2010-2018 Google, Inc. https://angular.io/
* License: MIT
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/compiler')) :
typeof define === 'function' && define.amd ? define('@angular/compiler/testing', ['exports', '@angular/compiler'], factory) :
(factory((global.ng = global.ng || {}, global.ng.compiler = global.ng.compiler || {}, global.ng.compiler.testing = {}),global.ng.compiler));
}(this, (function (exports,compiler) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
/**
* @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 mock implementation of {@link ResourceLoader} that allows outgoing requests to be mocked
* and responded to within a single test, without going to the network.
*/
var MockResourceLoader = /** @class */ (function (_super) {
__extends(MockResourceLoader, _super);
function MockResourceLoader() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._expectations = [];
_this._definitions = new Map();
_this._requests = [];
return _this;
}
MockResourceLoader.prototype.get = function (url) {
var request = new _PendingRequest(url);
this._requests.push(request);
return request.getPromise();
};
MockResourceLoader.prototype.hasPendingRequests = function () { return !!this._requests.length; };
/**
* Add an expectation for the given URL. Incoming requests will be checked against
* the next expectation (in FIFO order). The `verifyNoOutstandingExpectations` method
* can be used to check if any expectations have not yet been met.
*
* The response given will be returned if the expectation matches.
*/
MockResourceLoader.prototype.expect = function (url, response) {
var expectation = new _Expectation(url, response);
this._expectations.push(expectation);
};
/**
* Add a definition for the given URL to return the given response. Unlike expectations,
* definitions have no order and will satisfy any matching request at any time. Also
* unlike expectations, unused definitions do not cause `verifyNoOutstandingExpectations`
* to return an error.
*/
MockResourceLoader.prototype.when = function (url, response) { this._definitions.set(url, response); };
/**
* Process pending requests and verify there are no outstanding expectations. Also fails
* if no requests are pending.
*/
MockResourceLoader.prototype.flush = function () {
if (this._requests.length === 0) {
throw new Error('No pending requests to flush');
}
do {
this._processRequest(this._requests.shift());
} while (this._requests.length > 0);
this.verifyNoOutstandingExpectations();
};
/**
* Throw an exception if any expectations have not been satisfied.
*/
MockResourceLoader.prototype.verifyNoOutstandingExpectations = function () {
if (this._expectations.length === 0)
return;
var urls = [];
for (var i = 0; i < this._expectations.length; i++) {
var expectation = this._expectations[i];
urls.push(expectation.url);
}
throw new Error("Unsatisfied requests: " + urls.join(', '));
};
MockResourceLoader.prototype._processRequest = function (request) {
var url = request.url;
if (this._expectations.length > 0) {
var expectation = this._expectations[0];
if (expectation.url == url) {
remove(this._expectations, expectation);
request.complete(expectation.response);
return;
}
}
if (this._definitions.has(url)) {
var response = this._definitions.get(url);
request.complete(response == null ? null : response);
return;
}
throw new Error("Unexpected request " + url);
};
return MockResourceLoader;
}(compiler.ResourceLoader));
var _PendingRequest = /** @class */ (function () {
function _PendingRequest(url) {
var _this = this;
this.url = url;
this.promise = new Promise(function (res, rej) {
_this.resolve = res;
_this.reject = rej;
});
}
_PendingRequest.prototype.complete = function (response) {
if (response == null) {
this.reject("Failed to load " + this.url);
}
else {
this.resolve(response);
}
};
_PendingRequest.prototype.getPromise = function () { return this.promise; };
return _PendingRequest;
}());
var _Expectation = /** @class */ (function () {
function _Expectation(url, response) {
this.url = url;
this.response = response;
}
return _Expectation;
}());
function remove(list, el) {
var index = list.indexOf(el);
if (index > -1) {
list.splice(index, 1);
}
}
/**
* @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 MockSchemaRegistry = /** @class */ (function () {
function MockSchemaRegistry(existingProperties, attrPropMapping, existingElements, invalidProperties, invalidAttributes) {
this.existingProperties = existingProperties;
this.attrPropMapping = attrPropMapping;
this.existingElements = existingElements;
this.invalidProperties = invalidProperties;
this.invalidAttributes = invalidAttributes;
}
MockSchemaRegistry.prototype.hasProperty = function (tagName, property, schemas) {
var value = this.existingProperties[property];
return value === void 0 ? true : value;
};
MockSchemaRegistry.prototype.hasElement = function (tagName, schemaMetas) {
var value = this.existingElements[tagName.toLowerCase()];
return value === void 0 ? true : value;
};
MockSchemaRegistry.prototype.allKnownElementNames = function () { return Object.keys(this.existingElements); };
MockSchemaRegistry.prototype.securityContext = function (selector, property, isAttribute) {
return compiler.core.SecurityContext.NONE;
};
MockSchemaRegistry.prototype.getMappedPropName = function (attrName) { return this.attrPropMapping[attrName] || attrName; };
MockSchemaRegistry.prototype.getDefaultComponentElementName = function () { return 'ng-component'; };
MockSchemaRegistry.prototype.validateProperty = function (name) {
if (this.invalidProperties.indexOf(name) > -1) {
return { error: true, msg: "Binding to property '" + name + "' is disallowed for security reasons" };
}
else {
return { error: false };
}
};
MockSchemaRegistry.prototype.validateAttribute = function (name) {
if (this.invalidAttributes.indexOf(name) > -1) {
return {
error: true,
msg: "Binding to attribute '" + name + "' is disallowed for security reasons"
};
}
else {
return { error: false };
}
};
MockSchemaRegistry.prototype.normalizeAnimationStyleProperty = function (propName) { return propName; };
MockSchemaRegistry.prototype.normalizeAnimationStyleValue = function (camelCaseProp, userProvidedProp, val) {
return { error: null, value: val.toString() };
};
return MockSchemaRegistry;
}());
/**
* @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
*/
/**
* An implementation of {@link DirectiveResolver} that allows overriding
* various properties of directives.
*/
var MockDirectiveResolver = /** @class */ (function (_super) {
__extends(MockDirectiveResolver, _super);
function MockDirectiveResolver(reflector) {
var _this = _super.call(this, reflector) || this;
_this._directives = new Map();
return _this;
}
MockDirectiveResolver.prototype.resolve = function (type, throwIfNotFound) {
if (throwIfNotFound === void 0) { throwIfNotFound = true; }
return this._directives.get(type) || _super.prototype.resolve.call(this, type, throwIfNotFound);
};
/**
* Overrides the {@link core.Directive} for a directive.
*/
MockDirectiveResolver.prototype.setDirective = function (type, metadata) {
this._directives.set(type, metadata);
};
return MockDirectiveResolver;
}(compiler.DirectiveResolver));
/**
* @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 MockNgModuleResolver = /** @class */ (function (_super) {
__extends(MockNgModuleResolver, _super);
function MockNgModuleResolver(reflector) {
var _this = _super.call(this, reflector) || this;
_this._ngModules = new Map();
return _this;
}
/**
* Overrides the {@link NgModule} for a module.
*/
MockNgModuleResolver.prototype.setNgModule = function (type, metadata) {
this._ngModules.set(type, metadata);
};
/**
* Returns the {@link NgModule} for a module:
* - Set the {@link NgModule} to the overridden view when it exists or fallback to the
* default
* `NgModuleResolver`, see `setNgModule`.
*/
MockNgModuleResolver.prototype.resolve = function (type, throwIfNotFound) {
if (throwIfNotFound === void 0) { throwIfNotFound = true; }
return this._ngModules.get(type) || _super.prototype.resolve.call(this, type, throwIfNotFound);
};
return MockNgModuleResolver;
}(compiler.NgModuleResolver));
/**
* @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 MockPipeResolver = /** @class */ (function (_super) {
__extends(MockPipeResolver, _super);
function MockPipeResolver(refector) {
var _this = _super.call(this, refector) || this;
_this._pipes = new Map();
return _this;
}
/**
* Overrides the {@link Pipe} for a pipe.
*/
MockPipeResolver.prototype.setPipe = function (type, metadata) { this._pipes.set(type, metadata); };
/**
* Returns the {@link Pipe} for a pipe:
* - Set the {@link Pipe} to the overridden view when it exists or fallback to the
* default
* `PipeResolver`, see `setPipe`.
*/
MockPipeResolver.prototype.resolve = function (type, throwIfNotFound) {
if (throwIfNotFound === void 0) { throwIfNotFound = true; }
var metadata = this._pipes.get(type);
if (!metadata) {
metadata = _super.prototype.resolve.call(this, type, throwIfNotFound);
}
return metadata;
};
return MockPipeResolver;
}(compiler.PipeResolver));
/**
* @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 APIs of the compiler package.
*
* <div class="callout is-critical">
* <header>Unstable APIs</header>
* <p>
* All compiler apis are currently considered experimental and private!
* </p>
* <p>
* We expect the APIs in this package to keep on changing. Do not rely on them.
* </p>
* </div>
*/
/**
* @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.
*/
// This file only reexports content of the `src` folder. Keep it that way.
/**
* @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
*/
// This file is not used to build this module. It is only used during editing
// by the TypeScript language service and during build for verification. `ngc`
// replaces this file with production index.ts when it rewrites private symbol
// names.
/**
* Generated bundle index. Do not edit.
*/
exports.MockResourceLoader = MockResourceLoader;
exports.MockSchemaRegistry = MockSchemaRegistry;
exports.MockDirectiveResolver = MockDirectiveResolver;
exports.MockNgModuleResolver = MockNgModuleResolver;
exports.MockPipeResolver = MockPipeResolver;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=compiler-testing.umd.js.map