a zip code crypto-currency system good for red ONLY

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /**
  2. * @license Angular v5.2.11
  3. * (c) 2010-2018 Google, Inc. https://angular.io/
  4. * License: MIT
  5. */
  6. import { Injectable } from '@angular/core';
  7. import { ReadyState, Request } from '@angular/http';
  8. import { ReplaySubject } from 'rxjs/ReplaySubject';
  9. import { Subject } from 'rxjs/Subject';
  10. import { take } from 'rxjs/operator/take';
  11. /**
  12. * @fileoverview added by tsickle
  13. * @suppress {checkTypes} checked by tsc
  14. */
  15. /**
  16. * @license
  17. * Copyright Google Inc. All Rights Reserved.
  18. *
  19. * Use of this source code is governed by an MIT-style license that can be
  20. * found in the LICENSE file at https://angular.io/license
  21. */
  22. /**
  23. *
  24. * Mock Connection to represent a {\@link Connection} for tests.
  25. *
  26. * @deprecated use \@angular/common/http instead
  27. */
  28. class MockConnection {
  29. /**
  30. * @param {?} req
  31. */
  32. constructor(req) {
  33. this.response = /** @type {?} */ (take.call(new ReplaySubject(1), 1));
  34. this.readyState = ReadyState.Open;
  35. this.request = req;
  36. }
  37. /**
  38. * Sends a mock response to the connection. This response is the value that is emitted to the
  39. * {\@link EventEmitter} returned by {\@link Http}.
  40. *
  41. * ### Example
  42. *
  43. * ```
  44. * var connection;
  45. * backend.connections.subscribe(c => connection = c);
  46. * http.request('data.json').subscribe(res => console.log(res.text()));
  47. * connection.mockRespond(new Response(new ResponseOptions({ body: 'fake response' }))); //logs
  48. * 'fake response'
  49. * ```
  50. *
  51. * @param {?} res
  52. * @return {?}
  53. */
  54. mockRespond(res) {
  55. if (this.readyState === ReadyState.Done || this.readyState === ReadyState.Cancelled) {
  56. throw new Error('Connection has already been resolved');
  57. }
  58. this.readyState = ReadyState.Done;
  59. this.response.next(res);
  60. this.response.complete();
  61. }
  62. /**
  63. * Not yet implemented!
  64. *
  65. * Sends the provided {\@link Response} to the `downloadObserver` of the `Request`
  66. * associated with this connection.
  67. * @param {?} res
  68. * @return {?}
  69. */
  70. mockDownload(res) {
  71. // this.request.downloadObserver.onNext(res);
  72. // if (res.bytesLoaded === res.totalBytes) {
  73. // this.request.downloadObserver.onCompleted();
  74. // }
  75. }
  76. /**
  77. * Emits the provided error object as an error to the {\@link Response} {\@link EventEmitter}
  78. * returned
  79. * from {\@link Http}.
  80. *
  81. * ### Example
  82. *
  83. * ```
  84. * var connection;
  85. * backend.connections.subscribe(c => connection = c);
  86. * http.request('data.json').subscribe(res => res, err => console.log(err)));
  87. * connection.mockError(new Error('error'));
  88. * ```
  89. *
  90. * @param {?=} err
  91. * @return {?}
  92. */
  93. mockError(err) {
  94. // Matches ResourceLoader semantics
  95. this.readyState = ReadyState.Done;
  96. this.response.error(err);
  97. }
  98. }
  99. /**
  100. * A mock backend for testing the {\@link Http} service.
  101. *
  102. * This class can be injected in tests, and should be used to override providers
  103. * to other backends, such as {\@link XHRBackend}.
  104. *
  105. * ### Example
  106. *
  107. * ```
  108. * import {Injectable, Injector} from '\@angular/core';
  109. * import {async, fakeAsync, tick} from '\@angular/core/testing';
  110. * import {BaseRequestOptions, ConnectionBackend, Http, RequestOptions} from '\@angular/http';
  111. * import {Response, ResponseOptions} from '\@angular/http';
  112. * import {MockBackend, MockConnection} from '\@angular/http/testing';
  113. *
  114. * const HERO_ONE = 'HeroNrOne';
  115. * const HERO_TWO = 'WillBeAlwaysTheSecond';
  116. *
  117. * \@Injectable()
  118. * class HeroService {
  119. * constructor(private http: Http) {}
  120. *
  121. * getHeroes(): Promise<String[]> {
  122. * return this.http.get('myservices.de/api/heroes')
  123. * .toPromise()
  124. * .then(response => response.json().data)
  125. * .catch(e => this.handleError(e));
  126. * }
  127. *
  128. * private handleError(error: any): Promise<any> {
  129. * console.error('An error occurred', error);
  130. * return Promise.reject(error.message || error);
  131. * }
  132. * }
  133. *
  134. * describe('MockBackend HeroService Example', () => {
  135. * beforeEach(() => {
  136. * this.injector = Injector.create([
  137. * {provide: ConnectionBackend, useClass: MockBackend},
  138. * {provide: RequestOptions, useClass: BaseRequestOptions},
  139. * Http,
  140. * HeroService,
  141. * ]);
  142. * this.heroService = this.injector.get(HeroService);
  143. * this.backend = this.injector.get(ConnectionBackend) as MockBackend;
  144. * this.backend.connections.subscribe((connection: any) => this.lastConnection = connection);
  145. * });
  146. *
  147. * it('getHeroes() should query current service url', () => {
  148. * this.heroService.getHeroes();
  149. * expect(this.lastConnection).toBeDefined('no http service connection at all?');
  150. * expect(this.lastConnection.request.url).toMatch(/api\/heroes$/, 'url invalid');
  151. * });
  152. *
  153. * it('getHeroes() should return some heroes', fakeAsync(() => {
  154. * let result: String[];
  155. * this.heroService.getHeroes().then((heroes: String[]) => result = heroes);
  156. * this.lastConnection.mockRespond(new Response(new ResponseOptions({
  157. * body: JSON.stringify({data: [HERO_ONE, HERO_TWO]}),
  158. * })));
  159. * tick();
  160. * expect(result.length).toEqual(2, 'should contain given amount of heroes');
  161. * expect(result[0]).toEqual(HERO_ONE, ' HERO_ONE should be the first hero');
  162. * expect(result[1]).toEqual(HERO_TWO, ' HERO_TWO should be the second hero');
  163. * }));
  164. *
  165. * it('getHeroes() while server is down', fakeAsync(() => {
  166. * let result: String[];
  167. * let catchedError: any;
  168. * this.heroService.getHeroes()
  169. * .then((heroes: String[]) => result = heroes)
  170. * .catch((error: any) => catchedError = error);
  171. * this.lastConnection.mockRespond(new Response(new ResponseOptions({
  172. * status: 404,
  173. * statusText: 'URL not Found',
  174. * })));
  175. * tick();
  176. * expect(result).toBeUndefined();
  177. * expect(catchedError).toBeDefined();
  178. * }));
  179. * });
  180. * ```
  181. *
  182. * This method only exists in the mock implementation, not in real Backends.
  183. *
  184. * @deprecated use \@angular/common/http instead
  185. */
  186. class MockBackend {
  187. constructor() {
  188. this.connectionsArray = [];
  189. this.connections = new Subject();
  190. this.connections.subscribe((connection) => this.connectionsArray.push(connection));
  191. this.pendingConnections = new Subject();
  192. }
  193. /**
  194. * Checks all connections, and raises an exception if any connection has not received a response.
  195. *
  196. * This method only exists in the mock implementation, not in real Backends.
  197. * @return {?}
  198. */
  199. verifyNoPendingRequests() {
  200. let /** @type {?} */ pending = 0;
  201. this.pendingConnections.subscribe((c) => pending++);
  202. if (pending > 0)
  203. throw new Error(`${pending} pending connections to be resolved`);
  204. }
  205. /**
  206. * Can be used in conjunction with `verifyNoPendingRequests` to resolve any not-yet-resolve
  207. * connections, if it's expected that there are connections that have not yet received a response.
  208. *
  209. * This method only exists in the mock implementation, not in real Backends.
  210. * @return {?}
  211. */
  212. resolveAllConnections() { this.connections.subscribe((c) => c.readyState = 4); }
  213. /**
  214. * Creates a new {\@link MockConnection}. This is equivalent to calling `new
  215. * MockConnection()`, except that it also will emit the new `Connection` to the `connections`
  216. * emitter of this `MockBackend` instance. This method will usually only be used by tests
  217. * against the framework itself, not by end-users.
  218. * @param {?} req
  219. * @return {?}
  220. */
  221. createConnection(req) {
  222. if (!req || !(req instanceof Request)) {
  223. throw new Error(`createConnection requires an instance of Request, got ${req}`);
  224. }
  225. const /** @type {?} */ connection = new MockConnection(req);
  226. this.connections.next(connection);
  227. return connection;
  228. }
  229. }
  230. MockBackend.decorators = [
  231. { type: Injectable },
  232. ];
  233. /** @nocollapse */
  234. MockBackend.ctorParameters = () => [];
  235. /**
  236. * @fileoverview added by tsickle
  237. * @suppress {checkTypes} checked by tsc
  238. */
  239. /**
  240. * @license
  241. * Copyright Google Inc. All Rights Reserved.
  242. *
  243. * Use of this source code is governed by an MIT-style license that can be
  244. * found in the LICENSE file at https://angular.io/license
  245. */
  246. /**
  247. * @module
  248. * @description
  249. * Entry point for all public APIs of the platform-server/testing package.
  250. */
  251. /**
  252. * @fileoverview added by tsickle
  253. * @suppress {checkTypes} checked by tsc
  254. */
  255. /**
  256. * @license
  257. * Copyright Google Inc. All Rights Reserved.
  258. *
  259. * Use of this source code is governed by an MIT-style license that can be
  260. * found in the LICENSE file at https://angular.io/license
  261. */
  262. /**
  263. * @module
  264. * @description
  265. * Entry point for all public APIs of this package.
  266. */
  267. /**
  268. * @fileoverview added by tsickle
  269. * @suppress {checkTypes} checked by tsc
  270. */
  271. /**
  272. * Generated bundle index. Do not edit.
  273. */
  274. export { MockConnection, MockBackend };
  275. //# sourceMappingURL=testing.js.map