How to use TOKEN2 method in ng-mocks

Best JavaScript code snippet using ng-mocks

hooks_cln.js

Source:hooks_cln.js Github

copy

Full Screen

1var __create = Object.create;2var __defProp = Object.defineProperty;3var __getOwnPropDesc = Object.getOwnPropertyDescriptor;4var __getOwnPropNames = Object.getOwnPropertyNames;5var __getProtoOf = Object.getPrototypeOf;6var __hasOwnProp = Object.prototype.hasOwnProperty;7var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });8var __export = (target, all) => {9 for (var name in all)10 __defProp(target, name, { get: all[name], enumerable: true });11};12var __reExport = (target, module2, copyDefault, desc) => {13 if (module2 && typeof module2 === "object" || typeof module2 === "function") {14 for (let key of __getOwnPropNames(module2))15 if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))16 __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });17 }18 return target;19};20var __toESM = (module2, isNodeMode) => {21 return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);22};23var __toCommonJS = /* @__PURE__ */ ((cache) => {24 return (module2, temp) => {25 return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);26 };27})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);28var hooks_cln_exports = {};29__export(hooks_cln_exports, {30 hooks: () => hooks31});32var auth = __toESM(require("../auth/client"));33var base = __toESM(require("../base/client"));34var media = __toESM(require("../media/client"));35let hook_token;36const hooks = {37 set_token: (token) => {38 hook_token = token;39 },40 get_token: () => {41 return hook_token;42 },43 superusers: {44 authenticate: async (email, password) => {45 return await auth.create("superuser").authenticate(email, password);46 },47 count: async (parameters, token) => {48 const args = {49 ...parameters50 };51 let current_token;52 const hook_token2 = hooks.get_token();53 if (typeof hook_token2 === "string" && hook_token2 !== "") {54 current_token = hook_token2;55 }56 if (typeof token === "string" && token !== "") {57 current_token = token;58 }59 return await base.create("superuser", current_token).hook("count")(args);60 },61 find_one: async (parameters, token) => {62 const args = {63 ...parameters64 };65 let current_token;66 const hook_token2 = hooks.get_token();67 if (typeof hook_token2 === "string" && hook_token2 !== "") {68 current_token = hook_token2;69 }70 if (typeof token === "string" && token !== "") {71 current_token = token;72 }73 return await base.create("superuser", current_token).hook("find_one")(args);74 },75 find: async (parameters, token) => {76 const args = {77 ...parameters78 };79 let current_token;80 const hook_token2 = hooks.get_token();81 if (typeof hook_token2 === "string" && hook_token2 !== "") {82 current_token = hook_token2;83 }84 if (typeof token === "string" && token !== "") {85 current_token = token;86 }87 return await base.create("superuser", current_token).hook("find")(args);88 },89 find_id: async (id, parameters, token) => {90 const args = {91 params: {92 id93 },94 ...parameters95 };96 let current_token;97 const hook_token2 = hooks.get_token();98 if (typeof hook_token2 === "string" && hook_token2 !== "") {99 current_token = hook_token2;100 }101 if (typeof token === "string" && token !== "") {102 current_token = token;103 }104 return await base.create("superuser", current_token).hook("find_id")(args);105 },106 insert: async (body, parameters, token) => {107 const args = {108 body,109 ...parameters110 };111 let current_token;112 const hook_token2 = hooks.get_token();113 if (typeof hook_token2 === "string" && hook_token2 !== "") {114 current_token = hook_token2;115 }116 if (typeof token === "string" && token !== "") {117 current_token = token;118 }119 return await base.create("superuser", current_token).hook("insert")(args);120 },121 update: async (id, body, parameters, token) => {122 const args = {123 params: {124 id125 },126 body,127 ...parameters128 };129 let current_token;130 const hook_token2 = hooks.get_token();131 if (typeof hook_token2 === "string" && hook_token2 !== "") {132 current_token = hook_token2;133 }134 if (typeof token === "string" && token !== "") {135 current_token = token;136 }137 return await base.create("superuser", current_token).hook("update")(args);138 },139 delete: async (id, parameters, token) => {140 const args = {141 params: {142 id143 },144 ...parameters145 };146 let current_token;147 const hook_token2 = hooks.get_token();148 if (typeof hook_token2 === "string" && hook_token2 !== "") {149 current_token = hook_token2;150 }151 if (typeof token === "string" && token !== "") {152 current_token = token;153 }154 return await base.create("superuser", current_token).hook("delete")(args);155 },156 insert_multiple: async (body, parameters, token) => {157 const args = {158 body,159 ...parameters160 };161 let current_token;162 const hook_token2 = hooks.get_token();163 if (typeof hook_token2 === "string" && hook_token2 !== "") {164 current_token = hook_token2;165 }166 if (typeof token === "string" && token !== "") {167 current_token = token;168 }169 return await base.create("superuser", current_token).hook("insert_multiple")(args);170 },171 update_multiple: async (ids, body, parameters, token) => {172 const args = {173 params: {174 ids175 },176 body,177 ...parameters178 };179 let current_token;180 const hook_token2 = hooks.get_token();181 if (typeof hook_token2 === "string" && hook_token2 !== "") {182 current_token = hook_token2;183 }184 if (typeof token === "string" && token !== "") {185 current_token = token;186 }187 return await base.create("superuser", current_token).hook("update_multiple")(args);188 },189 delete_multiple: async (ids, parameters, token) => {190 const args = {191 params: {192 ids193 },194 ...parameters195 };196 let current_token;197 const hook_token2 = hooks.get_token();198 if (typeof hook_token2 === "string" && hook_token2 !== "") {199 current_token = hook_token2;200 }201 if (typeof token === "string" && token !== "") {202 current_token = token;203 }204 return await base.create("superuser", current_token).hook("delete_multiple")(args);205 }206 },207 users: {208 authenticate: async (email, password) => {209 return await auth.create("user").authenticate(email, password);210 },211 count: async (parameters, token) => {212 const args = {213 ...parameters214 };215 let current_token;216 const hook_token2 = hooks.get_token();217 if (typeof hook_token2 === "string" && hook_token2 !== "") {218 current_token = hook_token2;219 }220 if (typeof token === "string" && token !== "") {221 current_token = token;222 }223 return await base.create("user", current_token).hook("count")(args);224 },225 find_one: async (parameters, token) => {226 const args = {227 ...parameters228 };229 let current_token;230 const hook_token2 = hooks.get_token();231 if (typeof hook_token2 === "string" && hook_token2 !== "") {232 current_token = hook_token2;233 }234 if (typeof token === "string" && token !== "") {235 current_token = token;236 }237 return await base.create("user", current_token).hook("find_one")(args);238 },239 find: async (parameters, token) => {240 const args = {241 ...parameters242 };243 let current_token;244 const hook_token2 = hooks.get_token();245 if (typeof hook_token2 === "string" && hook_token2 !== "") {246 current_token = hook_token2;247 }248 if (typeof token === "string" && token !== "") {249 current_token = token;250 }251 return await base.create("user", current_token).hook("find")(args);252 },253 find_id: async (id, parameters, token) => {254 const args = {255 params: {256 id257 },258 ...parameters259 };260 let current_token;261 const hook_token2 = hooks.get_token();262 if (typeof hook_token2 === "string" && hook_token2 !== "") {263 current_token = hook_token2;264 }265 if (typeof token === "string" && token !== "") {266 current_token = token;267 }268 return await base.create("user", current_token).hook("find_id")(args);269 },270 insert: async (body, parameters, token) => {271 const args = {272 body,273 ...parameters274 };275 let current_token;276 const hook_token2 = hooks.get_token();277 if (typeof hook_token2 === "string" && hook_token2 !== "") {278 current_token = hook_token2;279 }280 if (typeof token === "string" && token !== "") {281 current_token = token;282 }283 return await base.create("user", current_token).hook("insert")(args);284 },285 update: async (id, body, parameters, token) => {286 const args = {287 params: {288 id289 },290 body,291 ...parameters292 };293 let current_token;294 const hook_token2 = hooks.get_token();295 if (typeof hook_token2 === "string" && hook_token2 !== "") {296 current_token = hook_token2;297 }298 if (typeof token === "string" && token !== "") {299 current_token = token;300 }301 return await base.create("user", current_token).hook("update")(args);302 },303 delete: async (id, parameters, token) => {304 const args = {305 params: {306 id307 },308 ...parameters309 };310 let current_token;311 const hook_token2 = hooks.get_token();312 if (typeof hook_token2 === "string" && hook_token2 !== "") {313 current_token = hook_token2;314 }315 if (typeof token === "string" && token !== "") {316 current_token = token;317 }318 return await base.create("user", current_token).hook("delete")(args);319 },320 insert_multiple: async (body, parameters, token) => {321 const args = {322 body,323 ...parameters324 };325 let current_token;326 const hook_token2 = hooks.get_token();327 if (typeof hook_token2 === "string" && hook_token2 !== "") {328 current_token = hook_token2;329 }330 if (typeof token === "string" && token !== "") {331 current_token = token;332 }333 return await base.create("user", current_token).hook("insert_multiple")(args);334 },335 update_multiple: async (ids, body, parameters, token) => {336 const args = {337 params: {338 ids339 },340 body,341 ...parameters342 };343 let current_token;344 const hook_token2 = hooks.get_token();345 if (typeof hook_token2 === "string" && hook_token2 !== "") {346 current_token = hook_token2;347 }348 if (typeof token === "string" && token !== "") {349 current_token = token;350 }351 return await base.create("user", current_token).hook("update_multiple")(args);352 },353 delete_multiple: async (ids, parameters, token) => {354 const args = {355 params: {356 ids357 },358 ...parameters359 };360 let current_token;361 const hook_token2 = hooks.get_token();362 if (typeof hook_token2 === "string" && hook_token2 !== "") {363 current_token = hook_token2;364 }365 if (typeof token === "string" && token !== "") {366 current_token = token;367 }368 return await base.create("user", current_token).hook("delete_multiple")(args);369 }370 },371 groups: {372 count: async (parameters, token) => {373 const args = {374 ...parameters375 };376 let current_token;377 const hook_token2 = hooks.get_token();378 if (typeof hook_token2 === "string" && hook_token2 !== "") {379 current_token = hook_token2;380 }381 if (typeof token === "string" && token !== "") {382 current_token = token;383 }384 return await base.create("group", current_token).hook("count")(args);385 },386 find_one: async (parameters, token) => {387 const args = {388 ...parameters389 };390 let current_token;391 const hook_token2 = hooks.get_token();392 if (typeof hook_token2 === "string" && hook_token2 !== "") {393 current_token = hook_token2;394 }395 if (typeof token === "string" && token !== "") {396 current_token = token;397 }398 return await base.create("group", current_token).hook("find_one")(args);399 },400 find: async (parameters, token) => {401 const args = {402 ...parameters403 };404 let current_token;405 const hook_token2 = hooks.get_token();406 if (typeof hook_token2 === "string" && hook_token2 !== "") {407 current_token = hook_token2;408 }409 if (typeof token === "string" && token !== "") {410 current_token = token;411 }412 return await base.create("group", current_token).hook("find")(args);413 },414 find_id: async (id, parameters, token) => {415 const args = {416 params: {417 id418 },419 ...parameters420 };421 let current_token;422 const hook_token2 = hooks.get_token();423 if (typeof hook_token2 === "string" && hook_token2 !== "") {424 current_token = hook_token2;425 }426 if (typeof token === "string" && token !== "") {427 current_token = token;428 }429 return await base.create("group", current_token).hook("find_id")(args);430 },431 insert: async (body, parameters, token) => {432 const args = {433 body,434 ...parameters435 };436 let current_token;437 const hook_token2 = hooks.get_token();438 if (typeof hook_token2 === "string" && hook_token2 !== "") {439 current_token = hook_token2;440 }441 if (typeof token === "string" && token !== "") {442 current_token = token;443 }444 return await base.create("group", current_token).hook("insert")(args);445 },446 update: async (id, body, parameters, token) => {447 const args = {448 params: {449 id450 },451 body,452 ...parameters453 };454 let current_token;455 const hook_token2 = hooks.get_token();456 if (typeof hook_token2 === "string" && hook_token2 !== "") {457 current_token = hook_token2;458 }459 if (typeof token === "string" && token !== "") {460 current_token = token;461 }462 return await base.create("group", current_token).hook("update")(args);463 },464 delete: async (id, parameters, token) => {465 const args = {466 params: {467 id468 },469 ...parameters470 };471 let current_token;472 const hook_token2 = hooks.get_token();473 if (typeof hook_token2 === "string" && hook_token2 !== "") {474 current_token = hook_token2;475 }476 if (typeof token === "string" && token !== "") {477 current_token = token;478 }479 return await base.create("group", current_token).hook("delete")(args);480 },481 insert_multiple: async (body, parameters, token) => {482 const args = {483 body,484 ...parameters485 };486 let current_token;487 const hook_token2 = hooks.get_token();488 if (typeof hook_token2 === "string" && hook_token2 !== "") {489 current_token = hook_token2;490 }491 if (typeof token === "string" && token !== "") {492 current_token = token;493 }494 return await base.create("group", current_token).hook("insert_multiple")(args);495 },496 update_multiple: async (ids, body, parameters, token) => {497 const args = {498 params: {499 ids500 },501 body,502 ...parameters503 };504 let current_token;505 const hook_token2 = hooks.get_token();506 if (typeof hook_token2 === "string" && hook_token2 !== "") {507 current_token = hook_token2;508 }509 if (typeof token === "string" && token !== "") {510 current_token = token;511 }512 return await base.create("group", current_token).hook("update_multiple")(args);513 },514 delete_multiple: async (ids, parameters, token) => {515 const args = {516 params: {517 ids518 },519 ...parameters520 };521 let current_token;522 const hook_token2 = hooks.get_token();523 if (typeof hook_token2 === "string" && hook_token2 !== "") {524 current_token = hook_token2;525 }526 if (typeof token === "string" && token !== "") {527 current_token = token;528 }529 return await base.create("group", current_token).hook("delete_multiple")(args);530 }531 },532 media: {533 upload: async (file, token) => {534 let current_token;535 const hook_token2 = hooks.get_token();536 if (typeof hook_token2 === "string" && hook_token2 !== "") {537 current_token = hook_token2;538 }539 if (typeof token === "string" && token !== "") {540 current_token = token;541 }542 return await media.create(current_token).upload(file, current_token);543 },544 presigned: async (filename, size, type, token) => {545 let current_token;546 const hook_token2 = hooks.get_token();547 if (typeof hook_token2 === "string" && hook_token2 !== "") {548 current_token = hook_token2;549 }550 if (typeof token === "string" && token !== "") {551 current_token = token;552 }553 return await media.create(current_token).presigned(filename, size, type, current_token);554 },555 count: async (parameters, token) => {556 const args = {557 ...parameters558 };559 let current_token;560 const hook_token2 = hooks.get_token();561 if (typeof hook_token2 === "string" && hook_token2 !== "") {562 current_token = hook_token2;563 }564 if (typeof token === "string" && token !== "") {565 current_token = token;566 }567 return await base.create("media", current_token).hook("count")(args);568 },569 find_one: async (parameters, token) => {570 const args = {571 ...parameters572 };573 let current_token;574 const hook_token2 = hooks.get_token();575 if (typeof hook_token2 === "string" && hook_token2 !== "") {576 current_token = hook_token2;577 }578 if (typeof token === "string" && token !== "") {579 current_token = token;580 }581 return await base.create("media", current_token).hook("find_one")(args);582 },583 find: async (parameters, token) => {584 const args = {585 ...parameters586 };587 let current_token;588 const hook_token2 = hooks.get_token();589 if (typeof hook_token2 === "string" && hook_token2 !== "") {590 current_token = hook_token2;591 }592 if (typeof token === "string" && token !== "") {593 current_token = token;594 }595 return await base.create("media", current_token).hook("find")(args);596 },597 find_id: async (id, parameters, token) => {598 const args = {599 params: {600 id601 },602 ...parameters603 };604 let current_token;605 const hook_token2 = hooks.get_token();606 if (typeof hook_token2 === "string" && hook_token2 !== "") {607 current_token = hook_token2;608 }609 if (typeof token === "string" && token !== "") {610 current_token = token;611 }612 return await base.create("media", current_token).hook("find_id")(args);613 },614 insert: async (body, parameters, token) => {615 const args = {616 body,617 ...parameters618 };619 let current_token;620 const hook_token2 = hooks.get_token();621 if (typeof hook_token2 === "string" && hook_token2 !== "") {622 current_token = hook_token2;623 }624 if (typeof token === "string" && token !== "") {625 current_token = token;626 }627 return await base.create("media", current_token).hook("insert")(args);628 },629 update: async (id, body, parameters, token) => {630 const args = {631 params: {632 id633 },634 body,635 ...parameters636 };637 let current_token;638 const hook_token2 = hooks.get_token();639 if (typeof hook_token2 === "string" && hook_token2 !== "") {640 current_token = hook_token2;641 }642 if (typeof token === "string" && token !== "") {643 current_token = token;644 }645 return await base.create("media", current_token).hook("update")(args);646 },647 delete: async (id, parameters, token) => {648 const args = {649 params: {650 id651 },652 ...parameters653 };654 let current_token;655 const hook_token2 = hooks.get_token();656 if (typeof hook_token2 === "string" && hook_token2 !== "") {657 current_token = hook_token2;658 }659 if (typeof token === "string" && token !== "") {660 current_token = token;661 }662 return await base.create("media", current_token).hook("delete")(args);663 },664 insert_multiple: async (body, parameters, token) => {665 const args = {666 body,667 ...parameters668 };669 let current_token;670 const hook_token2 = hooks.get_token();671 if (typeof hook_token2 === "string" && hook_token2 !== "") {672 current_token = hook_token2;673 }674 if (typeof token === "string" && token !== "") {675 current_token = token;676 }677 return await base.create("media", current_token).hook("insert_multiple")(args);678 },679 update_multiple: async (ids, body, parameters, token) => {680 const args = {681 params: {682 ids683 },684 body,685 ...parameters686 };687 let current_token;688 const hook_token2 = hooks.get_token();689 if (typeof hook_token2 === "string" && hook_token2 !== "") {690 current_token = hook_token2;691 }692 if (typeof token === "string" && token !== "") {693 current_token = token;694 }695 return await base.create("media", current_token).hook("update_multiple")(args);696 },697 delete_multiple: async (ids, parameters, token) => {698 const args = {699 params: {700 ids701 },702 ...parameters703 };704 let current_token;705 const hook_token2 = hooks.get_token();706 if (typeof hook_token2 === "string" && hook_token2 !== "") {707 current_token = hook_token2;708 }709 if (typeof token === "string" && token !== "") {710 current_token = token;711 }712 return await base.create("media", current_token).hook("delete_multiple")(args);713 }714 },715 errors: {716 count: async (parameters, token) => {717 const args = {718 ...parameters719 };720 let current_token;721 const hook_token2 = hooks.get_token();722 if (typeof hook_token2 === "string" && hook_token2 !== "") {723 current_token = hook_token2;724 }725 if (typeof token === "string" && token !== "") {726 current_token = token;727 }728 return await base.create("error", current_token).hook("count")(args);729 },730 find_one: async (parameters, token) => {731 const args = {732 ...parameters733 };734 let current_token;735 const hook_token2 = hooks.get_token();736 if (typeof hook_token2 === "string" && hook_token2 !== "") {737 current_token = hook_token2;738 }739 if (typeof token === "string" && token !== "") {740 current_token = token;741 }742 return await base.create("error", current_token).hook("find_one")(args);743 },744 find: async (parameters, token) => {745 const args = {746 ...parameters747 };748 let current_token;749 const hook_token2 = hooks.get_token();750 if (typeof hook_token2 === "string" && hook_token2 !== "") {751 current_token = hook_token2;752 }753 if (typeof token === "string" && token !== "") {754 current_token = token;755 }756 return await base.create("error", current_token).hook("find")(args);757 },758 find_id: async (id, parameters, token) => {759 const args = {760 params: {761 id762 },763 ...parameters764 };765 let current_token;766 const hook_token2 = hooks.get_token();767 if (typeof hook_token2 === "string" && hook_token2 !== "") {768 current_token = hook_token2;769 }770 if (typeof token === "string" && token !== "") {771 current_token = token;772 }773 return await base.create("error", current_token).hook("find_id")(args);774 },775 insert: async (body, parameters, token) => {776 const args = {777 body,778 ...parameters779 };780 let current_token;781 const hook_token2 = hooks.get_token();782 if (typeof hook_token2 === "string" && hook_token2 !== "") {783 current_token = hook_token2;784 }785 if (typeof token === "string" && token !== "") {786 current_token = token;787 }788 return await base.create("error", current_token).hook("insert")(args);789 },790 update: async (id, body, parameters, token) => {791 const args = {792 params: {793 id794 },795 body,796 ...parameters797 };798 let current_token;799 const hook_token2 = hooks.get_token();800 if (typeof hook_token2 === "string" && hook_token2 !== "") {801 current_token = hook_token2;802 }803 if (typeof token === "string" && token !== "") {804 current_token = token;805 }806 return await base.create("error", current_token).hook("update")(args);807 },808 delete: async (id, parameters, token) => {809 const args = {810 params: {811 id812 },813 ...parameters814 };815 let current_token;816 const hook_token2 = hooks.get_token();817 if (typeof hook_token2 === "string" && hook_token2 !== "") {818 current_token = hook_token2;819 }820 if (typeof token === "string" && token !== "") {821 current_token = token;822 }823 return await base.create("error", current_token).hook("delete")(args);824 },825 insert_multiple: async (body, parameters, token) => {826 const args = {827 body,828 ...parameters829 };830 let current_token;831 const hook_token2 = hooks.get_token();832 if (typeof hook_token2 === "string" && hook_token2 !== "") {833 current_token = hook_token2;834 }835 if (typeof token === "string" && token !== "") {836 current_token = token;837 }838 return await base.create("error", current_token).hook("insert_multiple")(args);839 },840 update_multiple: async (ids, body, parameters, token) => {841 const args = {842 params: {843 ids844 },845 body,846 ...parameters847 };848 let current_token;849 const hook_token2 = hooks.get_token();850 if (typeof hook_token2 === "string" && hook_token2 !== "") {851 current_token = hook_token2;852 }853 if (typeof token === "string" && token !== "") {854 current_token = token;855 }856 return await base.create("error", current_token).hook("update_multiple")(args);857 },858 delete_multiple: async (ids, parameters, token) => {859 const args = {860 params: {861 ids862 },863 ...parameters864 };865 let current_token;866 const hook_token2 = hooks.get_token();867 if (typeof hook_token2 === "string" && hook_token2 !== "") {868 current_token = hook_token2;869 }870 if (typeof token === "string" && token !== "") {871 current_token = token;872 }873 return await base.create("error", current_token).hook("delete_multiple")(args);874 }875 },876 requests: {877 count: async (parameters, token) => {878 const args = {879 ...parameters880 };881 let current_token;882 const hook_token2 = hooks.get_token();883 if (typeof hook_token2 === "string" && hook_token2 !== "") {884 current_token = hook_token2;885 }886 if (typeof token === "string" && token !== "") {887 current_token = token;888 }889 return await base.create("request", current_token).hook("count")(args);890 },891 find_one: async (parameters, token) => {892 const args = {893 ...parameters894 };895 let current_token;896 const hook_token2 = hooks.get_token();897 if (typeof hook_token2 === "string" && hook_token2 !== "") {898 current_token = hook_token2;899 }900 if (typeof token === "string" && token !== "") {901 current_token = token;902 }903 return await base.create("request", current_token).hook("find_one")(args);904 },905 find: async (parameters, token) => {906 const args = {907 ...parameters908 };909 let current_token;910 const hook_token2 = hooks.get_token();911 if (typeof hook_token2 === "string" && hook_token2 !== "") {912 current_token = hook_token2;913 }914 if (typeof token === "string" && token !== "") {915 current_token = token;916 }917 return await base.create("request", current_token).hook("find")(args);918 },919 find_id: async (id, parameters, token) => {920 const args = {921 params: {922 id923 },924 ...parameters925 };926 let current_token;927 const hook_token2 = hooks.get_token();928 if (typeof hook_token2 === "string" && hook_token2 !== "") {929 current_token = hook_token2;930 }931 if (typeof token === "string" && token !== "") {932 current_token = token;933 }934 return await base.create("request", current_token).hook("find_id")(args);935 },936 insert: async (body, parameters, token) => {937 const args = {938 body,939 ...parameters940 };941 let current_token;942 const hook_token2 = hooks.get_token();943 if (typeof hook_token2 === "string" && hook_token2 !== "") {944 current_token = hook_token2;945 }946 if (typeof token === "string" && token !== "") {947 current_token = token;948 }949 return await base.create("request", current_token).hook("insert")(args);950 },951 update: async (id, body, parameters, token) => {952 const args = {953 params: {954 id955 },956 body,957 ...parameters958 };959 let current_token;960 const hook_token2 = hooks.get_token();961 if (typeof hook_token2 === "string" && hook_token2 !== "") {962 current_token = hook_token2;963 }964 if (typeof token === "string" && token !== "") {965 current_token = token;966 }967 return await base.create("request", current_token).hook("update")(args);968 },969 delete: async (id, parameters, token) => {970 const args = {971 params: {972 id973 },974 ...parameters975 };976 let current_token;977 const hook_token2 = hooks.get_token();978 if (typeof hook_token2 === "string" && hook_token2 !== "") {979 current_token = hook_token2;980 }981 if (typeof token === "string" && token !== "") {982 current_token = token;983 }984 return await base.create("request", current_token).hook("delete")(args);985 },986 insert_multiple: async (body, parameters, token) => {987 const args = {988 body,989 ...parameters990 };991 let current_token;992 const hook_token2 = hooks.get_token();993 if (typeof hook_token2 === "string" && hook_token2 !== "") {994 current_token = hook_token2;995 }996 if (typeof token === "string" && token !== "") {997 current_token = token;998 }999 return await base.create("request", current_token).hook("insert_multiple")(args);1000 },1001 update_multiple: async (ids, body, parameters, token) => {1002 const args = {1003 params: {1004 ids1005 },1006 body,1007 ...parameters1008 };1009 let current_token;1010 const hook_token2 = hooks.get_token();1011 if (typeof hook_token2 === "string" && hook_token2 !== "") {1012 current_token = hook_token2;1013 }1014 if (typeof token === "string" && token !== "") {1015 current_token = token;1016 }1017 return await base.create("request", current_token).hook("update_multiple")(args);1018 },1019 delete_multiple: async (ids, parameters, token) => {1020 const args = {1021 params: {1022 ids1023 },1024 ...parameters1025 };1026 let current_token;1027 const hook_token2 = hooks.get_token();1028 if (typeof hook_token2 === "string" && hook_token2 !== "") {1029 current_token = hook_token2;1030 }1031 if (typeof token === "string" && token !== "") {1032 current_token = token;1033 }1034 return await base.create("request", current_token).hook("delete_multiple")(args);1035 }1036 },1037 settings: {1038 count: async (parameters, token) => {1039 const args = {1040 ...parameters1041 };1042 let current_token;1043 const hook_token2 = hooks.get_token();1044 if (typeof hook_token2 === "string" && hook_token2 !== "") {1045 current_token = hook_token2;1046 }1047 if (typeof token === "string" && token !== "") {1048 current_token = token;1049 }1050 return await base.create("setting", current_token).hook("count")(args);1051 },1052 find_one: async (parameters, token) => {1053 const args = {1054 ...parameters1055 };1056 let current_token;1057 const hook_token2 = hooks.get_token();1058 if (typeof hook_token2 === "string" && hook_token2 !== "") {1059 current_token = hook_token2;1060 }1061 if (typeof token === "string" && token !== "") {1062 current_token = token;1063 }1064 return await base.create("setting", current_token).hook("find_one")(args);1065 },1066 find: async (parameters, token) => {1067 const args = {1068 ...parameters1069 };1070 let current_token;1071 const hook_token2 = hooks.get_token();1072 if (typeof hook_token2 === "string" && hook_token2 !== "") {1073 current_token = hook_token2;1074 }1075 if (typeof token === "string" && token !== "") {1076 current_token = token;1077 }1078 return await base.create("setting", current_token).hook("find")(args);1079 },1080 find_id: async (id, parameters, token) => {1081 const args = {1082 params: {1083 id1084 },1085 ...parameters1086 };1087 let current_token;1088 const hook_token2 = hooks.get_token();1089 if (typeof hook_token2 === "string" && hook_token2 !== "") {1090 current_token = hook_token2;1091 }1092 if (typeof token === "string" && token !== "") {1093 current_token = token;1094 }1095 return await base.create("setting", current_token).hook("find_id")(args);1096 },1097 insert: async (body, parameters, token) => {1098 const args = {1099 body,1100 ...parameters1101 };1102 let current_token;1103 const hook_token2 = hooks.get_token();1104 if (typeof hook_token2 === "string" && hook_token2 !== "") {1105 current_token = hook_token2;1106 }1107 if (typeof token === "string" && token !== "") {1108 current_token = token;1109 }1110 return await base.create("setting", current_token).hook("insert")(args);1111 },1112 update: async (id, body, parameters, token) => {1113 const args = {1114 params: {1115 id1116 },1117 body,1118 ...parameters1119 };1120 let current_token;1121 const hook_token2 = hooks.get_token();1122 if (typeof hook_token2 === "string" && hook_token2 !== "") {1123 current_token = hook_token2;1124 }1125 if (typeof token === "string" && token !== "") {1126 current_token = token;1127 }1128 return await base.create("setting", current_token).hook("update")(args);1129 },1130 delete: async (id, parameters, token) => {1131 const args = {1132 params: {1133 id1134 },1135 ...parameters1136 };1137 let current_token;1138 const hook_token2 = hooks.get_token();1139 if (typeof hook_token2 === "string" && hook_token2 !== "") {1140 current_token = hook_token2;1141 }1142 if (typeof token === "string" && token !== "") {1143 current_token = token;1144 }1145 return await base.create("setting", current_token).hook("delete")(args);1146 },1147 insert_multiple: async (body, parameters, token) => {1148 const args = {1149 body,1150 ...parameters1151 };1152 let current_token;1153 const hook_token2 = hooks.get_token();1154 if (typeof hook_token2 === "string" && hook_token2 !== "") {1155 current_token = hook_token2;1156 }1157 if (typeof token === "string" && token !== "") {1158 current_token = token;1159 }1160 return await base.create("setting", current_token).hook("insert_multiple")(args);1161 },1162 update_multiple: async (ids, body, parameters, token) => {1163 const args = {1164 params: {1165 ids1166 },1167 body,1168 ...parameters1169 };1170 let current_token;1171 const hook_token2 = hooks.get_token();1172 if (typeof hook_token2 === "string" && hook_token2 !== "") {1173 current_token = hook_token2;1174 }1175 if (typeof token === "string" && token !== "") {1176 current_token = token;1177 }1178 return await base.create("setting", current_token).hook("update_multiple")(args);1179 },1180 delete_multiple: async (ids, parameters, token) => {1181 const args = {1182 params: {1183 ids1184 },1185 ...parameters1186 };1187 let current_token;1188 const hook_token2 = hooks.get_token();1189 if (typeof hook_token2 === "string" && hook_token2 !== "") {1190 current_token = hook_token2;1191 }1192 if (typeof token === "string" && token !== "") {1193 current_token = token;1194 }1195 return await base.create("setting", current_token).hook("delete_multiple")(args);1196 }1197 }1198};1199module.exports = __toCommonJS(hooks_cln_exports);1200// Annotate the CommonJS export names for ESM import in node:12010 && (module.exports = {1202 hooks...

