Front end of the Slack clone application.

testing.js 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /**
  2. * @license Angular v5.2.11
  3. * (c) 2010-2018 Google, Inc. https://angular.io/
  4. * License: MIT
  5. */
  6. import { __extends } from 'tslib';
  7. import { DirectiveResolver, NgModuleResolver, PipeResolver, ResourceLoader, core } from '@angular/compiler';
  8. /**
  9. * @fileoverview added by tsickle
  10. * @suppress {checkTypes} checked by tsc
  11. */
  12. /**
  13. * @license
  14. * Copyright Google Inc. All Rights Reserved.
  15. *
  16. * Use of this source code is governed by an MIT-style license that can be
  17. * found in the LICENSE file at https://angular.io/license
  18. */
  19. /**
  20. * A mock implementation of {\@link ResourceLoader} that allows outgoing requests to be mocked
  21. * and responded to within a single test, without going to the network.
  22. */
  23. var MockResourceLoader = /** @class */ (function (_super) {
  24. __extends(MockResourceLoader, _super);
  25. function MockResourceLoader() {
  26. var _this = _super !== null && _super.apply(this, arguments) || this;
  27. _this._expectations = [];
  28. _this._definitions = new Map();
  29. _this._requests = [];
  30. return _this;
  31. }
  32. /**
  33. * @param {?} url
  34. * @return {?}
  35. */
  36. MockResourceLoader.prototype.get = /**
  37. * @param {?} url
  38. * @return {?}
  39. */
  40. function (url) {
  41. var /** @type {?} */ request = new _PendingRequest(url);
  42. this._requests.push(request);
  43. return request.getPromise();
  44. };
  45. /**
  46. * @return {?}
  47. */
  48. MockResourceLoader.prototype.hasPendingRequests = /**
  49. * @return {?}
  50. */
  51. function () { return !!this._requests.length; };
  52. /**
  53. * Add an expectation for the given URL. Incoming requests will be checked against
  54. * the next expectation (in FIFO order). The `verifyNoOutstandingExpectations` method
  55. * can be used to check if any expectations have not yet been met.
  56. *
  57. * The response given will be returned if the expectation matches.
  58. */
  59. /**
  60. * Add an expectation for the given URL. Incoming requests will be checked against
  61. * the next expectation (in FIFO order). The `verifyNoOutstandingExpectations` method
  62. * can be used to check if any expectations have not yet been met.
  63. *
  64. * The response given will be returned if the expectation matches.
  65. * @param {?} url
  66. * @param {?} response
  67. * @return {?}
  68. */
  69. MockResourceLoader.prototype.expect = /**
  70. * Add an expectation for the given URL. Incoming requests will be checked against
  71. * the next expectation (in FIFO order). The `verifyNoOutstandingExpectations` method
  72. * can be used to check if any expectations have not yet been met.
  73. *
  74. * The response given will be returned if the expectation matches.
  75. * @param {?} url
  76. * @param {?} response
  77. * @return {?}
  78. */
  79. function (url, response) {
  80. var /** @type {?} */ expectation = new _Expectation(url, response);
  81. this._expectations.push(expectation);
  82. };
  83. /**
  84. * Add a definition for the given URL to return the given response. Unlike expectations,
  85. * definitions have no order and will satisfy any matching request at any time. Also
  86. * unlike expectations, unused definitions do not cause `verifyNoOutstandingExpectations`
  87. * to return an error.
  88. */
  89. /**
  90. * Add a definition for the given URL to return the given response. Unlike expectations,
  91. * definitions have no order and will satisfy any matching request at any time. Also
  92. * unlike expectations, unused definitions do not cause `verifyNoOutstandingExpectations`
  93. * to return an error.
  94. * @param {?} url
  95. * @param {?} response
  96. * @return {?}
  97. */
  98. MockResourceLoader.prototype.when = /**
  99. * Add a definition for the given URL to return the given response. Unlike expectations,
  100. * definitions have no order and will satisfy any matching request at any time. Also
  101. * unlike expectations, unused definitions do not cause `verifyNoOutstandingExpectations`
  102. * to return an error.
  103. * @param {?} url
  104. * @param {?} response
  105. * @return {?}
  106. */
  107. function (url, response) { this._definitions.set(url, response); };
  108. /**
  109. * Process pending requests and verify there are no outstanding expectations. Also fails
  110. * if no requests are pending.
  111. */
  112. /**
  113. * Process pending requests and verify there are no outstanding expectations. Also fails
  114. * if no requests are pending.
  115. * @return {?}
  116. */
  117. MockResourceLoader.prototype.flush = /**
  118. * Process pending requests and verify there are no outstanding expectations. Also fails
  119. * if no requests are pending.
  120. * @return {?}
  121. */
  122. function () {
  123. if (this._requests.length === 0) {
  124. throw new Error('No pending requests to flush');
  125. }
  126. do {
  127. this._processRequest(/** @type {?} */ ((this._requests.shift())));
  128. } while (this._requests.length > 0);
  129. this.verifyNoOutstandingExpectations();
  130. };
  131. /**
  132. * Throw an exception if any expectations have not been satisfied.
  133. */
  134. /**
  135. * Throw an exception if any expectations have not been satisfied.
  136. * @return {?}
  137. */
  138. MockResourceLoader.prototype.verifyNoOutstandingExpectations = /**
  139. * Throw an exception if any expectations have not been satisfied.
  140. * @return {?}
  141. */
  142. function () {
  143. if (this._expectations.length === 0)
  144. return;
  145. var /** @type {?} */ urls = [];
  146. for (var /** @type {?} */ i = 0; i < this._expectations.length; i++) {
  147. var /** @type {?} */ expectation = this._expectations[i];
  148. urls.push(expectation.url);
  149. }
  150. throw new Error("Unsatisfied requests: " + urls.join(', '));
  151. };
  152. /**
  153. * @param {?} request
  154. * @return {?}
  155. */
  156. MockResourceLoader.prototype._processRequest = /**
  157. * @param {?} request
  158. * @return {?}
  159. */
  160. function (request) {
  161. var /** @type {?} */ url = request.url;
  162. if (this._expectations.length > 0) {
  163. var /** @type {?} */ expectation = this._expectations[0];
  164. if (expectation.url == url) {
  165. remove(this._expectations, expectation);
  166. request.complete(expectation.response);
  167. return;
  168. }
  169. }
  170. if (this._definitions.has(url)) {
  171. var /** @type {?} */ response = this._definitions.get(url);
  172. request.complete(response == null ? null : response);
  173. return;
  174. }
  175. throw new Error("Unexpected request " + url);
  176. };
  177. return MockResourceLoader;
  178. }(ResourceLoader));
  179. var _PendingRequest = /** @class */ (function () {
  180. function _PendingRequest(url) {
  181. var _this = this;
  182. this.url = url;
  183. this.promise = new Promise(function (res, rej) {
  184. _this.resolve = res;
  185. _this.reject = rej;
  186. });
  187. }
  188. /**
  189. * @param {?} response
  190. * @return {?}
  191. */
  192. _PendingRequest.prototype.complete = /**
  193. * @param {?} response
  194. * @return {?}
  195. */
  196. function (response) {
  197. if (response == null) {
  198. this.reject("Failed to load " + this.url);
  199. }
  200. else {
  201. this.resolve(response);
  202. }
  203. };
  204. /**
  205. * @return {?}
  206. */
  207. _PendingRequest.prototype.getPromise = /**
  208. * @return {?}
  209. */
  210. function () { return this.promise; };
  211. return _PendingRequest;
  212. }());
  213. var _Expectation = /** @class */ (function () {
  214. function _Expectation(url, response) {
  215. this.url = url;
  216. this.response = response;
  217. }
  218. return _Expectation;
  219. }());
  220. /**
  221. * @template T
  222. * @param {?} list
  223. * @param {?} el
  224. * @return {?}
  225. */
  226. function remove(list, el) {
  227. var /** @type {?} */ index = list.indexOf(el);
  228. if (index > -1) {
  229. list.splice(index, 1);
  230. }
  231. }
  232. /**
  233. * @fileoverview added by tsickle
  234. * @suppress {checkTypes} checked by tsc
  235. */
  236. /**
  237. * @license
  238. * Copyright Google Inc. All Rights Reserved.
  239. *
  240. * Use of this source code is governed by an MIT-style license that can be
  241. * found in the LICENSE file at https://angular.io/license
  242. */
  243. var MockSchemaRegistry = /** @class */ (function () {
  244. function MockSchemaRegistry(existingProperties, attrPropMapping, existingElements, invalidProperties, invalidAttributes) {
  245. this.existingProperties = existingProperties;
  246. this.attrPropMapping = attrPropMapping;
  247. this.existingElements = existingElements;
  248. this.invalidProperties = invalidProperties;
  249. this.invalidAttributes = invalidAttributes;
  250. }
  251. /**
  252. * @param {?} tagName
  253. * @param {?} property
  254. * @param {?} schemas
  255. * @return {?}
  256. */
  257. MockSchemaRegistry.prototype.hasProperty = /**
  258. * @param {?} tagName
  259. * @param {?} property
  260. * @param {?} schemas
  261. * @return {?}
  262. */
  263. function (tagName, property, schemas) {
  264. var /** @type {?} */ value = this.existingProperties[property];
  265. return value === void 0 ? true : value;
  266. };
  267. /**
  268. * @param {?} tagName
  269. * @param {?} schemaMetas
  270. * @return {?}
  271. */
  272. MockSchemaRegistry.prototype.hasElement = /**
  273. * @param {?} tagName
  274. * @param {?} schemaMetas
  275. * @return {?}
  276. */
  277. function (tagName, schemaMetas) {
  278. var /** @type {?} */ value = this.existingElements[tagName.toLowerCase()];
  279. return value === void 0 ? true : value;
  280. };
  281. /**
  282. * @return {?}
  283. */
  284. MockSchemaRegistry.prototype.allKnownElementNames = /**
  285. * @return {?}
  286. */
  287. function () { return Object.keys(this.existingElements); };
  288. /**
  289. * @param {?} selector
  290. * @param {?} property
  291. * @param {?} isAttribute
  292. * @return {?}
  293. */
  294. MockSchemaRegistry.prototype.securityContext = /**
  295. * @param {?} selector
  296. * @param {?} property
  297. * @param {?} isAttribute
  298. * @return {?}
  299. */
  300. function (selector, property, isAttribute) {
  301. return core.SecurityContext.NONE;
  302. };
  303. /**
  304. * @param {?} attrName
  305. * @return {?}
  306. */
  307. MockSchemaRegistry.prototype.getMappedPropName = /**
  308. * @param {?} attrName
  309. * @return {?}
  310. */
  311. function (attrName) { return this.attrPropMapping[attrName] || attrName; };
  312. /**
  313. * @return {?}
  314. */
  315. MockSchemaRegistry.prototype.getDefaultComponentElementName = /**
  316. * @return {?}
  317. */
  318. function () { return 'ng-component'; };
  319. /**
  320. * @param {?} name
  321. * @return {?}
  322. */
  323. MockSchemaRegistry.prototype.validateProperty = /**
  324. * @param {?} name
  325. * @return {?}
  326. */
  327. function (name) {
  328. if (this.invalidProperties.indexOf(name) > -1) {
  329. return { error: true, msg: "Binding to property '" + name + "' is disallowed for security reasons" };
  330. }
  331. else {
  332. return { error: false };
  333. }
  334. };
  335. /**
  336. * @param {?} name
  337. * @return {?}
  338. */
  339. MockSchemaRegistry.prototype.validateAttribute = /**
  340. * @param {?} name
  341. * @return {?}
  342. */
  343. function (name) {
  344. if (this.invalidAttributes.indexOf(name) > -1) {
  345. return {
  346. error: true,
  347. msg: "Binding to attribute '" + name + "' is disallowed for security reasons"
  348. };
  349. }
  350. else {
  351. return { error: false };
  352. }
  353. };
  354. /**
  355. * @param {?} propName
  356. * @return {?}
  357. */
  358. MockSchemaRegistry.prototype.normalizeAnimationStyleProperty = /**
  359. * @param {?} propName
  360. * @return {?}
  361. */
  362. function (propName) { return propName; };
  363. /**
  364. * @param {?} camelCaseProp
  365. * @param {?} userProvidedProp
  366. * @param {?} val
  367. * @return {?}
  368. */
  369. MockSchemaRegistry.prototype.normalizeAnimationStyleValue = /**
  370. * @param {?} camelCaseProp
  371. * @param {?} userProvidedProp
  372. * @param {?} val
  373. * @return {?}
  374. */
  375. function (camelCaseProp, userProvidedProp, val) {
  376. return { error: /** @type {?} */ ((null)), value: val.toString() };
  377. };
  378. return MockSchemaRegistry;
  379. }());
  380. /**
  381. * @fileoverview added by tsickle
  382. * @suppress {checkTypes} checked by tsc
  383. */
  384. /**
  385. * An implementation of {\@link DirectiveResolver} that allows overriding
  386. * various properties of directives.
  387. */
  388. var MockDirectiveResolver = /** @class */ (function (_super) {
  389. __extends(MockDirectiveResolver, _super);
  390. function MockDirectiveResolver(reflector) {
  391. var _this = _super.call(this, reflector) || this;
  392. _this._directives = new Map();
  393. return _this;
  394. }
  395. /**
  396. * @param {?} type
  397. * @param {?=} throwIfNotFound
  398. * @return {?}
  399. */
  400. MockDirectiveResolver.prototype.resolve = /**
  401. * @param {?} type
  402. * @param {?=} throwIfNotFound
  403. * @return {?}
  404. */
  405. function (type, throwIfNotFound) {
  406. if (throwIfNotFound === void 0) { throwIfNotFound = true; }
  407. return this._directives.get(type) || _super.prototype.resolve.call(this, type, throwIfNotFound);
  408. };
  409. /**
  410. * Overrides the {@link core.Directive} for a directive.
  411. */
  412. /**
  413. * Overrides the {\@link core.Directive} for a directive.
  414. * @param {?} type
  415. * @param {?} metadata
  416. * @return {?}
  417. */
  418. MockDirectiveResolver.prototype.setDirective = /**
  419. * Overrides the {\@link core.Directive} for a directive.
  420. * @param {?} type
  421. * @param {?} metadata
  422. * @return {?}
  423. */
  424. function (type, metadata) {
  425. this._directives.set(type, metadata);
  426. };
  427. return MockDirectiveResolver;
  428. }(DirectiveResolver));
  429. /**
  430. * @fileoverview added by tsickle
  431. * @suppress {checkTypes} checked by tsc
  432. */
  433. /**
  434. * @license
  435. * Copyright Google Inc. All Rights Reserved.
  436. *
  437. * Use of this source code is governed by an MIT-style license that can be
  438. * found in the LICENSE file at https://angular.io/license
  439. */
  440. var MockNgModuleResolver = /** @class */ (function (_super) {
  441. __extends(MockNgModuleResolver, _super);
  442. function MockNgModuleResolver(reflector) {
  443. var _this = _super.call(this, reflector) || this;
  444. _this._ngModules = new Map();
  445. return _this;
  446. }
  447. /**
  448. * Overrides the {@link NgModule} for a module.
  449. */
  450. /**
  451. * Overrides the {\@link NgModule} for a module.
  452. * @param {?} type
  453. * @param {?} metadata
  454. * @return {?}
  455. */
  456. MockNgModuleResolver.prototype.setNgModule = /**
  457. * Overrides the {\@link NgModule} for a module.
  458. * @param {?} type
  459. * @param {?} metadata
  460. * @return {?}
  461. */
  462. function (type, metadata) {
  463. this._ngModules.set(type, metadata);
  464. };
  465. /**
  466. * Returns the {@link NgModule} for a module:
  467. * - Set the {@link NgModule} to the overridden view when it exists or fallback to the
  468. * default
  469. * `NgModuleResolver`, see `setNgModule`.
  470. */
  471. /**
  472. * Returns the {\@link NgModule} for a module:
  473. * - Set the {\@link NgModule} to the overridden view when it exists or fallback to the
  474. * default
  475. * `NgModuleResolver`, see `setNgModule`.
  476. * @param {?} type
  477. * @param {?=} throwIfNotFound
  478. * @return {?}
  479. */
  480. MockNgModuleResolver.prototype.resolve = /**
  481. * Returns the {\@link NgModule} for a module:
  482. * - Set the {\@link NgModule} to the overridden view when it exists or fallback to the
  483. * default
  484. * `NgModuleResolver`, see `setNgModule`.
  485. * @param {?} type
  486. * @param {?=} throwIfNotFound
  487. * @return {?}
  488. */
  489. function (type, throwIfNotFound) {
  490. if (throwIfNotFound === void 0) { throwIfNotFound = true; }
  491. return this._ngModules.get(type) || /** @type {?} */ ((_super.prototype.resolve.call(this, type, throwIfNotFound)));
  492. };
  493. return MockNgModuleResolver;
  494. }(NgModuleResolver));
  495. /**
  496. * @fileoverview added by tsickle
  497. * @suppress {checkTypes} checked by tsc
  498. */
  499. /**
  500. * @license
  501. * Copyright Google Inc. All Rights Reserved.
  502. *
  503. * Use of this source code is governed by an MIT-style license that can be
  504. * found in the LICENSE file at https://angular.io/license
  505. */
  506. var MockPipeResolver = /** @class */ (function (_super) {
  507. __extends(MockPipeResolver, _super);
  508. function MockPipeResolver(refector) {
  509. var _this = _super.call(this, refector) || this;
  510. _this._pipes = new Map();
  511. return _this;
  512. }
  513. /**
  514. * Overrides the {@link Pipe} for a pipe.
  515. */
  516. /**
  517. * Overrides the {\@link Pipe} for a pipe.
  518. * @param {?} type
  519. * @param {?} metadata
  520. * @return {?}
  521. */
  522. MockPipeResolver.prototype.setPipe = /**
  523. * Overrides the {\@link Pipe} for a pipe.
  524. * @param {?} type
  525. * @param {?} metadata
  526. * @return {?}
  527. */
  528. function (type, metadata) { this._pipes.set(type, metadata); };
  529. /**
  530. * Returns the {@link Pipe} for a pipe:
  531. * - Set the {@link Pipe} to the overridden view when it exists or fallback to the
  532. * default
  533. * `PipeResolver`, see `setPipe`.
  534. */
  535. /**
  536. * Returns the {\@link Pipe} for a pipe:
  537. * - Set the {\@link Pipe} to the overridden view when it exists or fallback to the
  538. * default
  539. * `PipeResolver`, see `setPipe`.
  540. * @param {?} type
  541. * @param {?=} throwIfNotFound
  542. * @return {?}
  543. */
  544. MockPipeResolver.prototype.resolve = /**
  545. * Returns the {\@link Pipe} for a pipe:
  546. * - Set the {\@link Pipe} to the overridden view when it exists or fallback to the
  547. * default
  548. * `PipeResolver`, see `setPipe`.
  549. * @param {?} type
  550. * @param {?=} throwIfNotFound
  551. * @return {?}
  552. */
  553. function (type, throwIfNotFound) {
  554. if (throwIfNotFound === void 0) { throwIfNotFound = true; }
  555. var /** @type {?} */ metadata = this._pipes.get(type);
  556. if (!metadata) {
  557. metadata = /** @type {?} */ ((_super.prototype.resolve.call(this, type, throwIfNotFound)));
  558. }
  559. return metadata;
  560. };
  561. return MockPipeResolver;
  562. }(PipeResolver));
  563. /**
  564. * @fileoverview added by tsickle
  565. * @suppress {checkTypes} checked by tsc
  566. */
  567. /**
  568. * @license
  569. * Copyright Google Inc. All Rights Reserved.
  570. *
  571. * Use of this source code is governed by an MIT-style license that can be
  572. * found in the LICENSE file at https://angular.io/license
  573. */
  574. /**
  575. * @module
  576. * @description
  577. * Entry point for all APIs of the compiler package.
  578. *
  579. * <div class="callout is-critical">
  580. * <header>Unstable APIs</header>
  581. * <p>
  582. * All compiler apis are currently considered experimental and private!
  583. * </p>
  584. * <p>
  585. * We expect the APIs in this package to keep on changing. Do not rely on them.
  586. * </p>
  587. * </div>
  588. */
  589. /**
  590. * @fileoverview added by tsickle
  591. * @suppress {checkTypes} checked by tsc
  592. */
  593. /**
  594. * @license
  595. * Copyright Google Inc. All Rights Reserved.
  596. *
  597. * Use of this source code is governed by an MIT-style license that can be
  598. * found in the LICENSE file at https://angular.io/license
  599. */
  600. /**
  601. * @module
  602. * @description
  603. * Entry point for all public APIs of this package.
  604. */
  605. // This file only reexports content of the `src` folder. Keep it that way.
  606. /**
  607. * @fileoverview added by tsickle
  608. * @suppress {checkTypes} checked by tsc
  609. */
  610. /**
  611. * @license
  612. * Copyright Google Inc. All Rights Reserved.
  613. *
  614. * Use of this source code is governed by an MIT-style license that can be
  615. * found in the LICENSE file at https://angular.io/license
  616. */
  617. // This file is not used to build this module. It is only used during editing
  618. // by the TypeScript language service and during build for verification. `ngc`
  619. // replaces this file with production index.ts when it rewrites private symbol
  620. // names.
  621. export { MockResourceLoader, MockSchemaRegistry, MockDirectiveResolver, MockNgModuleResolver, MockPipeResolver };
  622. //# sourceMappingURL=testing.js.map