a zip code crypto-currency system good for red ONLY

mock-providers.js 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = Object.setPrototypeOf ||
  3. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5. return function (d, b) {
  6. extendStatics(d, b);
  7. function __() { this.constructor = d; }
  8. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9. };
  10. })();
  11. (function (factory) {
  12. if (typeof module === "object" && typeof module.exports === "object") {
  13. var v = factory(require, exports);
  14. if (v !== undefined) module.exports = v;
  15. }
  16. else if (typeof define === "function" && define.amd) {
  17. define(["require", "exports", "@angular/core", "../components/app/app", "../config/config", "../components/content/content", "../navigation/deep-linker", "../platform/dom-controller", "../gestures/gesture-controller", "../tap-click/haptic", "../components/app/app-root", "../components/menu/menu", "../navigation/nav-controller-base", "../components/app/overlay-portal", "../transitions/page-transition", "../platform/platform", "../platform/query-params", "../components/tabs/tab", "../components/tabs/tabs", "../transitions/transition-controller", "../navigation/url-serializer", "../navigation/view-controller", "./module-loader", "./ng-module-loader", "../navigation/nav-util", "../components/ion", "../components/item/item", "./form"], factory);
  18. }
  19. })(function (require, exports) {
  20. "use strict";
  21. Object.defineProperty(exports, "__esModule", { value: true });
  22. var core_1 = require("@angular/core");
  23. var app_1 = require("../components/app/app");
  24. var config_1 = require("../config/config");
  25. var content_1 = require("../components/content/content");
  26. var deep_linker_1 = require("../navigation/deep-linker");
  27. var dom_controller_1 = require("../platform/dom-controller");
  28. var gesture_controller_1 = require("../gestures/gesture-controller");
  29. var haptic_1 = require("../tap-click/haptic");
  30. var app_root_1 = require("../components/app/app-root");
  31. var menu_1 = require("../components/menu/menu");
  32. var nav_controller_base_1 = require("../navigation/nav-controller-base");
  33. var overlay_portal_1 = require("../components/app/overlay-portal");
  34. var page_transition_1 = require("../transitions/page-transition");
  35. var platform_1 = require("../platform/platform");
  36. var query_params_1 = require("../platform/query-params");
  37. var tab_1 = require("../components/tabs/tab");
  38. var tabs_1 = require("../components/tabs/tabs");
  39. var transition_controller_1 = require("../transitions/transition-controller");
  40. var url_serializer_1 = require("../navigation/url-serializer");
  41. var view_controller_1 = require("../navigation/view-controller");
  42. var module_loader_1 = require("./module-loader");
  43. var ng_module_loader_1 = require("./ng-module-loader");
  44. var nav_util_1 = require("../navigation/nav-util");
  45. var ion_1 = require("../components/ion");
  46. var item_1 = require("../components/item/item");
  47. var form_1 = require("./form");
  48. function mockConfig(config, _url, platform) {
  49. if (_url === void 0) { _url = '/'; }
  50. var c = new config_1.Config();
  51. var p = platform || mockPlatform();
  52. c.init(config, p);
  53. return c;
  54. }
  55. exports.mockConfig = mockConfig;
  56. function mockQueryParams(url) {
  57. if (url === void 0) { url = '/'; }
  58. var qp = new query_params_1.QueryParams();
  59. qp.parseUrl(url);
  60. return qp;
  61. }
  62. exports.mockQueryParams = mockQueryParams;
  63. function mockPlatform() {
  64. return new MockPlatform();
  65. }
  66. exports.mockPlatform = mockPlatform;
  67. var MockPlatform = (function (_super) {
  68. __extends(MockPlatform, _super);
  69. function MockPlatform() {
  70. var _this = _super.call(this) || this;
  71. _this.timeoutIds = 0;
  72. _this.timeouts = [];
  73. _this.rafIds = 0;
  74. _this.timeStamps = 0;
  75. _this.rafs = [];
  76. var doc = document.implementation.createHTMLDocument('');
  77. _this.setWindow(window);
  78. _this.setDocument(doc);
  79. _this.setCssProps(doc.documentElement);
  80. return _this;
  81. }
  82. MockPlatform.prototype.timeout = function (callback, timeout) {
  83. var timeoutId = ++this.timeoutIds;
  84. this.timeouts.push({
  85. callback: callback,
  86. timeout: timeout,
  87. timeoutId: timeoutId
  88. });
  89. return timeoutId;
  90. };
  91. MockPlatform.prototype.cancelTimeout = function (timeoutId) {
  92. for (var i = 0; i < this.timeouts.length; i++) {
  93. if (timeoutId === this.timeouts[i].timeoutId) {
  94. this.timeouts.splice(i, 1);
  95. break;
  96. }
  97. }
  98. };
  99. MockPlatform.prototype.flushTimeouts = function (done) {
  100. var _this = this;
  101. setTimeout(function () {
  102. _this.timeouts.sort(function (a, b) {
  103. if (a.timeout < b.timeout)
  104. return -1;
  105. if (a.timeout > b.timeout)
  106. return 1;
  107. return 0;
  108. }).forEach(function (t) {
  109. t.callback();
  110. });
  111. _this.timeouts.length = 0;
  112. done();
  113. });
  114. };
  115. MockPlatform.prototype.flushTimeoutsUntil = function (timeout, done) {
  116. var _this = this;
  117. setTimeout(function () {
  118. _this.timeouts.sort(function (a, b) {
  119. if (a.timeout < b.timeout)
  120. return -1;
  121. if (a.timeout > b.timeout)
  122. return 1;
  123. return 0;
  124. });
  125. var keepers = [];
  126. _this.timeouts.forEach(function (t) {
  127. if (t.timeout < timeout) {
  128. t.callback();
  129. }
  130. else {
  131. keepers.push(t);
  132. }
  133. });
  134. _this.timeouts = keepers;
  135. done();
  136. });
  137. };
  138. MockPlatform.prototype.raf = function (callback) {
  139. var rafId = ++this.rafIds;
  140. this.rafs.push({
  141. callback: callback,
  142. rafId: rafId
  143. });
  144. return rafId;
  145. };
  146. MockPlatform.prototype.cancelRaf = function (rafId) {
  147. for (var i = 0; i < this.rafs.length; i++) {
  148. if (rafId === this.rafs[i].rafId) {
  149. this.rafs.splice(i, 1);
  150. break;
  151. }
  152. }
  153. };
  154. MockPlatform.prototype.flushRafs = function (done) {
  155. var _this = this;
  156. var timestamp = ++this.timeStamps;
  157. setTimeout(function () {
  158. _this.rafs.forEach(function (raf) {
  159. raf.callback(timestamp);
  160. });
  161. _this.rafs.length = 0;
  162. done(timestamp);
  163. });
  164. };
  165. return MockPlatform;
  166. }(platform_1.Platform));
  167. exports.MockPlatform = MockPlatform;
  168. function mockDomController(platform) {
  169. platform = platform || mockPlatform();
  170. return new MockDomController(platform);
  171. }
  172. exports.mockDomController = mockDomController;
  173. var MockDomController = (function (_super) {
  174. __extends(MockDomController, _super);
  175. function MockDomController(mockedPlatform) {
  176. var _this = _super.call(this, mockedPlatform) || this;
  177. _this.mockedPlatform = mockedPlatform;
  178. return _this;
  179. }
  180. MockDomController.prototype.flush = function (done) {
  181. var _this = this;
  182. this.mockedPlatform.flushTimeouts(function () {
  183. _this.mockedPlatform.flushRafs(function (timeStamp) {
  184. done(timeStamp);
  185. });
  186. });
  187. };
  188. MockDomController.prototype.flushUntil = function (timeout, done) {
  189. var _this = this;
  190. this.mockedPlatform.flushTimeoutsUntil(timeout, function () {
  191. _this.mockedPlatform.flushRafs(function (timeStamp) {
  192. done(timeStamp);
  193. });
  194. });
  195. };
  196. return MockDomController;
  197. }(dom_controller_1.DomController));
  198. exports.MockDomController = MockDomController;
  199. function mockApp(config, platform) {
  200. platform = platform || mockPlatform();
  201. config = config || mockConfig(null, '/', platform);
  202. var app = new app_1.App(config, platform);
  203. mockIonicApp(app, config, platform);
  204. return app;
  205. }
  206. exports.mockApp = mockApp;
  207. function mockIonicApp(app, config, plt) {
  208. var appRoot = new app_root_1.IonicApp(null, null, mockElementRef(), mockRenderer(), config, plt, app);
  209. appRoot._loadingPortal = mockOverlayPortal(app, config, plt);
  210. appRoot._toastPortal = mockOverlayPortal(app, config, plt);
  211. appRoot._overlayPortal = mockOverlayPortal(app, config, plt);
  212. appRoot._modalPortal = mockOverlayPortal(app, config, plt);
  213. return appRoot;
  214. }
  215. exports.mockIonicApp = mockIonicApp;
  216. exports.mockTrasitionController = function (config) {
  217. var platform = mockPlatform();
  218. platform.raf = function (callback) {
  219. callback();
  220. };
  221. var trnsCtrl = new transition_controller_1.TransitionController(platform, config);
  222. trnsCtrl.get = function (trnsId, enteringView, leavingView, opts) {
  223. var trns = new page_transition_1.PageTransition(platform, enteringView, leavingView, opts);
  224. trns.trnsId = trnsId;
  225. return trns;
  226. };
  227. return trnsCtrl;
  228. };
  229. function mockContent() {
  230. var platform = mockPlatform();
  231. return new content_1.Content(mockConfig(), platform, mockDomController(platform), mockElementRef(), mockRenderer(), null, null, mockZone(), null, null);
  232. }
  233. exports.mockContent = mockContent;
  234. function mockZone() {
  235. return new core_1.NgZone({ enableLongStackTrace: false });
  236. }
  237. exports.mockZone = mockZone;
  238. function mockChangeDetectorRef() {
  239. var cd = {
  240. reattach: function () { },
  241. detach: function () { },
  242. detectChanges: function () { }
  243. };
  244. return cd;
  245. }
  246. exports.mockChangeDetectorRef = mockChangeDetectorRef;
  247. function mockGestureController(app) {
  248. if (!app) {
  249. app = mockApp();
  250. }
  251. return new gesture_controller_1.GestureController(app);
  252. }
  253. exports.mockGestureController = mockGestureController;
  254. var MockElementRef = (function () {
  255. function MockElementRef(ele) {
  256. this.nativeElement = ele;
  257. }
  258. return MockElementRef;
  259. }());
  260. exports.MockElementRef = MockElementRef;
  261. var MockElement = (function () {
  262. function MockElement() {
  263. this.children = [];
  264. this.classList = new ClassList();
  265. this.attributes = {};
  266. this.style = {};
  267. this.nodeName = 'ION-MOCK';
  268. this.clientWidth = 0;
  269. this.clientHeight = 0;
  270. this.clientTop = 0;
  271. this.clientLeft = 0;
  272. this.offsetWidth = 0;
  273. this.offsetHeight = 0;
  274. this.offsetTop = 0;
  275. this.offsetLeft = 0;
  276. this.scrollTop = 0;
  277. this.scrollHeight = 0;
  278. }
  279. Object.defineProperty(MockElement.prototype, "className", {
  280. get: function () {
  281. return this.classList.classes.join(' ');
  282. },
  283. set: function (val) {
  284. this.classList.classes = val.split(' ');
  285. },
  286. enumerable: true,
  287. configurable: true
  288. });
  289. MockElement.prototype.hasAttribute = function (name) {
  290. return !!this.attributes[name];
  291. };
  292. MockElement.prototype.getAttribute = function (name) {
  293. return this.attributes[name];
  294. };
  295. MockElement.prototype.setAttribute = function (name, val) {
  296. this.attributes[name] = val;
  297. };
  298. MockElement.prototype.addEventListener = function (_type, _listener, _options) { };
  299. MockElement.prototype.removeEventListener = function (_type, _listener, _options) { };
  300. MockElement.prototype.removeAttribute = function (name) {
  301. delete this.attributes[name];
  302. };
  303. return MockElement;
  304. }());
  305. exports.MockElement = MockElement;
  306. var ClassList = (function () {
  307. function ClassList() {
  308. this.classes = [];
  309. }
  310. ClassList.prototype.add = function (className) {
  311. if (!this.contains(className)) {
  312. this.classes.push(className);
  313. }
  314. };
  315. ClassList.prototype.remove = function (className) {
  316. var index = this.classes.indexOf(className);
  317. if (index > -1) {
  318. this.classes.splice(index, 1);
  319. }
  320. };
  321. ClassList.prototype.toggle = function (className) {
  322. if (this.contains(className)) {
  323. this.remove(className);
  324. }
  325. else {
  326. this.add(className);
  327. }
  328. };
  329. ClassList.prototype.contains = function (className) {
  330. return this.classes.indexOf(className) > -1;
  331. };
  332. return ClassList;
  333. }());
  334. exports.ClassList = ClassList;
  335. function mockElementRef() {
  336. return new MockElementRef(new MockElement());
  337. }
  338. exports.mockElementRef = mockElementRef;
  339. function mockElementRefEle(ele) {
  340. return new MockElementRef(ele);
  341. }
  342. exports.mockElementRefEle = mockElementRefEle;
  343. var MockRenderer = (function () {
  344. function MockRenderer() {
  345. }
  346. MockRenderer.prototype.setElementAttribute = function (renderElement, name, val) {
  347. if (name === null) {
  348. renderElement.removeAttribute(name);
  349. }
  350. else {
  351. renderElement.setAttribute(name, val);
  352. }
  353. };
  354. MockRenderer.prototype.setElementClass = function (renderElement, className, isAdd) {
  355. if (isAdd) {
  356. renderElement.classList.add(className);
  357. }
  358. else {
  359. renderElement.classList.remove(className);
  360. }
  361. };
  362. MockRenderer.prototype.setElementStyle = function (renderElement, styleName, styleValue) {
  363. renderElement.style[styleName] = styleValue;
  364. };
  365. return MockRenderer;
  366. }());
  367. exports.MockRenderer = MockRenderer;
  368. function mockRenderer() {
  369. var renderer = new MockRenderer();
  370. return renderer;
  371. }
  372. exports.mockRenderer = mockRenderer;
  373. function mockLocation() {
  374. var location = {
  375. path: function () { return ''; },
  376. subscribe: function () { },
  377. go: function () { },
  378. back: function () { },
  379. prepareExternalUrl: function () { }
  380. };
  381. return location;
  382. }
  383. exports.mockLocation = mockLocation;
  384. function mockView(component, data) {
  385. if (!component) {
  386. component = MockView;
  387. }
  388. var view = new view_controller_1.ViewController(component, data);
  389. view.init(mockComponentRef());
  390. return view;
  391. }
  392. exports.mockView = mockView;
  393. function mockViews(nav, views) {
  394. nav._views = views;
  395. views.forEach(function (v) {
  396. v._setNav(nav);
  397. });
  398. }
  399. exports.mockViews = mockViews;
  400. function mockComponentRef() {
  401. var componentRef = {
  402. location: mockElementRef(),
  403. changeDetectorRef: mockChangeDetectorRef(),
  404. destroy: function () { }
  405. };
  406. return componentRef;
  407. }
  408. exports.mockComponentRef = mockComponentRef;
  409. function mockDeepLinker(linkConfig, app) {
  410. if (linkConfig === void 0) { linkConfig = null; }
  411. app = app || mockApp(mockConfig(), mockPlatform());
  412. var serializer = new url_serializer_1.UrlSerializer(app, linkConfig);
  413. var location = mockLocation();
  414. return new deep_linker_1.DeepLinker(app || mockApp(), serializer, location, null, null);
  415. }
  416. exports.mockDeepLinker = mockDeepLinker;
  417. function mockNavController() {
  418. var platform = mockPlatform();
  419. var config = mockConfig(null, '/', platform);
  420. var app = mockApp(config, platform);
  421. var zone = mockZone();
  422. var dom = mockDomController(platform);
  423. var elementRef = mockElementRef();
  424. var renderer = mockRenderer();
  425. var componentFactoryResolver = null;
  426. var gestureCtrl = new gesture_controller_1.GestureController(app);
  427. var linker = mockDeepLinker(null, app);
  428. var trnsCtrl = exports.mockTrasitionController(config);
  429. var nav = new nav_controller_base_1.NavControllerBase(null, app, config, platform, elementRef, zone, renderer, componentFactoryResolver, gestureCtrl, trnsCtrl, linker, dom, null);
  430. nav._viewInit = function (enteringView) {
  431. enteringView.init(mockComponentRef());
  432. enteringView._state = nav_util_1.STATE_INITIALIZED;
  433. };
  434. nav._orgViewInsert = nav._viewAttachToDOM;
  435. nav._viewAttachToDOM = function (view, componentRef, _viewport) {
  436. var mockedViewport = {
  437. insert: function () { }
  438. };
  439. nav._orgViewInsert(view, componentRef, mockedViewport);
  440. };
  441. return nav;
  442. }
  443. exports.mockNavController = mockNavController;
  444. function mockOverlayPortal(app, config, plt) {
  445. var zone = mockZone();
  446. var dom = mockDomController(plt);
  447. var elementRef = mockElementRef();
  448. var renderer = mockRenderer();
  449. var componentFactoryResolver = null;
  450. var gestureCtrl = new gesture_controller_1.GestureController(app);
  451. var serializer = new url_serializer_1.UrlSerializer(app, null);
  452. var location = mockLocation();
  453. var deepLinker = new deep_linker_1.DeepLinker(app, serializer, location, null, null);
  454. return new overlay_portal_1.OverlayPortal(app, config, plt, elementRef, zone, renderer, componentFactoryResolver, gestureCtrl, null, deepLinker, null, dom, null);
  455. }
  456. exports.mockOverlayPortal = mockOverlayPortal;
  457. function mockTab(parentTabs, overrideLoad) {
  458. if (overrideLoad === void 0) { overrideLoad = true; }
  459. var platform = mockPlatform();
  460. var config = mockConfig(null, '/', platform);
  461. var app = parentTabs._app || mockApp(config, platform);
  462. var zone = mockZone();
  463. var dom = mockDomController(platform);
  464. var elementRef = mockElementRef();
  465. var renderer = mockRenderer();
  466. var changeDetectorRef = mockChangeDetectorRef();
  467. var compiler = null;
  468. var gestureCtrl = new gesture_controller_1.GestureController(app);
  469. var linker = mockDeepLinker(null, app);
  470. var tab = new tab_1.Tab(parentTabs, app, config, platform, elementRef, zone, renderer, compiler, changeDetectorRef, gestureCtrl, null, linker, dom, null);
  471. if (overrideLoad) {
  472. tab.load = function (_opts) {
  473. return Promise.resolve();
  474. };
  475. }
  476. return tab;
  477. }
  478. exports.mockTab = mockTab;
  479. function mockForm() {
  480. return new form_1.Form();
  481. }
  482. exports.mockForm = mockForm;
  483. function mockIon() {
  484. var config = mockConfig();
  485. var elementRef = mockElementRef();
  486. var renderer = mockRenderer();
  487. return new ion_1.Ion(config, elementRef, renderer, 'ion');
  488. }
  489. exports.mockIon = mockIon;
  490. function mockItem() {
  491. var form = mockForm();
  492. var config = mockConfig();
  493. var elementRef = mockElementRef();
  494. var renderer = mockRenderer();
  495. return new item_1.Item(form, config, elementRef, renderer, null);
  496. }
  497. exports.mockItem = mockItem;
  498. function mockTabs(app) {
  499. var platform = mockPlatform();
  500. var config = mockConfig(null, '/', platform);
  501. app = app || mockApp(config, platform);
  502. var elementRef = mockElementRef();
  503. var renderer = mockRenderer();
  504. var linker = mockDeepLinker();
  505. return new tabs_1.Tabs(null, null, app, config, elementRef, platform, renderer, linker);
  506. }
  507. exports.mockTabs = mockTabs;
  508. function mockMenu(platform) {
  509. if (platform === void 0) { platform = null; }
  510. var app = mockApp();
  511. var gestureCtrl = new gesture_controller_1.GestureController(app);
  512. var dom = mockDomController();
  513. var elementRef = mockElementRef();
  514. var renderer = mockRenderer();
  515. var plt = platform === null ? mockPlatform() : platform;
  516. return new menu_1.Menu(null, elementRef, null, plt, renderer, null, gestureCtrl, dom, app);
  517. }
  518. exports.mockMenu = mockMenu;
  519. function mockDeepLinkConfig(links) {
  520. return {
  521. links: links || [
  522. { component: MockView1, name: 'viewone' },
  523. { component: MockView2, name: 'viewtwo' },
  524. { component: MockView3, name: 'viewthree' },
  525. { component: MockView4, name: 'viewfour' },
  526. { component: MockView5, name: 'viewfive' }
  527. ]
  528. };
  529. }
  530. exports.mockDeepLinkConfig = mockDeepLinkConfig;
  531. function mockHaptic() {
  532. return new haptic_1.Haptic(mockPlatform());
  533. }
  534. exports.mockHaptic = mockHaptic;
  535. var MockView = (function () {
  536. function MockView() {
  537. }
  538. return MockView;
  539. }());
  540. exports.MockView = MockView;
  541. var MockView1 = (function () {
  542. function MockView1() {
  543. }
  544. return MockView1;
  545. }());
  546. exports.MockView1 = MockView1;
  547. var MockView2 = (function () {
  548. function MockView2() {
  549. }
  550. return MockView2;
  551. }());
  552. exports.MockView2 = MockView2;
  553. var MockView3 = (function () {
  554. function MockView3() {
  555. }
  556. return MockView3;
  557. }());
  558. exports.MockView3 = MockView3;
  559. var MockView4 = (function () {
  560. function MockView4() {
  561. }
  562. return MockView4;
  563. }());
  564. exports.MockView4 = MockView4;
  565. var MockView5 = (function () {
  566. function MockView5() {
  567. }
  568. return MockView5;
  569. }());
  570. exports.MockView5 = MockView5;
  571. function noop() { return 'noop'; }
  572. exports.noop = noop;
  573. function mockModuleLoader(ngModuleLoader) {
  574. ngModuleLoader = ngModuleLoader || mockNgModuleLoader();
  575. return new module_loader_1.ModuleLoader(ngModuleLoader, null);
  576. }
  577. exports.mockModuleLoader = mockModuleLoader;
  578. function mockNgModuleLoader() {
  579. return new ng_module_loader_1.NgModuleLoader(null);
  580. }
  581. exports.mockNgModuleLoader = mockNgModuleLoader;
  582. function mockOverlay() {
  583. return {
  584. present: function (_opts) { return Promise.resolve(); },
  585. dismiss: function (_data, _role, _navOptions) { return Promise.resolve(); },
  586. onDidDismiss: function (_callback) { },
  587. onWillDismiss: function (_callback) { }
  588. };
  589. }
  590. exports.mockOverlay = mockOverlay;
  591. });
  592. //# sourceMappingURL=mock-providers.js.map