Full Screen

Full Screen

hooks.js

Source:hooks.js Github

copy

Full Screen

1var __create = Object.create;2var __defProp = Object.defineProperty;3var __getOwnPropDesc = Object.getOwnPropertyDescriptor;4var __getOwnPropNames = Object.getOwnPropertyNames;5var __getProtoOf = Object.getPrototypeOf;6var __hasOwnProp = Object.prototype.hasOwnProperty;7var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });8var __export = (target, all) => {9 for (var name in all)10 __defProp(target, name, { get: all[name], enumerable: true });11};12var __reExport = (target, module2, copyDefault, desc) => {13 if (module2 && typeof module2 === "object" || typeof module2 === "function") {14 for (let key of __getOwnPropNames(module2))15 if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))16 __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });17 }18 return target;19};20var __toESM = (module2, isNodeMode) => {21 return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);22};23var __toCommonJS = /* @__PURE__ */ ((cache) => {24 return (module2, temp) => {25 return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);26 };27})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);28var hooks_exports = {};29__export(hooks_exports, {30 hooks: () => hooks31});32var auth = __toESM(require("../auth/server"));33var base = __toESM(require("../base/server"));34var media = __toESM(require("../media/server"));35let hook_token;36const hooks = {37 set_token: (token) => {38 hook_token = token;39 },40 get_token: () => {41 return hook_token;42 },43 superusers: {44 authenticate: async (email, password) => {45 return await auth.create("superuser").authenticate(email, password);46 },47 count: async (parameters, token) => {48 const args = {49 ...parameters50 };51 let current_token;52 const hook_token2 = hooks.get_token();53 if (typeof hook_token2 === "string" && hook_token2 !== "") {54 current_token = hook_token2;55 }56 if (typeof token === "string" && token !== "") {57 current_token = token;58 }59 return await base.create("superuser", current_token).hook("count")(args);60 },61 find_one: async (parameters, token) => {62 const args = {63 ...parameters64 };65 let current_token;66 const hook_token2 = hooks.get_token();67 if (typeof hook_token2 === "string" && hook_token2 !== "") {68 current_token = hook_token2;69 }70 if (typeof token === "string" && token !== "") {71 current_token = token;72 }73 return await base.create("superuser", current_token).hook("find_one")(args);74 },75 find: async (parameters, token) => {76 const args = {77 ...parameters78 };79 let current_token;80 const hook_token2 = hooks.get_token();81 if (typeof hook_token2 === "string" && hook_token2 !== "") {82 current_token = hook_token2;83 }84 if (typeof token === "string" && token !== "") {85 current_token = token;86 }87 return await base.create("superuser", current_token).hook("find")(args);88 },89 find_id: async (id, parameters, token) => {90 const args = {91 params: {92 id93 },94 ...parameters95 };96 let current_token;97 const hook_token2 = hooks.get_token();98 if (typeof hook_token2 === "string" && hook_token2 !== "") {99 current_token = hook_token2;100 }101 if (typeof token === "string" && token !== "") {102 current_token = token;103 }104 return await base.create("superuser", current_token).hook("find_id")(args);105 },106 insert: async (body, parameters, token) => {107 const args = {108 body,109 ...parameters110 };111 let current_token;112 const hook_token2 = hooks.get_token();113 if (typeof hook_token2 === "string" && hook_token2 !== "") {114 current_token = hook_token2;115 }116 if (typeof token === "string" && token !== "") {117 current_token = token;118 }119 return await base.create("superuser", current_token).hook("insert")(args);120 },121 update: async (id, body, parameters, token) => {122 const args = {123 params: {124 id125 },126 body,127 ...parameters128 };129 let current_token;130 const hook_token2 = hooks.get_token();131 if (typeof hook_token2 === "string" && hook_token2 !== "") {132 current_token = hook_token2;133 }134 if (typeof token === "string" && token !== "") {135 current_token = token;136 }137 return await base.create("superuser", current_token).hook("update")(args);138 },139 delete: async (id, parameters, token) => {140 const args = {141 params: {142 id143 },144 ...parameters145 };146 let current_token;147 const hook_token2 = hooks.get_token();148 if (typeof hook_token2 === "string" && hook_token2 !== "") {149 current_token = hook_token2;150 }151 if (typeof token === "string" && token !== "") {152 current_token = token;153 }154 return await base.create("superuser", current_token).hook("delete")(args);155 },156 insert_multiple: async (body, parameters, token) => {157 const args = {158 body,159 ...parameters160 };161 let current_token;162 const hook_token2 = hooks.get_token();163 if (typeof hook_token2 === "string" && hook_token2 !== "") {164 current_token = hook_token2;165 }166 if (typeof token === "string" && token !== "") {167 current_token = token;168 }169 return await base.create("superuser", current_token).hook("insert_multiple")(args);170 },171 update_multiple: async (ids, body, parameters, token) => {172 const args = {173 params: {174 ids175 },176 body,177 ...parameters178 };179 let current_token;180 const hook_token2 = hooks.get_token();181 if (typeof hook_token2 === "string" && hook_token2 !== "") {182 current_token = hook_token2;183 }184 if (typeof token === "string" && token !== "") {185 current_token = token;186 }187 return await base.create("superuser", current_token).hook("update_multiple")(args);188 },189 delete_multiple: async (ids, parameters, token) => {190 const args = {191 params: {192 ids193 },194 ...parameters195 };196 let current_token;197 const hook_token2 = hooks.get_token();198 if (typeof hook_token2 === "string" && hook_token2 !== "") {199 current_token = hook_token2;200 }201 if (typeof token === "string" && token !== "") {202 current_token = token;203 }204 return await base.create("superuser", current_token).hook("delete_multiple")(args);205 }206 },207 users: {208 authenticate: async (email, password) => {209 return await auth.create("user").authenticate(email, password);210 },211 count: async (parameters, token) => {212 const args = {213 ...parameters214 };215 let current_token;216 const hook_token2 = hooks.get_token();217 if (typeof hook_token2 === "string" && hook_token2 !== "") {218 current_token = hook_token2;219 }220 if (typeof token === "string" && token !== "") {221 current_token = token;222 }223 return await base.create("user", current_token).hook("count")(args);224 },225 find_one: async (parameters, token) => {226 const args = {227 ...parameters228 };229 let current_token;230 const hook_token2 = hooks.get_token();231 if (typeof hook_token2 === "string" && hook_token2 !== "") {232 current_token = hook_token2;233 }234 if (typeof token === "string" && token !== "") {235 current_token = token;236 }237 return await base.create("user", current_token).hook("find_one")(args);238 },239 find: async (parameters, token) => {240 const args = {241 ...parameters242 };243 let current_token;244 const hook_token2 = hooks.get_token();245 if (typeof hook_token2 === "string" && hook_token2 !== "") {246 current_token = hook_token2;247 }248 if (typeof token === "string" && token !== "") {249 current_token = token;250 }251 return await base.create("user", current_token).hook("find")(args);252 },253 find_id: async (id, parameters, token) => {254 const args = {255 params: {256 id257 },258 ...parameters259 };260 let current_token;261 const hook_token2 = hooks.get_token();262 if (typeof hook_token2 === "string" && hook_token2 !== "") {263 current_token = hook_token2;264 }265 if (typeof token === "string" && token !== "") {266 current_token = token;267 }268 return await base.create("user", current_token).hook("find_id")(args);269 },270 insert: async (body, parameters, token) => {271 const args = {272 body,273 ...parameters274 };275 let current_token;276 const hook_token2 = hooks.get_token();277 if (typeof hook_token2 === "string" && hook_token2 !== "") {278 current_token = hook_token2;279 }280 if (typeof token === "string" && token !== "") {281 current_token = token;282 }283 return await base.create("user", current_token).hook("insert")(args);284 },285 update: async (id, body, parameters, token) => {286 const args = {287 params: {288 id289 },290 body,291 ...parameters292 };293 let current_token;294 const hook_token2 = hooks.get_token();295 if (typeof hook_token2 === "string" && hook_token2 !== "") {296 current_token = hook_token2;297 }298 if (typeof token === "string" && token !== "") {299 current_token = token;300 }301 return await base.create("user", current_token).hook("update")(args);302 },303 delete: async (id, parameters, token) => {304 const args = {305 params: {306 id307 },308 ...parameters309 };310 let current_token;311 const hook_token2 = hooks.get_token();312 if (typeof hook_token2 === "string" && hook_token2 !== "") {313 current_token = hook_token2;314 }315 if (typeof token === "string" && token !== "") {316 current_token = token;317 }318 return await base.create("user", current_token).hook("delete")(args);319 },320 insert_multiple: async (body, parameters, token) => {321 const args = {322 body,323 ...parameters324 };325 let current_token;326 const hook_token2 = hooks.get_token();327 if (typeof hook_token2 === "string" && hook_token2 !== "") {328 current_token = hook_token2;329 }330 if (typeof token === "string" && token !== "") {331 current_token = token;332 }333 return await base.create("user", current_token).hook("insert_multiple")(args);334 },335 update_multiple: async (ids, body, parameters, token) => {336 const args = {337 params: {338 ids339 },340 body,341 ...parameters342 };343 let current_token;344 const hook_token2 = hooks.get_token();345 if (typeof hook_token2 === "string" && hook_token2 !== "") {346 current_token = hook_token2;347 }348 if (typeof token === "string" && token !== "") {349 current_token = token;350 }351 return await base.create("user", current_token).hook("update_multiple")(args);352 },353 delete_multiple: async (ids, parameters, token) => {354 const args = {355 params: {356 ids357 },358 ...parameters359 };360 let current_token;361 const hook_token2 = hooks.get_token();362 if (typeof hook_token2 === "string" && hook_token2 !== "") {363 current_token = hook_token2;364 }365 if (typeof token === "string" && token !== "") {366 current_token = token;367 }368 return await base.create("user", current_token).hook("delete_multiple")(args);369 }370 },371 groups: {372 count: async (parameters, token) => {373 const args = {374 ...parameters375 };376 let current_token;377 const hook_token2 = hooks.get_token();378 if (typeof hook_token2 === "string" && hook_token2 !== "") {379 current_token = hook_token2;380 }381 if (typeof token === "string" && token !== "") {382 current_token = token;383 }384 return await base.create("group", current_token).hook("count")(args);385 },386 find_one: async (parameters, token) => {387 const args = {388 ...parameters389 };390 let current_token;391 const hook_token2 = hooks.get_token();392 if (typeof hook_token2 === "string" && hook_token2 !== "") {393 current_token = hook_token2;394 }395 if (typeof token === "string" && token !== "") {396 current_token = token;397 }398 return await base.create("group", current_token).hook("find_one")(args);399 },400 find: async (parameters, token) => {401 const args = {402 ...parameters403 };404 let current_token;405 const hook_token2 = hooks.get_token();406 if (typeof hook_token2 === "string" && hook_token2 !== "") {407 current_token = hook_token2;408 }409 if (typeof token === "string" && token !== "") {410 current_token = token;411 }412 return await base.create("group", current_token).hook("find")(args);413 },414 find_id: async (id, parameters, token) => {415 const args = {416 params: {417 id418 },419 ...parameters420 };421 let current_token;422 const hook_token2 = hooks.get_token();423 if (typeof hook_token2 === "string" && hook_token2 !== "") {424 current_token = hook_token2;425 }426 if (typeof token === "string" && token !== "") {427 current_token = token;428 }429 return await base.create("group", current_token).hook("find_id")(args);430 },431 insert: async (body, parameters, token) => {432 const args = {433 body,434 ...parameters435 };436 let current_token;437 const hook_token2 = hooks.get_token();438 if (typeof hook_token2 === "string" && hook_token2 !== "") {439 current_token = hook_token2;440 }441 if (typeof token === "string" && token !== "") {442 current_token = token;443 }444 return await base.create("group", current_token).hook("insert")(args);445 },446 update: async (id, body, parameters, token) => {447 const args = {448 params: {449 id450 },451 body,452 ...parameters453 };454 let current_token;455 const hook_token2 = hooks.get_token();456 if (typeof hook_token2 === "string" && hook_token2 !== "") {457 current_token = hook_token2;458 }459 if (typeof token === "string" && token !== "") {460 current_token = token;461 }462 return await base.create("group", current_token).hook("update")(args);463 },464 delete: async (id, parameters, token) => {465 const args = {466 params: {467 id468 },469 ...parameters470 };471 let current_token;472 const hook_token2 = hooks.get_token();473 if (typeof hook_token2 === "string" && hook_token2 !== "") {474 current_token = hook_token2;475 }476 if (typeof token === "string" && token !== "") {477 current_token = token;478 }479 return await base.create("group", current_token).hook("delete")(args);480 },481 insert_multiple: async (body, parameters, token) => {482 const args = {483 body,484 ...parameters485 };486 let current_token;487 const hook_token2 = hooks.get_token();488 if (typeof hook_token2 === "string" && hook_token2 !== "") {489 current_token = hook_token2;490 }491 if (typeof token === "string" && token !== "") {492 current_token = token;493 }494 return await base.create("group", current_token).hook("insert_multiple")(args);495 },496 update_multiple: async (ids, body, parameters, token) => {497 const args = {498 params: {499 ids500 },501 body,502 ...parameters503 };504 let current_token;505 const hook_token2 = hooks.get_token();506 if (typeof hook_token2 === "string" && hook_token2 !== "") {507 current_token = hook_token2;508 }509 if (typeof token === "string" && token !== "") {510 current_token = token;511 }512 return await base.create("group", current_token).hook("update_multiple")(args);513 },514 delete_multiple: async (ids, parameters, token) => {515 const args = {516 params: {517 ids518 },519 ...parameters520 };521 let current_token;522 const hook_token2 = hooks.get_token();523 if (typeof hook_token2 === "string" && hook_token2 !== "") {524 current_token = hook_token2;525 }526 if (typeof token === "string" && token !== "") {527 current_token = token;528 }529 return await base.create("group", current_token).hook("delete_multiple")(args);530 }531 },532 media: {533 upload: async (file, token) => {534 let current_token;535 const hook_token2 = hooks.get_token();536 if (typeof hook_token2 === "string" && hook_token2 !== "") {537 current_token = hook_token2;538 }539 if (typeof token === "string" && token !== "") {540 current_token = token;541 }542 return await media.create(current_token).upload(file, current_token);543 },544 presigned: async (filename, size, type, token) => {545 let current_token;546 const hook_token2 = hooks.get_token();547 if (typeof hook_token2 === "string" && hook_token2 !== "") {548 current_token = hook_token2;549 }550 if (typeof token === "string" && token !== "") {551 current_token = token;552 }553 return await media.create(current_token).presigned(filename, size, type, current_token);554 },555 count: async (parameters, token) => {556 const args = {557 ...parameters558 };559 let current_token;560 const hook_token2 = hooks.get_token();561 if (typeof hook_token2 === "string" && hook_token2 !== "") {562 current_token = hook_token2;563 }564 if (typeof token === "string" && token !== "") {565 current_token = token;566 }567 return await base.create("media", current_token).hook("count")(args);568 },569 find_one: async (parameters, token) => {570 const args = {571 ...parameters572 };573 let current_token;574 const hook_token2 = hooks.get_token();575 if (typeof hook_token2 === "string" && hook_token2 !== "") {576 current_token = hook_token2;577 }578 if (typeof token === "string" && token !== "") {579 current_token = token;580 }581 return await base.create("media", current_token).hook("find_one")(args);582 },583 find: async (parameters, token) => {584 const args = {585 ...parameters586 };587 let current_token;588 const hook_token2 = hooks.get_token();589 if (typeof hook_token2 === "string" && hook_token2 !== "") {590 current_token = hook_token2;591 }592 if (typeof token === "string" && token !== "") {593 current_token = token;594 }595 return await base.create("media", current_token).hook("find")(args);596 },597 find_id: async (id, parameters, token) => {598 const args = {599 params: {600 id601 },602 ...parameters603 };604 let current_token;605 const hook_token2 = hooks.get_token();606 if (typeof hook_token2 === "string" && hook_token2 !== "") {607 current_token = hook_token2;608 }609 if (typeof token === "string" && token !== "") {610 current_token = token;611 }612 return await base.create("media", current_token).hook("find_id")(args);613 },614 insert: async (body, parameters, token) => {615 const args = {616 body,617 ...parameters618 };619 let current_token;620 const hook_token2 = hooks.get_token();621 if (typeof hook_token2 === "string" && hook_token2 !== "") {622 current_token = hook_token2;623 }624 if (typeof token === "string" && token !== "") {625 current_token = token;626 }627 return await base.create("media", current_token).hook("insert")(args);628 },629 update: async (id, body, parameters, token) => {630 const args = {631 params: {632 id633 },634 body,635 ...parameters636 };637 let current_token;638 const hook_token2 = hooks.get_token();639 if (typeof hook_token2 === "string" && hook_token2 !== "") {640 current_token = hook_token2;641 }642 if (typeof token === "string" && token !== "") {643 current_token = token;644 }645 return await base.create("media", current_token).hook("update")(args);646 },647 delete: async (id, parameters, token) => {648 const args = {649 params: {650 id651 },652 ...parameters653 };654 let current_token;655 const hook_token2 = hooks.get_token();656 if (typeof hook_token2 === "string" && hook_token2 !== "") {657 current_token = hook_token2;658 }659 if (typeof token === "string" && token !== "") {660 current_token = token;661 }662 return await base.create("media", current_token).hook("delete")(args);663 },664 insert_multiple: async (body, parameters, token) => {665 const args = {666 body,667 ...parameters668 };669 let current_token;670 const hook_token2 = hooks.get_token();671 if (typeof hook_token2 === "string" && hook_token2 !== "") {672 current_token = hook_token2;673 }674 if (typeof token === "string" && token !== "") {675 current_token = token;676 }677 return await base.create("media", current_token).hook("insert_multiple")(args);678 },679 update_multiple: async (ids, body, parameters, token) => {680 const args = {681 params: {682 ids683 },684 body,685 ...parameters686 };687 let current_token;688 const hook_token2 = hooks.get_token();689 if (typeof hook_token2 === "string" && hook_token2 !== "") {690 current_token = hook_token2;691 }692 if (typeof token === "string" && token !== "") {693 current_token = token;694 }695 return await base.create("media", current_token).hook("update_multiple")(args);696 },697 delete_multiple: async (ids, parameters, token) => {698 const args = {699 params: {700 ids701 },702 ...parameters703 };704 let current_token;705 const hook_token2 = hooks.get_token();706 if (typeof hook_token2 === "string" && hook_token2 !== "") {707 current_token = hook_token2;708 }709 if (typeof token === "string" && token !== "") {710 current_token = token;711 }712 return await base.create("media", current_token).hook("delete_multiple")(args);713 }714 },715 errors: {716 count: async (parameters, token) => {717 const args = {718 ...parameters719 };720 let current_token;721 const hook_token2 = hooks.get_token();722 if (typeof hook_token2 === "string" && hook_token2 !== "") {723 current_token = hook_token2;724 }725 if (typeof token === "string" && token !== "") {726 current_token = token;727 }728 return await base.create("error", current_token).hook("count")(args);729 },730 find_one: async (parameters, token) => {731 const args = {732 ...parameters733 };734 let current_token;735 const hook_token2 = hooks.get_token();736 if (typeof hook_token2 === "string" && hook_token2 !== "") {737 current_token = hook_token2;738 }739 if (typeof token === "string" && token !== "") {740 current_token = token;741 }742 return await base.create("error", current_token).hook("find_one")(args);743 },744 find: async (parameters, token) => {745 const args = {746 ...parameters747 };748 let current_token;749 const hook_token2 = hooks.get_token();750 if (typeof hook_token2 === "string" && hook_token2 !== "") {751 current_token = hook_token2;752 }753 if (typeof token === "string" && token !== "") {754 current_token = token;755 }756 return await base.create("error", current_token).hook("find")(args);757 },758 find_id: async (id, parameters, token) => {759 const args = {760 params: {761 id762 },763 ...parameters764 };765 let current_token;766 const hook_token2 = hooks.get_token();767 if (typeof hook_token2 === "string" && hook_token2 !== "") {768 current_token = hook_token2;769 }770 if (typeof token === "string" && token !== "") {771 current_token = token;772 }773 return await base.create("error", current_token).hook("find_id")(args);774 },775 insert: async (body, parameters, token) => {776 const args = {777 body,778 ...parameters779 };780 let current_token;781 const hook_token2 = hooks.get_token();782 if (typeof hook_token2 === "string" && hook_token2 !== "") {783 current_token = hook_token2;784 }785 if (typeof token === "string" && token !== "") {786 current_token = token;787 }788 return await base.create("error", current_token).hook("insert")(args);789 },790 update: async (id, body, parameters, token) => {791 const args = {792 params: {793 id794 },795 body,796 ...parameters797 };798 let current_token;799 const hook_token2 = hooks.get_token();800 if (typeof hook_token2 === "string" && hook_token2 !== "") {801 current_token = hook_token2;802 }803 if (typeof token === "string" && token !== "") {804 current_token = token;805 }806 return await base.create("error", current_token).hook("update")(args);807 },808 delete: async (id, parameters, token) => {809 const args = {810 params: {811 id812 },813 ...parameters814 };815 let current_token;816 const hook_token2 = hooks.get_token();817 if (typeof hook_token2 === "string" && hook_token2 !== "") {818 current_token = hook_token2;819 }820 if (typeof token === "string" && token !== "") {821 current_token = token;822 }823 return await base.create("error", current_token).hook("delete")(args);824 },825 insert_multiple: async (body, parameters, token) => {826 const args = {827 body,828 ...parameters829 };830 let current_token;831 const hook_token2 = hooks.get_token();832 if (typeof hook_token2 === "string" && hook_token2 !== "") {833 current_token = hook_token2;834 }835 if (typeof token === "string" && token !== "") {836 current_token = token;837 }838 return await base.create("error", current_token).hook("insert_multiple")(args);839 },840 update_multiple: async (ids, body, parameters, token) => {841 const args = {842 params: {843 ids844 },845 body,846 ...parameters847 };848 let current_token;849 const hook_token2 = hooks.get_token();850 if (typeof hook_token2 === "string" && hook_token2 !== "") {851 current_token = hook_token2;852 }853 if (typeof token === "string" && token !== "") {854 current_token = token;855 }856 return await base.create("error", current_token).hook("update_multiple")(args);857 },858 delete_multiple: async (ids, parameters, token) => {859 const args = {860 params: {861 ids862 },863 ...parameters864 };865 let current_token;866 const hook_token2 = hooks.get_token();867 if (typeof hook_token2 === "string" && hook_token2 !== "") {868 current_token = hook_token2;869 }870 if (typeof token === "string" && token !== "") {871 current_token = token;872 }873 return await base.create("error", current_token).hook("delete_multiple")(args);874 }875 },876 requests: {877 count: async (parameters, token) => {878 const args = {879 ...parameters880 };881 let current_token;882 const hook_token2 = hooks.get_token();883 if (typeof hook_token2 === "string" && hook_token2 !== "") {884 current_token = hook_token2;885 }886 if (typeof token === "string" && token !== "") {887 current_token = token;888 }889 return await base.create("request", current_token).hook("count")(args);890 },891 find_one: async (parameters, token) => {892 const args = {893 ...parameters894 };895 let current_token;896 const hook_token2 = hooks.get_token();897 if (typeof hook_token2 === "string" && hook_token2 !== "") {898 current_token = hook_token2;899 }900 if (typeof token === "string" && token !== "") {901 current_token = token;902 }903 return await base.create("request", current_token).hook("find_one")(args);904 },905 find: async (parameters, token) => {906 const args = {907 ...parameters908 };909 let current_token;910 const hook_token2 = hooks.get_token();911 if (typeof hook_token2 === "string" && hook_token2 !== "") {912 current_token = hook_token2;913 }914 if (typeof token === "string" && token !== "") {915 current_token = token;916 }917 return await base.create("request", current_token).hook("find")(args);918 },919 find_id: async (id, parameters, token) => {920 const args = {921 params: {922 id923 },924 ...parameters925 };926 let current_token;927 const hook_token2 = hooks.get_token();928 if (typeof hook_token2 === "string" && hook_token2 !== "") {929 current_token = hook_token2;930 }931 if (typeof token === "string" && token !== "") {932 current_token = token;933 }934 return await base.create("request", current_token).hook("find_id")(args);935 },936 insert: async (body, parameters, token) => {937 const args = {938 body,939 ...parameters940 };941 let current_token;942 const hook_token2 = hooks.get_token();943 if (typeof hook_token2 === "string" && hook_token2 !== "") {944 current_token = hook_token2;945 }946 if (typeof token === "string" && token !== "") {947 current_token = token;948 }949 return await base.create("request", current_token).hook("insert")(args);950 },951 update: async (id, body, parameters, token) => {952 const args = {953 params: {954 id955 },956 body,957 ...parameters958 };959 let current_token;960 const hook_token2 = hooks.get_token();961 if (typeof hook_token2 === "string" && hook_token2 !== "") {962 current_token = hook_token2;963 }964 if (typeof token === "string" && token !== "") {965 current_token = token;966 }967 return await base.create("request", current_token).hook("update")(args);968 },969 delete: async (id, parameters, token) => {970 const args = {971 params: {972 id973 },974 ...parameters975 };976 let current_token;977 const hook_token2 = hooks.get_token();978 if (typeof hook_token2 === "string" && hook_token2 !== "") {979 current_token = hook_token2;980 }981 if (typeof token === "string" && token !== "") {982 current_token = token;983 }984 return await base.create("request", current_token).hook("delete")(args);985 },986 insert_multiple: async (body, parameters, token) => {987 const args = {988 body,989 ...parameters990 };991 let current_token;992 const hook_token2 = hooks.get_token();993 if (typeof hook_token2 === "string" && hook_token2 !== "") {994 current_token = hook_token2;995 }996 if (typeof token === "string" && token !== "") {997 current_token = token;998 }999 return await base.create("request", current_token).hook("insert_multiple")(args);1000 },1001 update_multiple: async (ids, body, parameters, token) => {1002 const args = {1003 params: {1004 ids1005 },1006 body,1007 ...parameters1008 };1009 let current_token;1010 const hook_token2 = hooks.get_token();1011 if (typeof hook_token2 === "string" && hook_token2 !== "") {1012 current_token = hook_token2;1013 }1014 if (typeof token === "string" && token !== "") {1015 current_token = token;1016 }1017 return await base.create("request", current_token).hook("update_multiple")(args);1018 },1019 delete_multiple: async (ids, parameters, token) => {1020 const args = {1021 params: {1022 ids1023 },1024 ...parameters1025 };1026 let current_token;1027 const hook_token2 = hooks.get_token();1028 if (typeof hook_token2 === "string" && hook_token2 !== "") {1029 current_token = hook_token2;1030 }1031 if (typeof token === "string" && token !== "") {1032 current_token = token;1033 }1034 return await base.create("request", current_token).hook("delete_multiple")(args);1035 }1036 },1037 settings: {1038 count: async (parameters, token) => {1039 const args = {1040 ...parameters1041 };1042 let current_token;1043 const hook_token2 = hooks.get_token();1044 if (typeof hook_token2 === "string" && hook_token2 !== "") {1045 current_token = hook_token2;1046 }1047 if (typeof token === "string" && token !== "") {1048 current_token = token;1049 }1050 return await base.create("setting", current_token).hook("count")(args);1051 },1052 find_one: async (parameters, token) => {1053 const args = {1054 ...parameters1055 };1056 let current_token;1057 const hook_token2 = hooks.get_token();1058 if (typeof hook_token2 === "string" && hook_token2 !== "") {1059 current_token = hook_token2;1060 }1061 if (typeof token === "string" && token !== "") {1062 current_token = token;1063 }1064 return await base.create("setting", current_token).hook("find_one")(args);1065 },1066 find: async (parameters, token) => {1067 const args = {1068 ...parameters1069 };1070 let current_token;1071 const hook_token2 = hooks.get_token();1072 if (typeof hook_token2 === "string" && hook_token2 !== "") {1073 current_token = hook_token2;1074 }1075 if (typeof token === "string" && token !== "") {1076 current_token = token;1077 }1078 return await base.create("setting", current_token).hook("find")(args);1079 },1080 find_id: async (id, parameters, token) => {1081 const args = {1082 params: {1083 id1084 },1085 ...parameters1086 };1087 let current_token;1088 const hook_token2 = hooks.get_token();1089 if (typeof hook_token2 === "string" && hook_token2 !== "") {1090 current_token = hook_token2;1091 }1092 if (typeof token === "string" && token !== "") {1093 current_token = token;1094 }1095 return await base.create("setting", current_token).hook("find_id")(args);1096 },1097 insert: async (body, parameters, token) => {1098 const args = {1099 body,1100 ...parameters1101 };1102 let current_token;1103 const hook_token2 = hooks.get_token();1104 if (typeof hook_token2 === "string" && hook_token2 !== "") {1105 current_token = hook_token2;1106 }1107 if (typeof token === "string" && token !== "") {1108 current_token = token;1109 }1110 return await base.create("setting", current_token).hook("insert")(args);1111 },1112 update: async (id, body, parameters, token) => {1113 const args = {1114 params: {1115 id1116 },1117 body,1118 ...parameters1119 };1120 let current_token;1121 const hook_token2 = hooks.get_token();1122 if (typeof hook_token2 === "string" && hook_token2 !== "") {1123 current_token = hook_token2;1124 }1125 if (typeof token === "string" && token !== "") {1126 current_token = token;1127 }1128 return await base.create("setting", current_token).hook("update")(args);1129 },1130 delete: async (id, parameters, token) => {1131 const args = {1132 params: {1133 id1134 },1135 ...parameters1136 };1137 let current_token;1138 const hook_token2 = hooks.get_token();1139 if (typeof hook_token2 === "string" && hook_token2 !== "") {1140 current_token = hook_token2;1141 }1142 if (typeof token === "string" && token !== "") {1143 current_token = token;1144 }1145 return await base.create("setting", current_token).hook("delete")(args);1146 },1147 insert_multiple: async (body, parameters, token) => {1148 const args = {1149 body,1150 ...parameters1151 };1152 let current_token;1153 const hook_token2 = hooks.get_token();1154 if (typeof hook_token2 === "string" && hook_token2 !== "") {1155 current_token = hook_token2;1156 }1157 if (typeof token === "string" && token !== "") {1158 current_token = token;1159 }1160 return await base.create("setting", current_token).hook("insert_multiple")(args);1161 },1162 update_multiple: async (ids, body, parameters, token) => {1163 const args = {1164 params: {1165 ids1166 },1167 body,1168 ...parameters1169 };1170 let current_token;1171 const hook_token2 = hooks.get_token();1172 if (typeof hook_token2 === "string" && hook_token2 !== "") {1173 current_token = hook_token2;1174 }1175 if (typeof token === "string" && token !== "") {1176 current_token = token;1177 }1178 return await base.create("setting", current_token).hook("update_multiple")(args);1179 },1180 delete_multiple: async (ids, parameters, token) => {1181 const args = {1182 params: {1183 ids1184 },1185 ...parameters1186 };1187 let current_token;1188 const hook_token2 = hooks.get_token();1189 if (typeof hook_token2 === "string" && hook_token2 !== "") {1190 current_token = hook_token2;1191 }1192 if (typeof token === "string" && token !== "") {1193 current_token = token;1194 }1195 return await base.create("setting", current_token).hook("delete_multiple")(args);1196 }1197 }1198};1199module.exports = __toCommonJS(hooks_exports);1200// Annotate the CommonJS export names for ESM import in node:12010 && (module.exports = {1202 hooks...

Full Screen

Full Screen

Deposits.test.js

Source:Deposits.test.js Github

copy

Full Screen

1const Deposits = artifacts.require('./Deposits.sol');2const ERC20 = artifacts.require('./ERC20Mock.sol');3contract('Deposits', ([owner, alice, bob, carl]) => {4 before(async () => {5 this.deposits = await Deposits.new();6 });7 before(async () => {8 this.token1 = await ERC20.new("Token 1", "T1", 0, 0);9 await Promise.all([10 this.token1.mint(alice, 5000),11 this.token1.mint(bob, 500),12 this.token1.mint(carl, 2000),13 ]);14 const [balanceAlice, balanceBob, balanceCarl] = await Promise.all([15 this.token1.balanceOf(alice),16 this.token1.balanceOf(bob),17 this.token1.balanceOf(carl),18 ]);19 assert.equal(5000, balanceAlice);20 assert.equal(500, balanceBob);21 assert.equal(2000, balanceCarl);22 });23 before(async () => {24 this.token2 = await ERC20.new("Token 2", "T2", 0, 0);25 await Promise.all([26 this.token2.mint(alice, 1500),27 this.token2.mint(bob, 800),28 ]);29 const [balanceAlice, balanceBob, balanceCarl] = await Promise.all([30 this.token2.balanceOf(alice),31 this.token2.balanceOf(bob),32 this.token2.balanceOf(carl),33 ]);34 assert.equal(1500, balanceAlice);35 assert.equal(800, balanceBob);36 assert.equal(0, balanceCarl);37 });38 describe('receives deposits', () => {39 before(async () => {40 await Promise.all([41 this.token1.approve(this.deposits.address, 3000, {from: alice}),42 this.token2.approve(this.deposits.address, 1000, {from: alice}),43 this.token1.approve(this.deposits.address, 500, {from: bob}),44 this.token2.approve(this.deposits.address, 100, {from: bob}),45 this.token1.approve(this.deposits.address, 1000, {from: carl})46 ]);47 this.depositBlock1 = await web3.eth.getBlockNumber() + 1;48 await Promise.all([49 this.deposits.deposit(this.token1.address, 1500, {from: alice}),50 this.deposits.deposit(this.token2.address, 1000, {from: alice}),51 this.deposits.deposit(this.token1.address, 500, {from: bob}),52 this.deposits.deposit(this.token2.address, 100, {from: bob}),53 this.deposits.deposit(this.token1.address, 1000, {from: carl})54 ]);55 });56 it('shows the deposits of alice', async () => {57 const balanceToken1 = await this.token1.balanceOf(alice);58 const depositToken1 = await this.deposits.deposited(this.token1.address, alice);59 assert.equal(3500, balanceToken1);60 assert.equal(1500, depositToken1);61 const balanceToken2 = await this.token2.balanceOf(alice);62 const depositToken2 = await this.deposits.deposited(this.token2.address, alice);63 assert.equal(500, balanceToken2);64 assert.equal(1000, depositToken2);65 });66 it('shows the deposits of bob', async () => {67 const balanceToken1 = await this.token1.balanceOf(bob);68 const depositToken1 = await this.deposits.deposited(this.token1.address, bob);69 assert.equal(0, balanceToken1);70 assert.equal(500, depositToken1);71 const balanceToken2 = await this.token2.balanceOf(bob);72 const depositToken2 = await this.deposits.deposited(this.token2.address, bob);73 assert.equal(700, balanceToken2);74 assert.equal(100, depositToken2);75 });76 it('shows the deposits of carl', async () => {77 const balanceToken1 = await this.token1.balanceOf(carl);78 const depositToken1 = await this.deposits.deposited(this.token1.address, carl);79 assert.equal(1000, balanceToken1);80 assert.equal(1000, depositToken1);81 const balanceToken2 = await this.token2.balanceOf(carl);82 const depositToken2 = await this.deposits.deposited(this.token2.address, carl);83 assert.equal(0, balanceToken2);84 assert.equal(0, depositToken2);85 });86 it('shows the total deposit', async () => {87 const totalToken1 = await this.deposits.total(this.token1.address);88 assert.equal(3000, totalToken1);89 const totalToken2 = await this.deposits.total(this.token2.address);90 assert.equal(1100, totalToken2);91 });92 it('holds the deposits', async () => {93 const balanceToken1 = await this.token1.balanceOf(this.deposits.address);94 assert.equal(3000, balanceToken1);95 const balanceToken2 = await this.token2.balanceOf(this.deposits.address);96 assert.equal(1100, balanceToken2);97 });98 });99 describe('can calcuate rewards', () => {100 it('calculates rewards alice for token 1 over 1000 blocks', async () => {101 const reward = await this.deposits.calcReward(this.token1.address, alice, 3, 1000, 2000);102 assert.equal(1000 * 1500 * 3, reward)103 });104 it('calculates rewards alice for the first 1000 blocks', async () => {105 const reward = await this.deposits.calcReward(this.token1.address, alice, 3, 0, 1000);106 assert.equal((1000 - this.depositBlock1) * 1500 * 3, reward)107 });108 });109 describe('has a capped token', () => {110 before(async () => {111 await this.deposits.cap(this.token1.address, 20, this.token2.address, 10);112 });113 it('shows alice can\'t deposit token 2', async () => {114 const max = await this.deposits.maxDeposit(this.token2.address, alice);115 assert.equal(0, max);116 });117 it('shows bob can deposit some token 2', async () => {118 const max = await this.deposits.maxDeposit(this.token2.address, bob);119 assert.equal(150, max);120 });121 it('shows carl can deposit max token 2', async () => {122 const max = await this.deposits.maxDeposit(this.token2.address, carl);123 assert.equal(500, max);124 });125 it('won\'t allow alice to deposit more token 2', async () => {126 await this.token2.approve(this.deposits.address, 100, {from: alice});127 try {128 await this.deposits.deposit(this.token2.address, 100, {from: alice});129 } catch (ex) {130 assert.equal(ex.receipt.status, '0x0');131 assert.equal(ex.reason, 'Not allowed to deposit specified amount of capped token');132 return;133 }134 assert.fail('deposit successful');135 });136 it('won\'t allow bob to deposit more than max token 2', async () => {137 await this.token2.approve(this.deposits.address, 250, {from: bob});138 try {139 await this.deposits.deposit(this.token2.address, 250, {from: bob});140 } catch (ex) {141 assert.equal(ex.receipt.status, '0x0');142 assert.equal(ex.reason, 'Not allowed to deposit specified amount of capped token');143 return;144 }145 assert.fail('deposit successful');146 });147 it('will allow bob to deposit less than max token 2', async () => {148 await this.token2.approve(this.deposits.address, 100, {from: bob});149 await this.deposits.deposit(this.token2.address, 100, {from: bob});150 const balanceToken2 = await this.token2.balanceOf(bob);151 const depositToken2 = await this.deposits.deposited(this.token2.address, bob);152 assert.equal(600, balanceToken2);153 assert.equal(200, depositToken2);154 });155 it('will allow alice to deposit both token 1 and token 2', async () => {156 await this.token1.approve(this.deposits.address, 700, {from: alice});157 await this.token2.approve(this.deposits.address, 100, {from: alice});158 await this.deposits.deposit2(this.token2.address, 100, this.token1.address, 700, {from: alice});159 const balanceToken1 = await this.token1.balanceOf(alice);160 const depositToken1 = await this.deposits.deposited(this.token1.address, alice);161 assert.equal(2800, balanceToken1);162 assert.equal(2200, depositToken1);163 const balanceToken2 = await this.token2.balanceOf(alice);164 const depositToken2 = await this.deposits.deposited(this.token2.address, alice);165 assert.equal(400, balanceToken2);166 assert.equal(1100, depositToken2);167 });168 });169 describe('has a limit of a token', () => {170 before(async () => {171 await this.deposits.limit(this.token1.address, 4500);172 await this.token1.approve(this.deposits.address, 1000, {from: alice});173 });174 it('won\'t allow alice to add 1000 tokens', async () => {175 try {176 await this.deposits.deposit(this.token1.address, 1000, {from: alice});177 } catch (ex) {178 assert.equal(ex.receipt.status, '0x0');179 assert.equal(ex.reason, 'Limit reached');180 return;181 }182 assert.fail('deposit successful');183 });184 it('will allow alice to add 500 tokens', async () => {185 await this.deposits.deposit(this.token1.address, 500, {from: alice});186 const balanceToken1 = await this.token1.balanceOf(alice);187 const depositToken1 = await this.deposits.deposited(this.token1.address, alice);188 assert.equal(2300, balanceToken1);189 assert.equal(2700, depositToken1);190 })191 });192 describe('tokens are withdrawn', () => {193 before(async () => {194 await this.deposits.withdraw({from: alice});195 });196 it('shows alice has her deposit back', async () => {197 const balanceToken1 = await this.token1.balanceOf(alice);198 const depositToken1 = await this.deposits.deposited(this.token1.address, alice);199 assert.equal(5000, balanceToken1);200 assert.equal(0, depositToken1);201 const balanceToken2 = await this.token2.balanceOf(alice);202 const depositToken2 = await this.deposits.deposited(this.token2.address, alice);203 assert.equal(1500, balanceToken2);204 assert.equal(0, depositToken2);205 });206 });207 describe('only allows actions to be done by the contract owner', () => {208 it('won\'t allow alice to cap a token', async () => {209 try {210 await this.deposits.cap(this.token1.address, 1, this.token2.address, 1, {from: alice});211 } catch (ex) {212 assert.equal(ex.receipt.status, '0x0');213 return;214 }215 assert.fail('transaction should not have been successful');216 });217 it('won\'t allow alice to uncap a token', async () => {218 try {219 await this.deposits.uncap(this.token2.address, {from: alice});220 } catch (ex) {221 assert.equal(ex.receipt.status, '0x0');222 return;223 }224 assert.fail('transaction should not have been successful');225 });226 it('won\'t allow alice to set the limit', async () => {227 try {228 await this.deposits.limit(this.token1.address, 1000, {from: alice});229 } catch (ex) {230 assert.equal(ex.receipt.status, '0x0');231 return;232 }233 assert.fail('transaction should not have been successful');234 });235 it('won\'t allow alice to withdraw for bob', async () => {236 try {237 await this.deposits.withdrawForUser(bob, {from: alice});238 } catch (ex) {239 assert.equal(ex.receipt.status, '0x0');240 return;241 }242 assert.fail('transaction should not have been successful');243 });244 });...

Full Screen

Full Screen

run-arbitrage.js

Source:run-arbitrage.js Github

copy

Full Screen

1require("dotenv").config();2const Web3 = require("web3");3const abis = require("./abis");4const { mainnet: addresses } = require("./addresses");5const Flashloan = require("./build/contracts/TokenFlashSwap.json");6const web3 = new Web3(7 new Web3.providers.WebsocketProvider(process.env.WSS_URL)8);9const { address: admin } = web3.eth.accounts.wallet.add(10 process.env.PRIVATE_KEY11);12const wbnbamount = "1";13const flashloanToken1 = "10";14const flashloanToken2 = "10";15const amountInToken1 = web3.utils.toBN(web3.utils.toWei(flashloanToken1));16const amountInToken2 = web3.utils.toBN(web3.utils.toWei(flashloanToken2));17const Exchange1 = new web3.eth.Contract(18 abis.exchange1.router,19 addresses.exchange1.router20);21const Exchange2 = new web3.eth.Contract(22 abis.exchange2.router,23 addresses.exchange2.router24);25const init = async () => {26 const networkId = await web3.eth.net.getId();27 const flashloan = new web3.eth.Contract(28 Flashloan.abi,29 Flashloan.networks[networkId].address30 );31 web3.eth32 .subscribe("newBlockHeaders")33 .on("data", async (block) => {34 console.log(`New block received. Block # ${block.number}`);35 const getbnbprice = await Exchange1.methods36 .getAmountsOut(wbnbamount, [37 addresses.tokens.Wbnb,38 addresses.tokens.busd,39 ])40 .call();41 const amountsOut1 = await Exchange1.methods42 .getAmountsIn(amountInToken1, [43 addresses.tokens.Token2,44 addresses.tokens.Token1,45 ])46 .call();47 const amountsOut2 = await Exchange1.methods48 .getAmountsOut(amountInToken1, [49 addresses.tokens.Token1,50 addresses.tokens.Token2,51 ])52 .call();53 const amountsOut3 = await Exchange2.methods54 .getAmountsIn(amountInToken1, [55 addresses.tokens.Token2,56 addresses.tokens.Token1,57 ])58 .call();59 const amountsOut4 = await Exchange2.methods60 .getAmountsOut(amountInToken1, [61 addresses.tokens.Token1,62 addresses.tokens.Token2,63 ])64 .call();65 const amountsOut5 = await Exchange1.methods66 .getAmountsIn(amountInToken2, [67 addresses.tokens.Token1,68 addresses.tokens.Token2,69 ])70 .call();71 const amountsOut6 = await Exchange1.methods72 .getAmountsOut(amountInToken2, [73 addresses.tokens.Token2,74 addresses.tokens.Token1,75 ])76 .call();77 const amountsOut7 = await Exchange2.methods78 .getAmountsIn(amountInToken2, [79 addresses.tokens.Token1,80 addresses.tokens.Token2,81 ])82 .call();83 const amountsOut8 = await Exchange2.methods84 .getAmountsOut(amountInToken2, [85 addresses.tokens.Token2,86 addresses.tokens.Token1,87 ])88 .call();89 const Exchange1results = {90 buy: amountsOut1[0] / 10 ** 18,91 sell: amountsOut2[1] / 10 ** 18,92 };93 const Exchange1results2 = {94 buy: amountsOut5[0] / 10 ** 18,95 sell: amountsOut6[1] / 10 ** 18,96 };97 const Exchange2results = {98 buy: amountsOut3[0] / 10 ** 18,99 sell: amountsOut4[1] / 10 ** 18,100 };101 const Exchange2results2 = {102 buy: amountsOut7[0] / 10 ** 18,103 sell: amountsOut8[1] / 10 ** 18,104 };105 console.log(`exchange1 ${flashloanToken1} Token1/Token2 `);106 console.log(Exchange1results);107 console.log(`exchange2 ${flashloanToken1} Token1/Token2`);108 console.log(Exchange2results);109 console.log(`exchange1 ${flashloanToken2} Token2/Token1`);110 console.log(Exchange1results2);111 console.log(`exchange2 ${flashloanToken2} Token2/Token1 `);112 console.log(Exchange2results2);113 let Exchange2PaybackCalcToken1 =114 (Exchange2results.buy / 0.997) * 10 ** 18;115 let Exchange1PaybackCalcToken1 =116 (Exchange1results.buy / 0.997) * 10 ** 18;117 let Exchange1PaybackCalcToken2 =118 (Exchange1results2.buy / 0.997) * 10 ** 18;119 let Exchange2PaybackCalcToken2 =120 (Exchange2results2.buy / 0.997) * 10 ** 18;121 let repayToken1Exchange2Fee =122 Exchange2PaybackCalcToken1 / 10 ** 18 - Exchange2results.buy;123 let repayToken1Exchange1Fee =124 Exchange1PaybackCalcToken1 / 10 ** 18 - Exchange1results.buy;125 let repayToken2Exchange2Fee =126 Exchange2PaybackCalcToken2 / 10 ** 18 - Exchange2results2.buy;127 let repayToken2Exchange1Fee =128 Exchange1PaybackCalcToken2 / 10 ** 18 - Exchange1results2.buy;129 const gasPrice = await web3.eth.getGasPrice();130 const bnbprice = getbnbprice[1].toString() / 10 ** 8;131 const txCost =132 (330000 * parseInt(gasPrice) * getbnbprice[1].toString()) / 10 ** 18;133 txCost - repayToken1Exchange1Fee;134 const profit1 =135 Exchange1results.sell -136 Exchange2results.buy -137 txCost -138 repayToken1Exchange2Fee;139 const profit2 =140 Exchange2results.sell -141 Exchange1results.buy -142 txCost -143 repayToken1Exchange2Fee;144 const profit3 =145 Exchange2results2.sell -146 Exchange1results2.buy -147 txCost -148 repayToken2Exchange2Fee;149 const profit4 =150 Exchange1results2.sell -151 Exchange2results2.buy -152 txCost -153 repayToken2Exchange1Fee;154 if (profit1 > 0 && profit1 > profit2) {155 console.log("Arb opportunity found!");156 console.log(157 `Flashloan Token2 on exchange1 at ${Exchange1results.buy} `158 );159 console.log(`Sell Token2 on exchange2 at ${Exchange2results.sell} `);160 console.log(`Expected cost of flashswap: ${repayToken1Exchange2Fee}`);161 console.log(`Expected Gas cost: ${txCost}`);162 console.log(`Expected profit: ${profit1} Token1`);163 let tx = flashloan.methods.TokenArbitrage(164 addresses.tokens.Token2, //token1165 addresses.tokens.Token1, //token2166 amountInToken2.toString(), //amount0167 0, //amount1168 addresses.exchange1.factory,169 addresses.exchange2.router,170 Exchange2PaybackCalcToken1.toString()171 );172 const data = tx.encodeABI();173 const txData = {174 from: admin,175 to: flashloan.options.address,176 data,177 gas: "330000",178 gasPrice: gasPrice,179 };180 const receipt = await web3.eth.sendTransaction(txData);181 console.log(`Transaction hash: ${receipt.transactionHash}`);182 }183 if (profit2 > 0 && profit2 > profit1) {184 console.log("Arb opportunity found!");185 console.log(`Buy Token2 from exchange2 at ${Exchange2results.buy} `);186 console.log(`Sell Token2 from exchange1 at ${Exchange1results.sell}`);187 console.log(`Expected cost of flashswap: ${repayToken1Exchange1Fee}`);188 console.log(`Expected Gas cost: ${txCost}`);189 console.log(`Expected profit: ${profit2} Token1`);190 let tx = flashloan.methods.TokenArbitrage(191 addresses.tokens.Token2, //token1192 addresses.tokens.Token1, //token2193 amountInToken2.toString(), //amount0194 0, //amount1195 addresses.exchange2.factory,196 addresses.exchange1.router,197 Exchange1PaybackCalcToken1.toString()198 );199 const data = tx.encodeABI();200 const txData = {201 from: admin,202 to: flashloan.options.address,203 data,204 gas: "330000",205 gasPrice: gasPrice,206 };207 const receipt = await web3.eth.sendTransaction(txData);208 console.log(`Transaction hash: ${receipt.transactionHash}`);209 }210 if (profit3 > 0 && profit3 > profit4) {211 console.log("Arb opportunity found!");212 console.log(213 `Flashloan Token1 on exchange1 at ${Exchange1results2.buy} `214 );215 console.log(`Sell Token1 on exchange2 at ${Exchange2results2.sell} `);216 console.log(`Expected cost of flashswap: ${repayToken2Exchange2Fee}`);217 console.log(`Expected Gas cost: ${txCost}`);218 console.log(`Expected profit: ${profit3} Token2`);219 let tx = flashloan.methods.TokenArbitrage(220 addresses.tokens.Token1, //token1221 addresses.tokens.Token2, //token2222 0, //amount0223 amountInToken1.toString(), //amount1224 addresses.exchange1.factory,225 addresses.exchange2.router,226 Exchange1PaybackCalcToken2.toString()227 );228 const data = tx.encodeABI();229 const txData = {230 from: admin,231 to: flashloan.options.address,232 data,233 gas: "330000",234 gasPrice: gasPrice,235 };236 const receipt = await web3.eth.sendTransaction(txData);237 console.log(`Transaction hash: ${receipt.transactionHash}`);238 }239 if (profit4 > 0 && profit4 > profit3) {240 console.log("Arb opportunity found!");241 console.log(242 `Flashloan Token1 on exchange2 at ${pancakeresults2.buy} `243 );244 console.log(`Sell Token1 on at exchange1 ${aperesults2.sell} `);245 console.log(`Expected cost of flashswap: ${repayToken2Exchange1Fee}`);246 console.log(`Expected Gas cost: ${txCost}`);247 console.log(`Expected profit: ${profit4} Token2`);248 let tx = flashloan.methods.TokenArbitrage(249 addresses.tokens.Token2,250 addresses.tokens.Token1,251 0, //amount0252 amountInToken1.toString(), //amount1253 addresses.exchange2.factory,254 addresses.exchange1.router,255 Exchange2PaybackCalcToken2.toString()256 );257 const data = tx.encodeABI();258 const txData = {259 from: admin,260 to: flashloan.options.address,261 data,262 gas: "330000",263 gasPrice: gasPrice,264 };265 const receipt = await web3.eth.sendTransaction(txData);266 console.log(`Transaction hash: ${receipt.transactionHash}`);267 }268 })269 .on("error", (error) => {270 console.log(error);271 });272};...

Full Screen

Full Screen

lexer.js

Source:lexer.js Github

copy

Full Screen

12const lexers = require('../lib/lexer');3const TokenType = lexers.TokenType;45exports['Create lexer'] = function (test) {6 const lexer = lexers.lexer('foo');7 8 test.ok(lexer);9 test.equal(typeof lexer, 'object');10};1112exports['Get name'] = function (test) {13 const lexer = lexers.lexer('foo');14 15 const token = lexer.nextToken();16 17 test.ok(token);18 test.equal(token.type, TokenType.Name);19 test.equal(token.value, 'foo');20 21 test.strictEqual(lexer.nextToken(), null);22};2324exports['Get dollar name'] = function (test) {25 const lexer = lexers.lexer('$foo');26 27 const token = lexer.nextToken();28 29 test.ok(token);30 test.equal(token.type, TokenType.Name);31 test.equal(token.value, '$foo');32 33 test.strictEqual(lexer.nextToken(), null);34};3536exports['Get name skipping line comment'] = function (test) {37 const lexer = lexers.lexer('; this is a comment\nfoo');38 39 const token = lexer.nextToken();40 41 test.ok(token);42 test.equal(token.type, TokenType.Name);43 test.equal(token.value, 'foo');44 45 test.strictEqual(lexer.nextToken(), null);46};4748exports['Get name skipping line comment ending in carriage return'] = function (test) {49 const lexer = lexers.lexer('; this is a comment\rfoo');50 51 const token = lexer.nextToken();52 53 test.ok(token);54 test.equal(token.type, TokenType.Name);55 test.equal(token.value, 'foo');56 57 test.strictEqual(lexer.nextToken(), null);58};5960exports['Get name with qualified namespace'] = function (test) {61 const lexer = lexers.lexer('cljs.core/foo');62 63 const token = lexer.nextToken();64 65 test.ok(token);66 test.equal(token.type, TokenType.Name);67 test.equal(token.value, 'cljs.core/foo');68 69 test.strictEqual(lexer.nextToken(), null);70};7172exports['Get name with spaces'] = function (test) {73 const lexer = lexers.lexer(' foo ');74 75 const token = lexer.nextToken();76 77 test.ok(token);78 test.equal(token.type, TokenType.Name);79 test.equal(token.value, 'foo');80 81 test.strictEqual(lexer.nextToken(), null);82};8384exports['Get name skipping commas'] = function (test) {85 const lexer = lexers.lexer(' ,,foo,,, ');86 87 const token = lexer.nextToken();88 89 test.ok(token);90 test.equal(token.type, TokenType.Name);91 test.equal(token.value, 'foo');92 93 test.strictEqual(lexer.nextToken(), null);94};9596exports['Get names'] = function (test) {97 const lexer = lexers.lexer('foo bar');98 99 const token = lexer.nextToken();100 101 test.ok(token);102 test.equal(token.type, TokenType.Name);103 test.equal(token.value, 'foo');104 105 const token2 = lexer.nextToken();106 107 test.ok(token2);108 test.equal(token2.type, TokenType.Name);109 test.equal(token2.value, 'bar');110 111 test.strictEqual(lexer.nextToken(), null);112};113114exports['Get string'] = function (test) {115 const lexer = lexers.lexer('"foo"');116 117 const token = lexer.nextToken();118 119 test.ok(token);120 test.equal(token.type, TokenType.String);121 test.equal(token.value, 'foo');122 123 test.strictEqual(lexer.nextToken(), null);124};125126exports['Get integer'] = function (test) {127 const lexer = lexers.lexer('42');128 129 const token = lexer.nextToken();130 131 test.ok(token);132 test.equal(token.type, TokenType.Integer);133 test.equal(token.value, '42');134 135 test.strictEqual(lexer.nextToken(), null);136};137138exports['Get negative integer'] = function (test) {139 const lexer = lexers.lexer('-123');140 141 const token = lexer.nextToken();142 143 test.ok(token);144 test.equal(token.type, TokenType.Integer);145 test.equal(token.value, '-123');146 147 test.strictEqual(lexer.nextToken(), null);148};149150exports['Get parenthesis as delimiter'] = function (test) {151 const lexer = lexers.lexer('()');152 153 const token = lexer.nextToken();154 155 test.ok(token);156 test.equal(token.type, TokenType.Delimiter);157 test.equal(token.value, '(');158 159 const token2 = lexer.nextToken();160 161 test.ok(token2);162 test.equal(token2.type, TokenType.Delimiter);163 test.equal(token2.value, ')');164 165 test.strictEqual(lexer.nextToken(), null);166};167168exports['Get square brackets as delimiters'] = function (test) {169 const lexer = lexers.lexer('[]');170 171 const token = lexer.nextToken();172 173 test.ok(token);174 test.equal(token.type, TokenType.Delimiter);175 test.equal(token.value, '[');176 177 const token2 = lexer.nextToken();178 179 test.ok(token2);180 test.equal(token2.type, TokenType.Delimiter);181 test.equal(token2.value, ']');182 183 test.strictEqual(lexer.nextToken(), null);184};185186exports['Get handlebars as delimiters'] = function (test) {187 const lexer = lexers.lexer('{}');188 189 const token = lexer.nextToken();190 191 test.ok(token);192 test.equal(token.type, TokenType.Delimiter);193 test.equal(token.value, '{');194 195 const token2 = lexer.nextToken();196 197 test.ok(token2);198 test.equal(token2.type, TokenType.Delimiter);199 test.equal(token2.value, '}');200 201 test.strictEqual(lexer.nextToken(), null);202};203204exports['Get numeral and handlebars as delimiters'] = function (test) {205 const lexer = lexers.lexer('#{}');206 207 const token = lexer.nextToken();208 209 test.ok(token);210 test.equal(token.type, TokenType.Delimiter);211 test.equal(token.value, '#{');212 213 const token2 = lexer.nextToken();214 215 test.ok(token2);216 test.equal(token2.type, TokenType.Delimiter);217 test.equal(token2.value, '}');218 219 test.strictEqual(lexer.nextToken(), null);220};221222exports['Get delimiter, name, delimiter'] = function (test) {223 const lexer = lexers.lexer('[x]');224 225 const token = lexer.nextToken();226 227 test.ok(token);228 test.equal(token.type, TokenType.Delimiter);229 test.equal(token.value, '[');230 231 const token2 = lexer.nextToken();232 233 test.ok(token2);234 test.equal(token2.type, TokenType.Name);235 test.equal(token2.value, 'x');236 237 const token3 = lexer.nextToken();238 239 test.ok(token3);240 test.equal(token3.type, TokenType.Delimiter);241 test.equal(token3.value, ']');242 243 test.strictEqual(lexer.nextToken(), null);244};245246exports['Get quote character and name'] = function (test) {247 const lexer = lexers.lexer("'x");248 249 const token = lexer.nextToken();250 251 test.ok(token);252 test.equal(token.type, TokenType.Name);253 test.equal(token.value, "'");254 255 const token2 = lexer.nextToken();256 257 test.ok(token2);258 test.equal(token2.type, TokenType.Name);259 test.equal(token2.value, 'x');260 261 test.strictEqual(lexer.nextToken(), null);262};263264exports['Get ampersand character and name'] = function (test) {265 const lexer = lexers.lexer("&x");266 267 const token = lexer.nextToken();268 269 test.ok(token);270 test.equal(token.type, TokenType.Name);271 test.equal(token.value, "&");272 273 const token2 = lexer.nextToken();274 275 test.ok(token2);276 test.equal(token2.type, TokenType.Name);277 test.equal(token2.value, 'x');278 279 test.strictEqual(lexer.nextToken(), null);280};281282exports['Get backquote character and name'] = function (test) {283 const lexer = lexers.lexer("`x");284 285 const token = lexer.nextToken();286 287 test.ok(token);288 test.equal(token.type, TokenType.Name);289 test.equal(token.value, "`");290 291 const token2 = lexer.nextToken();292 293 test.ok(token2);294 test.equal(token2.type, TokenType.Name);295 test.equal(token2.value, 'x');296 297 test.strictEqual(lexer.nextToken(), null);298};299300exports['Get unquote character and name'] = function (test) {301 const lexer = lexers.lexer("~x");302 303 const token = lexer.nextToken();304 305 test.ok(token);306 test.equal(token.type, TokenType.Name);307 test.equal(token.value, "~");308 309 const token2 = lexer.nextToken();310 311 test.ok(token2);312 test.equal(token2.type, TokenType.Name);313 test.equal(token2.value, 'x');314 315 test.strictEqual(lexer.nextToken(), null);316};317318exports['Get unquote splicing and name'] = function (test) {319 const lexer = lexers.lexer("~@x");320 321 const token = lexer.nextToken();322 323 test.ok(token);324 test.equal(token.type, TokenType.Name);325 test.equal(token.value, "~@");326 327 const token2 = lexer.nextToken();328 329 test.ok(token2);330 test.equal(token2.type, TokenType.Name);331 test.equal(token2.value, 'x');332 333 test.strictEqual(lexer.nextToken(), null); ...

Full Screen

Full Screen

useUpdateAmount.ts

Source:useUpdateAmount.ts Github

copy

Full Screen

1import { useState, useEffect } from 'react';2import { ReefswapPool } from '../api/rpc/pools';3import { TokenWithAmount } from '../api/rpc/tokens';4import {5 assertAmount, getInputAmount, getOutputAmount,6} from '../utils/math';7export type SwapFocus = 'buy' | 'sell';8interface UpdateAmountHookInput {9 pool?: ReefswapPool;10 token1: TokenWithAmount;11 token2: TokenWithAmount;12 setToken1: (value: TokenWithAmount) => void;13 setToken2: (value: TokenWithAmount) => void;14}15interface SwapAmountHookInput extends UpdateAmountHookInput {16 focus: SwapFocus;17}18export const useUpdateSwapAmount = ({19 pool, token2, token1, setToken1: setSell, setToken2: setBuy, focus,20}: SwapAmountHookInput): void => {21 useEffect(() => {22 if (!pool || token2.price === 0 || token1.price === 0) { return; }23 if (focus === 'sell') {24 setBuy({ ...token2, amount: getOutputAmount(token1, pool).toFixed(4) });25 } else {26 setSell({ ...token1, amount: getInputAmount(token2, pool).toFixed(4) });27 }28 }, [token2.price, token1.price]);29};30export const useUpdateLiquidityAmount = ({31 pool, token1, token2, setToken1, setToken2,32}: UpdateAmountHookInput): void => {33 const [prevAddress1, setPrevAddress1] = useState(token1.address);34 const [prevAddress2, setPrevAddress2] = useState(token2.address);35 useEffect(() => {36 if (!pool || token1.price === 0 || token2.price === 0) { return; }37 const ratio = token2.price / token1.price;38 if (token1.address !== prevAddress1) {39 const amount = parseFloat(assertAmount(token2.amount)) * ratio;40 setToken1({ ...token1, amount: amount === 0 ? '' : amount.toFixed(4) });41 } else if (token2.address !== prevAddress2) {42 const amount = parseFloat(assertAmount(token1.amount)) / ratio;43 setToken2({ ...token2, amount: amount === 0 ? '' : amount.toFixed(4) });44 }45 setPrevAddress1(token1.address);46 setPrevAddress2(token2.address);47 }, [token1.price, token2.price]);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { TestBed } from '@angular/core/testing';2import { HttpClient, HttpErrorResponse } from '@angular/common/http';3import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';4describe('HttpClient', () => {5 let httpClient: HttpClient;6 let httpTestingController: HttpTestingController;7 beforeEach(() => {8 TestBed.configureTestingModule({9 imports: [ HttpClientTestingModule ]10 });11 httpClient = TestBed.get(HttpClient);12 httpTestingController = TestBed.get(HttpTestingController);13 });14 afterEach(() => {15 httpTestingController.verify();16 });17 it('can test HttpClient.get', () => {18 const testData = { name: 'Test Data' };19 httpClient.get('/data')20 .subscribe(data =>21 expect(data).toEqual(testData)22 );23 const req = httpTestingController.expectOne('/data');24 expect(req.request.method).toEqual('GET');25 req.flush(testData);26 httpTestingController.verify();27 });28 it('can test for 404 error', () => {29 const emsg = 'deliberate 404 error';30 httpClient.get('/data').subscribe(31 data => fail('should have failed with the 404 error'),32 (error: HttpErrorResponse) => {33 expect(error.status).toEqual(404, 'status');34 expect(error.error).toEqual(emsg, 'message');35 }36 );37 const req = httpTestingController.expectOne('/data');38 req.flush(emsg, {status: 404, statusText: 'Not Found'});39 });40 it('can test for network error', () => {41 const emsg = 'simulated network error';42 httpClient.get('/data').subscribe(43 data => fail('should have failed with the network

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('test', () => {2 beforeEach(() => {3 TestBed.configureTestingModule({4 {5 }6 });7 });8 it('should work', () => {9 const test = TestBed.get(TOKEN2);10 expect(test).toBe('test');11 });12});13describe('test', () => {14 beforeEach(() => {15 TestBed.configureTestingModule({16 {17 }18 });19 });20 it('should work', () => {21 const test = TestBed.get(TOKEN1);22 expect(test).toBe('test');23 });24});

Full Screen

Using AI Code Generation

copy

Full Screen

1createComponent() {2 const injector = TestBed.configureTestingModule({3 {4 useValue: {5 get: () => {6 return {7 get: () => {8 return {9 test: () => {10 return 'test';11 }12 };13 }14 };15 }16 }17 }18 });19 const fixture = TestBed.createComponent(AppComponent);20 const app = fixture.debugElement.componentInstance;21 return app;22 }23 createComponent2() {24 const injector = TestBed.configureTestingModule({25 {26 useValue: {27 get: () => {28 return {29 get: () => {30 return {31 test: () => {32 return 'test';33 }34 };35 }36 };37 }38 }39 }40 });41 const fixture = TestBed.createComponent(AppComponent);42 const app = fixture.debugElement.componentInstance;43 return app;44 }45 createComponent3() {46 const injector = TestBed.configureTestingModule({47 {48 useValue: {49 get: () => {50 return {51 get: () => {52 return {53 test: () => {54 return 'test';55 }56 };57 }

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Component, Input, NgModule } from '@angular/core';2import { CommonModule } from '@angular/common';3import { MockBuilder, MockInstance, MockRender, MockReset } from 'ng-mocks';4import { MockComponent } from 'ng-mocks';5@Component({6})7export class TestComponent {8 @Input() show = false;9}10@Component({11})12export class TestComponent {13 @Input() show = false;14}15@Component({16})17export class TestComponent {18 @Input() show = false;19}20@Component({21})22export class TestComponent {23 @Input() show = false;24}25@Component({26})27export class TestComponent {28 @Input() show = false;29}30@Component({

Full Screen

Using AI Code Generation

copy

Full Screen

1var $httpBackend = $injector.get('$httpBackend');2var $httpBackend = $injector.get('$httpBackend');3 return [200, 'success', {}];4});5var $httpBackend = $injector.get('$httpBackend');6 return [200, 'success', {}];7});8 return [200, 'success', {}];9});10 return [200, 'success', {}];11});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ng-mocks automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful