Best JavaScript code snippet using mountebank
enum.ts
Source:enum.ts
1module RongIMLib {2 export enum MentionedType {3 ALL = 1,4 PART = 25 }6 export enum BlacklistStatus {7 /**8 * å¨é»ååä¸ã9 */10 IN_BLACK_LIST = 0,11 /**12 * ä¸å¨é»ååä¸ã13 */14 NOT_IN_BLACK_LIST = 115 }16 export enum ConnectionChannel {17 XHR_POLLING = 0,18 WEBSOCKET = 1,19 //å¤é¨è°ç¨20 HTTP = 0,21 //å¤é¨è°ç¨22 HTTPS = 123 }24 export enum CustomerType {25 ONLY_ROBOT = 1,26 ONLY_HUMAN = 2,27 ROBOT_FIRST = 3,28 HUMAN_FIRST = 429 }30 export enum GetChatRoomType {31 NONE = 0,32 SQQUENCE = 1,33 REVERSE = 234 }35 export enum ConnectionStatus {36 /**37 * è¿æ¥æåã38 */39 CONNECTED = 0,40 /**41 * è¿æ¥ä¸ã42 */43 CONNECTING = 1,44 /**45 * æå¼è¿æ¥ã46 */47 DISCONNECTED = 2,48 /**49 * ç¨æ·è´¦æ·å¨å
¶ä»è®¾å¤ç»å½ï¼æ¬æºä¼è¢«è¸¢æ线ã50 */51 KICKED_OFFLINE_BY_OTHER_CLIENT = 6,52 /**53 * ç½ç»ä¸å¯ç¨ã54 */55 NETWORK_UNAVAILABLE = 3,56 /**57 * ååé误58 */59 DOMAIN_INCORRECT = 12,60 /**61 * è¿æ¥å
³éã62 */63 CONNECTION_CLOSED = 464 }65 export enum ConversationNotificationStatus {66 /**67 * å
ææ°ç¶æï¼å
³é对åºä¼è¯çéç¥æéã68 */69 DO_NOT_DISTURB,70 /**71 * æéã72 */73 NOTIFY74 }75 export enum ConversationType {76 NONE = 0,77 PRIVATE = 1,78 DISCUSSION = 2,79 GROUP = 3,80 CHATROOM = 4,81 CUSTOMER_SERVICE = 5,82 SYSTEM = 6,83 //é»è®¤å
³æ³¨ MC84 APP_PUBLIC_SERVICE = 7,85 //æå·¥å
³æ³¨ MP86 PUBLIC_SERVICE = 887 }8889 export enum DiscussionInviteStatus {90 /**91 * å¼æ¾é请ã92 */93 OPENED = 0,9495 /**96 * å
³éé请ã97 */98 CLOSED = 199 }100101 export enum ErrorCode {102103 /**104 * åéé¢çè¿å¿«105 */106 SEND_FREQUENCY_TOO_FAST = 20604,107108 RC_MSG_UNAUTHORIZED = 20406,109 /**110 * ç¾¤ç» Id æ æ111 */112 RC_DISCUSSION_GROUP_ID_INVALID = 20407,113 /**114 * 群ç»è¢«ç¦è¨115 */116 FORBIDDEN_IN_GROUP = 22408,117 /**118 * ä¸å¨è®¨è®ºç»ã119 */120 NOT_IN_DISCUSSION = 21406,121 /**122 * ä¸å¨ç¾¤ç»ã123 */124 NOT_IN_GROUP = 22406,125 /**126 * ä¸å¨è天室ã127 */128 NOT_IN_CHATROOM = 23406,129 /**130 *è天室被ç¦è¨131 */132 FORBIDDEN_IN_CHATROOM = 23408,133 /**134 * è天室ä¸æå被踢åº135 */136 RC_CHATROOM_USER_KICKED = 23409,137 /**138 * è天室ä¸åå¨139 */140 RC_CHATROOM_NOT_EXIST = 23410,141 /**142 * è天室æå已满143 */144 RC_CHATROOM_IS_FULL = 23411,145 /**146 * è·åè天室信æ¯åæ°æ æ147 */148 RC_CHATROOM_PATAMETER_INVALID = 23412,149150 TIMEOUT = -1,151 /**152 * æªç¥åå 失败ã153 */154 UNKNOWN = -2,155156 /**157 * å å
¥è®¨è®ºå¤±è´¥158 */159 JOIN_IN_DISCUSSION = 21407,160 /**161 * å建讨论ç»å¤±è´¥162 */163 CREATE_DISCUSSION = 21408,164 /**165 * 设置讨论ç»é请ç¶æ失败166 */167 INVITE_DICUSSION = 21409,168169170171 /**172 *è·åç¨æ·å¤±è´¥173 */174 GET_USERINFO_ERROR = 23407,175176 /**177 * å¨é»ååä¸ã178 */179 REJECTED_BY_BLACKLIST = 405,180181 /**182 * éä¿¡è¿ç¨ä¸ï¼å½å Socket ä¸åå¨ã183 */184 RC_NET_CHANNEL_INVALID = 30001,185186 /**187 * Socket è¿æ¥ä¸å¯ç¨ã188 */189 RC_NET_UNAVAILABLE = 30002,190191 /**192 * éä¿¡è¶
æ¶ã193 */194 RC_MSG_RESP_TIMEOUT = 30003,195196 /**197 * 导èªæä½æ¶ï¼Http 请æ±å¤±è´¥ã198 */199 RC_HTTP_SEND_FAIL = 30004,200201 /**202 * HTTP 请æ±å¤±è´¥ã203 */204 RC_HTTP_REQ_TIMEOUT = 30005,205206 /**207 * HTTP æ¥æ¶å¤±è´¥ã208 */209 RC_HTTP_RECV_FAIL = 30006,210211 /**212 * 导èªæä½ç HTTP 请æ±ï¼è¿åä¸æ¯200ã213 */214 RC_NAVI_RESOURCE_ERROR = 30007,215216 /**217 * 导èªæ°æ®è§£æåï¼å
¶ä¸ä¸åå¨æææ°æ®ã218 */219 RC_NODE_NOT_FOUND = 30008,220221 /**222 * 导èªæ°æ®è§£æåï¼å
¶ä¸ä¸åå¨ææ IP å°åã223 */224 RC_DOMAIN_NOT_RESOLVE = 30009,225226 /**227 * å建 Socket 失败ã228 */229 RC_SOCKET_NOT_CREATED = 30010,230231 /**232 * Socket 被æå¼ã233 */234 RC_SOCKET_DISCONNECTED = 30011,235236 /**237 * PING æä½å¤±è´¥ã238 */239 RC_PING_SEND_FAIL = 30012,240241 /**242 * PING è¶
æ¶ã243 */244 RC_PONG_RECV_FAIL = 30013,245 /**246 * æ¶æ¯åé失败ã247 */248 RC_MSG_SEND_FAIL = 30014,249250 /**251 * å connect è¿æ¥æ¶ï¼æ¶å°ç ACK è¶
æ¶ã252 */253 RC_CONN_ACK_TIMEOUT = 31000,254255 /**256 * åæ°é误ã257 */258 RC_CONN_PROTO_VERSION_ERROR = 31001,259260 /**261 * åæ°é误ï¼App Id é误ã262 */263 RC_CONN_ID_REJECT = 31002,264265 /**266 * æå¡å¨ä¸å¯ç¨ã267 */268 RC_CONN_SERVER_UNAVAILABLE = 31003,269270 /**271 * Token é误ã272 */273 RC_CONN_USER_OR_PASSWD_ERROR = 31004,274275 /**276 * App Id ä¸ Token ä¸å¹é
ã277 */278 RC_CONN_NOT_AUTHRORIZED = 31005,279280 /**281 * éå®åï¼å°åé误ã282 */283 RC_CONN_REDIRECTED = 31006,284285 /**286 * NAME ä¸åå°æ³¨åä¿¡æ¯ä¸ä¸è´ã287 */288 RC_CONN_PACKAGE_NAME_INVALID = 31007,289290 /**291 * APP 被å±è½ãå é¤æä¸åå¨ã292 */293 RC_CONN_APP_BLOCKED_OR_DELETED = 31008,294295 /**296 * ç¨æ·è¢«å±è½ã297 */298 RC_CONN_USER_BLOCKED = 31009,299300 /**301 * Disconnectï¼ç±æå¡å¨è¿åï¼æ¯å¦ç¨æ·äºè¸¢ã302 */303 RC_DISCONN_KICK = 31010,304305 /**306 * Disconnectï¼ç±æå¡å¨è¿åï¼æ¯å¦ç¨æ·äºè¸¢ã307 */308 RC_DISCONN_EXCEPTION = 31011,309310 /**311 * åè®®å±å
é¨é误ãqueryï¼ä¸ä¼ ä¸è½½è¿ç¨ä¸æ°æ®é误ã312 */313 RC_QUERY_ACK_NO_DATA = 32001,314315 /**316 * åè®®å±å
é¨é误ã317 */318 RC_MSG_DATA_INCOMPLETE = 32002,319320 /**321 * æªè°ç¨ init åå§åå½æ°ã322 */323 BIZ_ERROR_CLIENT_NOT_INIT = 33001,324325 /**326 * æ°æ®åºåå§å失败ã327 */328 BIZ_ERROR_DATABASE_ERROR = 33002,329330 /**331 * ä¼ å
¥åæ°æ æã332 */333 BIZ_ERROR_INVALID_PARAMETER = 33003,334335 /**336 * ééæ æã337 */338 BIZ_ERROR_NO_CHANNEL = 33004,339340 /**341 * éæ°è¿æ¥æåã342 */343 BIZ_ERROR_RECONNECT_SUCCESS = 33005,344 /**345 * è¿æ¥ä¸ï¼åè°ç¨ connect 被æç»ã346 */347 BIZ_ERROR_CONNECTING = 33006,348 /**349 * æ¶æ¯æ¼«æ¸¸æå¡æªå¼é350 */351 MSG_ROAMING_SERVICE_UNAVAILABLE = 33007,352353 /**354 * å é¤ä¼è¯å¤±è´¥355 */356 CONVER_REMOVE_ERROR = 34001,357 /**358 *æååå²æ¶æ¯359 */360 CONVER_GETLIST_ERROR = 34002,361 /**362 * ä¼è¯æå®å¼å¸¸363 */364 CONVER_SETOP_ERROR = 34003,365 /**366 * è·åä¼è¯æªè¯»æ¶æ¯æ»æ°å¤±è´¥367 */368 CONVER_TOTAL_UNREAD_ERROR = 34004,369 /**370 * è·åæå®ä¼è¯ç±»åæªè¯»æ¶æ¯æ°å¼å¸¸371 */372 CONVER_TYPE_UNREAD_ERROR = 34005,373 /**374 * è·åæå®ç¨æ·ID&ä¼è¯ç±»åæªè¯»æ¶æ¯æ°å¼å¸¸375 */376 CONVER_ID_TYPE_UNREAD_ERROR = 34006,377 //群ç»å¼å¸¸ä¿¡æ¯378 /**379 *380 */381 GROUP_SYNC_ERROR = 35001,382 /**383 * å¹é
群信æ¯ç³»å¼å¸¸384 */385 GROUP_MATCH_ERROR = 35002,386387 //è天室å¼å¸¸388 /**389 * å å
¥è天室Id为空390 */391 CHATROOM_ID_ISNULL = 36001,392 /**393 * å å
¥è天室失败394 */395 CHARTOOM_JOIN_ERROR = 36002,396 /**397 * æåè天室åå²æ¶æ¯å¤±è´¥398 */399 CHATROOM_HISMESSAGE_ERROR = 36003,400 //é»ååå¼å¸¸401 /**402 * å å
¥é»ååå¼å¸¸403 */404 BLACK_ADD_ERROR = 37001,405 /**406 * è·å¾æå®äººååé»ååä¸çç¶æå¼å¸¸407 */408 BLACK_GETSTATUS_ERROR = 37002,409 /**410 * 移é¤é»ååå¼å¸¸411 */412 BLACK_REMOVE_ERROR = 37003,413 /**414 * è·åè稿失败415 */416 DRAF_GET_ERROR = 38001,417 /**418 * ä¿åè稿失败419 */420 DRAF_SAVE_ERROR = 38002,421 /**422 * å é¤è稿失败423 */424 DRAF_REMOVE_ERROR = 38003,425 /**426 * å
³æ³¨å
¬ä¼å·å¤±è´¥427 */428 SUBSCRIBE_ERROR = 39001,429 /**430 * å
³æ³¨å
¬ä¼å·å¤±è´¥431 */432 QNTKN_FILETYPE_ERROR = 41001,433 /**434 * è·åä¸çtoken失败435 */436 QNTKN_GET_ERROR = 41002,437 /**438 * cookie被ç¦ç¨439 */440 COOKIE_ENABLE = 51001,441442 // 没æ注åDeviveId ä¹å°±æ¯ç¨æ·æ²¡æç»é443 HAVNODEVICEID = 24001,444445 // å·²ç»åå¨446 DEVICEIDISHAVE = 24002,447448 // æå449 SUCCESS = 0,450451 // 没æ对åºçç¨æ·ætoken452 FEILD = 24009,453454 // voip为空455 VOIPISNULL = 24013,456457 // ä¸æ¯æçVoipå¼æ458 NOENGINETYPE = 24010,459460 // channleName æ¯ç©º461 NULLCHANNELNAME = 24011,462463 // çæVoipkey失败464 VOIPDYANMICERROR = 24012,465466 // 没æé
ç½®voip467 NOVOIP = 24014,468469 // æå¡å¨å
é¨é误470 INTERNALERRROR = 24015,471472 //VOIP close473 VOIPCLOSE = 24016,474475 CLOSE_BEFORE_OPEN = 51001,476477 ALREADY_IN_USE = 51002,478479 INVALID_CHANNEL_NAME = 51003,480481 VIDEO_CONTAINER_IS_NULL = 51004,482 /*!483 å·±æ¹åæ¶å·²ååºçéè¯è¯·æ±484 */485 CANCEL = 1,486 /*!487 å·±æ¹æç»æ¶å°çéè¯è¯·æ±488 */489 REJECT = 2,490 /*!491 å·±æ¹ææ492 */493 HANGUP = 3,494 /*!495 å·±æ¹å¿ç¢496 */497 BUSYLINE = 4,498 /*!499 å·±æ¹æªæ¥å¬500 */501 NO_RESPONSE = 5,502 /*!503 å·±æ¹ä¸æ¯æå½åå¼æ504 */505 ENGINE_UN_SUPPORTED = 6,506 /*!507 å·±æ¹ç½ç»åºé508 */509 NETWORK_ERROR = 7,510 /*!511 对æ¹åæ¶å·²ååºçéè¯è¯·æ±512 */513 REMOTE_CANCEL = 11,514515 /*!516 对æ¹æç»æ¶å°çéè¯è¯·æ±517 */518 REMOTE_REJECT = 12,519 /*!520 éè¯è¿ç¨å¯¹æ¹ææ521 */522 REMOTE_HANGUP = 13,523524 /*!525 对æ¹å¿ç¢526 */527 REMOTE_BUSYLINE = 14,528 /*!529 对æ¹æªæ¥å¬530 */531 REMOTE_NO_RESPONSE = 15,532 /*!533 对æ¹ç½ç»é误534 */535 REMOTE_ENGINE_UN_SUPPORTED = 16,536 /*!537 对æ¹ç½ç»é误538 */539 REMOTE_NETWORK_ERROR = 17,540 /*!541 VoIP ä¸å¯ç¨542 */543 VOIP_NOT_AVALIABLE = 18544545 }546 export enum VoIPMediaType {547548 MEDIA_AUDIO = 1,549550 MEDIA_VEDIO = 2,551 }552553 export enum MediaType {554 /**555 * å¾çã556 */557 IMAGE = 1,558559 /**560 * 声é³ã561 */562 AUDIO = 2,563564 /**565 * è§é¢ã566 */567 VIDEO = 3,568569 /**570 * éç¨æ件ã571 */572 FILE = 100573 }574575 export enum MessageDirection {576 /**577 * åéæ¶æ¯ã578 */579 SEND = 1,580581 /**582 * æ¥æ¶æ¶æ¯ã583 */584 RECEIVE = 2585 }586587 export enum FileType {588 IMAGE = 1,589 AUDIO = 2,590 VIDEO = 3,591 FILE = 4592 }593594 export enum RealTimeLocationErrorCode {595 /**596 * æªåå§å RealTimeLocation å®ä¾597 */598 RC_REAL_TIME_LOCATION_NOT_INIT = -1,599600 /**601 * æ§è¡æåã602 */603 RC_REAL_TIME_LOCATION_SUCCESS = 0,604605 /**606 * è·å RealTimeLocation å®ä¾æ¶è¿å607 * GPS æªæå¼ã608 */609 RC_REAL_TIME_LOCATION_GPS_DISABLED = 1,610 /**611 * è·å RealTimeLocation å®ä¾æ¶è¿å612 * å½åä¼è¯ä¸æ¯æä½ç½®å
±äº«ã613 */614 RC_REAL_TIME_LOCATION_CONVERSATION_NOT_SUPPORT = 2,615616 /**617 * è·å RealTimeLocation å®ä¾æ¶è¿å618 * 对æ¹å·²åèµ·ä½ç½®å
±äº«ã619 */620 RC_REAL_TIME_LOCATION_IS_ON_GOING = 3,621 /**622 * Join æ¶è¿å623 * å½åä½ç½®å
±äº«å·²è¶
è¿æ大æ¯æ人æ°ã624 */625 RC_REAL_TIME_LOCATION_EXCEED_MAX_PARTICIPANT = 4,626627 /**628 * Join æ¶è¿å629 * å å
¥ä½ç½®å
±äº«å¤±è´¥ã630 */631 RC_REAL_TIME_LOCATION_JOIN_FAILURE = 5,632633 /**634 * Start æ¶è¿å635 * åèµ·ä½ç½®å
±äº«å¤±è´¥ã636 */637 RC_REAL_TIME_LOCATION_START_FAILURE = 6,638639 /**640 * ç½ç»ä¸å¯ç¨ã641 */642 RC_REAL_TIME_LOCATION_NETWORK_UNAVAILABLE = 7643 }644645 export enum RealTimeLocationStatus {646 /**647 * 空é²ç¶æ ï¼é»è®¤ç¶æï¼648 * 对æ¹æè
èªå·±é½æªåèµ·ä½ç½®å
±äº«ä¸å¡ï¼æè
ä½ç½®å
±äº«ä¸å¡å·²ç»æã649 */650 RC_REAL_TIME_LOCATION_STATUS_IDLE = 0,651652 /**653 * å¼å
¥ç¶æ ï¼å¾
å å
¥ï¼654 * 1. 对æ¹åèµ·äºä½ç½®å
±äº«ä¸å¡ï¼æ¤ç¶æä¸ï¼èªå·±åªè½éæ©å å
¥ã655 * 2. èªå·±ä»å·²è¿æ¥çä½ç½®å
±äº«ä¸éåºã656 */657 RC_REAL_TIME_LOCATION_STATUS_INCOMING = 1,658659 /**660 * å¼åºç¶æ =ï¼èªå·±å建ï¼661 * 1. èªå·±åèµ·ä½ç½®å
±äº«ä¸å¡ï¼å¯¹æ¹åªè½éæ©å å
¥ã662 * 2. 对æ¹ä»å·²è¿æ¥çä½ç½®å
±äº«ä¸å¡ä¸éåºã663 */664 RC_REAL_TIME_LOCATION_STATUS_OUTGOING = 2,665666 /**667 * è¿æ¥ç¶æ ï¼èªå·±å å
¥ï¼668 * 对æ¹å å
¥äºèªå·±åèµ·çä½ç½®å
±äº«ï¼æè
èªå·±å å
¥äºå¯¹æ¹åèµ·çä½ç½®å
±äº«ã669 */670 RC_REAL_TIME_LOCATION_STATUS_CONNECTED = 3671 }672673 export enum ReceivedStatus {674 READ = 0x1,675676 LISTENED = 0x2,677678 DOWNLOADED = 0x4,679680 RETRIEVED = 0x8,681682 UNREAD = 0x9683684 }685686 export enum SearchType {687 /**688 * 精确ã689 */690 EXACT = 0,691692 /**693 * 模ç³ã694 */695 FUZZY = 1696 }697698 export enum SentStatus {699 /**700 * åéä¸ã701 */702 SENDING = 10,703704 /**705 * åé失败ã706 */707 FAILED = 20,708709 /**710 * å·²åéã711 */712 SENT = 30,713714 /**715 * 对æ¹å·²æ¥æ¶ã716 */717 RECEIVED = 40,718719 /**720 * 对æ¹å·²è¯»ã721 */722 READ = 50,723724 /**725 * 对æ¹å·²éæ¯ã726 */727 DESTROYED = 60728 }729730731 export enum ConnectionState {732733 ACCEPTED = 0,734735 UNACCEPTABLE_PROTOCOL_VERSION = 1,736737 IDENTIFIER_REJECTED = 2,738739 SERVER_UNAVAILABLE = 3,740 /**741 * tokenæ æ742 */743 TOKEN_INCORRECT = 4,744745 NOT_AUTHORIZED = 5,746747 REDIRECT = 6,748749 PACKAGE_ERROR = 7,750751 APP_BLOCK_OR_DELETE = 8,752753 BLOCK = 9,754755 TOKEN_EXPIRE = 10,756757 DEVICE_ERROR = 11758 }
...
reformat_custom.js
Source:reformat_custom.js
1function initClearlyComponent__reformat_custom(_paramInstance){if(_paramInstance){}else{return false;}2var $RC=_paramInstance;switch(true)3{case(!($RC.settings)):case(!($RC.settings.path)):case(!($RC.window)):case(!($RC.window.document)):case(!($RC.window.document.body)):case(!($RC.jQuery)):if($RC.debug)4{console.log(!($RC.settings));console.log(!($RC.settings.path));console.log(!($RC.window));console.log(!($RC.window.document));console.log(!($RC.window.document.body));console.log(!($RC.jQuery));}5return false;}6$RC.document=$RC.window.document;var _default=function(_setting,_default_value){if($RC.settings[_setting]){}else{$RC.settings[_setting]=_default_value;}};_default('onCreateFrameUseThisId','clearly_frame_custom');_default('onCreateFrameUseThisBaseTimer',50);_default('onCreateFrameUseThisURLAsTheLocation','');_default('onCreateFrameDoNotInsertCSS',false);_default('onCreateFrameInjectThisHTMLAfter','');_default('onCreateFrameInjectThisHTMLBefore','');_default('onCreateFrameWaitForTheseWindowVars',[]);_default('createFrameInsideElementWithThisId','');_default('doDocumentWrite',function(_document,_html){_document.open();_document.write(_html);_document.close();});_default('imgPath',$RC.settings.path+'img/');_default('cssPath',$RC.settings.path+'css/');_default('cssImagesFile',$RC.settings.cssPath+'images.css');_default('cssFontsFile',$RC.settings.cssPath+'fonts.css');var $=$RC.jQuery;$RC.$window=$($RC.window);$RC.$document=$($RC.document);$RC.detected=false;$RC.checkedSections=false;$RC.uncheckedSections=false;$RC.debug=($RC.debug||false);$RC.debugRemembered={};if($RC.debug)7{switch(true)8{case(!(!($RC.window.console&&$RC.window.console.log))):$RC.logOneline=function(msg){$RC.window.console.log(msg);};break;case(!(!($RC.window.opera&&$RC.window.opera.postError))):$RC.logOneline=function(msg){$RC.window.opera.postError(msg);};break;default:$RC.logOneline=function(msg){};break;}9$RC.log=function()10{if($RC.debug){}else{return;}11for(var i=0,il=arguments.length;i<il;i++){$RC.logOneline(arguments[i]);}12$RC.logOneline('-----------------------------------------');};$RC.debugRemember=function(_k,_v)13{$RC.debugRemembered[_k]=_v;};}14else15{$RC.writeLog=function(){return false;};$RC.log=function(){return false;};$RC.debugRemember=function(){return false;};}16$RC.escape_html=function(_string)17{var _replace={"&":"amp",'"':"quot","<":"lt",">":"gt"};return((_string&&_string.replace)?_string.replace(/[&"<>]/g,function(_match){return("&"+_replace[_match]+";");}):'');};$RC.encode=function(_string)18{if(_string==''){return'none';}19var _replace={"!":"%21","'":"%27","(":"%28",")":"%29","*":"%2A"};return((_string&&_string.replace)?_string.replace(/[!'()*]/g,function(_match){return _replace[_match];}):'');};$RC.decode=function(_string)20{if(_string=='none'){return'';}21return((_string&&_string.replace)?decodeURIComponent(_string):'');};$RC.composer__loop=function(_array,_callback)22{if(_array&&_array.length){}else{return;}23for(var _item=false,_i=0,_ii=_array.length;_i<_ii;_i++)24{_item=_array[_i];_callback(_item,((_i===0)?0:((_i==_ii)?-1:_i)));}};$RC.composer__div=function(_content,_class,_after,_no_escape)25{if(_content){}else{return'';}26return''+'<div'+(_class?' class="'+$RC.composer__esc(_class)+'"':'')+'>'+27(_no_escape?_content:$RC.composer__esc(_content))+'</div>'+28(_after?_after:'')+'';};$RC.composer__raw=function(_content,_class,_after)29{return $RC.composer__div(_content,_class,_after,true);};$RC.composer__n2b=function(_text)30{if(!_text||typeof(_text)!=='string'){return'';}31return _text.replace(/[\r][\n]/gi,"\n").replace(/[\r]/gi,"\n").replace(/[\n]/gi,$RC.composer__br());};$RC.composer__br=function()32{return(arguments.length?(arguments[0]?'<br>':''):'<br>');};$RC.composer__hr=function()33{return'<div class="hr"></div>';};$RC.composer__esc=function(_text)34{return $RC.escape_html(_text);};$RC.sites={'amazon':{'sections_order':['top','images','bullets','book_description','product_description','dp_review','technical_details','reviews'],'sections_unchecked':false,'translations':{},'composer':function(_data,_loop,_div,_raw,_n2b,_esc,_br,_hr){return{'top':(function()35{var _retina=(($RC.window.devicePixelRatio&&($RC.window.devicePixelRatio>1))?'@2x':''),_return=''+36_div(_data.name,'header')+37_raw('<a href="'+_esc(_data.url)+'">'+_esc(_data.url)+'</a>')+'<table class="middle"><tr>'+'<td>'+'<img class="stars" src="'+$RC.settings.imgPath+'amazon--stars--'+_esc(_data.stars_icon)+_retina+'.png" />'+'</td>'+38(_data.stars_text?('<td>'+' | '+'</td>'+'<td>'+'<spam>'+_esc(_data.stars_text)+'</span>'+'</td>'):'')+39(_data.stars_count?('<td>'+' | '+'</td>'+'<td>'+'<spam>'+_esc(_data.stars_count)+'</span>'+'</td>'):'')+'</tr></table>'+40_div(_data.price,'bold')+'';return _return;})(),'images':(function()41{var _return='';_loop(_data.images,function(_item,_index)42{_return+=''+'<img class="product_image" src="'+_esc(_item)+'" />'+'';});return(_return?(_div(_data.headers.images,'header',_br())+_return):'');})(),'bullets':(function()43{var _return='';_loop(_data.bullets,function(_item,_index)44{_return+=''+'<li>'+_esc(_item)+'</li>'+'';});return(_return?(_div(_data.headers.bullets,'header',_br())+'<ul>'+_return+'<ul>'):'');})(),'reviews':(function()45{var _retina=(($RC.window.devicePixelRatio&&($RC.window.devicePixelRatio>1))?'@2x':''),_return='';_loop(_data.reviews,function(_item,_index)46{_return+=''+47_br(_index)+48_div(_item.title,'bold')+'<table class="middle"><tr>'+'<td>'+'<img class="stars" src="'+$RC.settings.imgPath+'amazon--stars--'+_esc(_item.stars_icon)+_retina+'.png" />'+'</td>'+'<td>'+' | '+'</td>'+'<td>'+'<spam>'+_esc(_item.reviewer_and_date)+'</span>'+'</td>'+'</tr></table>'+49_div(_item.usefulness,'light')+50_raw((function()51{var _return_quote=_n2b(_esc(_item.quote));if(_item.quote_more_url&&_item.quote_more_label){_return_quote+=' <a href="'+_esc(_item.quote_more_url)+'" target="_blank">'+_esc(_item.quote_more_label)+'</a>';}52return _return_quote;})())+'';});return(_return?(_div(_data.headers.reviews,'header',_br())+_return):'');})(),'book_description':(function()53{var _return=''+54_raw(_n2b(_esc(_data.book_description)))+'';return(_return?(_div(_data.headers.book_description,'header',_br())+_return):'');})(),'product_description':(function()55{var _return=''+56_raw(_n2b(_esc(_data.product_description)))+'';return(_return?(_div(_data.headers.product_description,'header',_br())+_return):'');})(),'technical_details':(function()57{var _return_tables='';_loop(_data.technical_details,function(_item_table,_index_table)58{_return_tables+=''+59(function()60{var _return_rows='';_loop(_item_table,function(_item_row,_index_row)61{_return_rows+='<tr>'+'<td class="label">'+_esc(_item_row.label)+'</td>'+'<td>'+_n2b(_esc(_item_row.value))+'</td>'+'</tr>';});return(_return_rows?('<table class="technical">'+_return_rows+'</table>'+_br()):'');})()+'';});_return_tables=(_return_tables?_return_tables.substr(0,(_return_tables.length-_br().length)):'');return(_return_tables?(_div(_data.headers.technical_details,'header',_br())+_return_tables):'');})(),'dp_review':(function()62{if(_data.dp_review){}else{return'';}63var _return=''+64_div(_data.dp_review.score_label+' '+_data.dp_review.score+' | '+_data.dp_review.date,'bold')+65_div(_data.dp_review.summary)+66(function()67{var _return_pros='';_loop(_data.dp_review.pros,function(_item,_index)68{_return_pros+=''+'<li>'+_esc(_item)+'</li>'+'';});return(_return_pros?(_br()+_div(_data.dp_review.pros_label,'bold')+'<ul>'+_return_pros+'</ul>'):'');})()+69(function()70{var _return_cons='';_loop(_data.dp_review.cons,function(_item,_index)71{_return_cons+=''+'<li>'+_esc(_item)+'</li>'+'';});return(_return_cons?(_br()+_div(_data.dp_review.cons_label,'bold')+'<ul>'+_return_cons+'</ul>'):'');})()+72_br()+73_raw('<a href="'+_esc(_data.dp_review.more_url)+'" target="_blank">'+_esc(_data.dp_review.more_label)+'</a>')+'';return(_return?(_div(_data.headers.dp_review,'header',_br())+_return):'');})()};}},'linked_in':{'sections_order':['top','summary','experience','skills','education','endorsements'],'sections_unchecked':false,'composer':function(_data,_loop,_div,_raw,_n2b,_esc,_br,_hr){return{'top':(function()74{var _return=''+75_div(_data.name,'header')+76(_data.email?_raw('<a href="mailto:'+_esc(_data.email)+'">'+_data.email+'</a>'):'')+77_div(_data.headline)+78_div(_data.demographics)+79_br(_data.image)+80(_data.image?_raw('<img class="profile_picture" src="'+_esc(_data.image)+'" />'):'')+81_br()+82_raw('<a href="'+_esc(_data.url)+'">'+_esc(_data.url)+'</a>')+'';return _return;})(),'summary':(function()83{var _return=''+84_div(_data.current_summary)+85_div(_data.experience_summary)+86_div(_data.education_summary)+87_br(_data.description)+88_raw(_n2b(_esc(_data.description)))+'';return(_return?(_div(_data.headers.summary,'header',_br())+_return):'');})(),'experience':(function()89{var _return='';_loop(_data.experience,function(_item,_index)90{_return+=''+91_br(_index)+92_div(_item.title_and_company,'bold')+93_div(_item.period_and_location,'light')+94_raw(_n2b(_esc(_item.description)),'')+'';});return(_return?(_div(_data.headers.experience,'header',_br())+_return):'');})(),'skills':(function()95{var _return='';var _skill_count=false;_loop(_data.skills,function(_item){if(_item.count>0){_skill_count=true;}});if(_skill_count)96{_loop(_data.skills,function(_item)97{_return+='<tr>'+'<td>'+_esc(_item.count)+'</td>'+'<td>'+_esc(_item.name)+'</td>'+'</tr>';});_return=(_return?('<table class="skills">'+_return+'</table>'):'');}98else99{_loop(_data.skills,function(_item)100{_return+=_div(_item.name);});}101return(_return?(_div(_data.headers.skills,'header',_br())+_return):'');})(),'education':(function()102{var _return='';_loop(_data.education,function(_item,_index)103{_return+=''+104_br(_index)+105_div(_item.institution,'bold')+106_div(_item.major)+107_div(_item.period,'light')+'';});return(_return?(_div(_data.headers.education,'header',_br())+_return):'');})(),'endorsements':(function()108{var _return_jobs='';_loop(_data.endorsements,function(_item_job,_index_job)109{_return_jobs+=''+110_br(_index_job)+111_div(_item_job.position_and_company,'bold')+112(function()113{var _return_endorsements='';_loop(_item_job.endorsements,function(_item_endorsement,_index_endorsement)114{_return_endorsements+=''+115_br(_index_endorsement)+116_div(_item_endorsement.quote)+117_raw(('<a href="'+_esc(_item_endorsement.person_url)+'">'+_esc(_item_endorsement.person_and_position)+'</a>'),'light')+118_div(_item_endorsement.date_and_connection,'light')+'';});return _return_endorsements;})()+'';});return(_return_jobs?(_div(_data.headers.endorsements,'header',_br())+_return_jobs):'');})()};}},'youtube':{'sections_order':['top','summary','comments'],'sections_unchecked':false,'composer':function(_data,_loop,_div,_raw,_n2b,_esc,_br,_hr){return{'top':(function()119{var _return=''+120_div(_data.title,'header')+121_raw('<a href="'+_esc(_data.url)+'">'+_esc(_data.url)+'</a>')+122_raw('<a href="'+_esc(_data.author_url)+'">'+_esc(_data.author)+'</a>')+123_div(_data.views+' '+_data.views_label)+124_div(_data.published)+125_br(_data.image)+126(_data.image?(''+'<table><tr><td><div class="video_image_container">'+'<img class="video_image" src="'+_esc(_data.image)+'" />'+'<a class="video_image_play" target="_blank" href="'+_esc(_data.url)+'"></a>'+'</div></td></tr></table>'+''):'')+'';return _return;})(),'summary':(function()127{var _return=''+128_raw(_data.summary_html)+'';return(_return?(_div(_data.headers.summary,'header',_br())+_return):'');})(),'comments':(function()129{var _return='';_loop(_data.comments,function(_item,_index)130{_return+=''+131_br(_index)+132_raw(''+'<span class="bold">'+_esc(_item.author)+'</span>'+'<span> | '+_esc(_item.date)+'</span>'+'')+133_raw(_item.quote_html)+'';});return(_return?(_div(_data.headers.comments,'header',_br())+_return):'');})()};}}};$RC.createFrame=function()134{var _frame_id=$RC.settings.onCreateFrameUseThisId;var _iframeElement=$RC.document.createElement('iframe'),_iframeBodyHTML=''+135$RC.settings.onCreateFrameInjectThisHTMLBefore+'<div id="bodyContent">'+'<div id="box">'+'<div class="content" id="contentToDisplay"></div>'+'<div class="content" id="contentToSave"></div>'+'</div>'+'<div id="background"><div id="backgroundInner"></div></div>'+'</div>'+'<link rel="stylesheet" href="'+$RC.settings.cssPath+'style.css" type="text/css" />'+'<link rel="stylesheet" href="'+$RC.settings.cssImagesFile+'" type="text/css" />'+'<link rel="stylesheet" href="'+$RC.settings.cssFontsFile+'" type="text/css" />'+136$RC.settings.onCreateFrameInjectThisHTMLAfter+'',_iframeDocumentHTML=''+'<!DOCTYPE html>'+'<html id="html">'+'<body id="body">'+137_iframeBodyHTML+'</body>'+'</html>'+'';_iframeElement.setAttribute('id',_frame_id);_iframeElement.setAttribute('frameBorder','0');_iframeElement.setAttribute('allowTransparency','true');_iframeElement.setAttribute('scrolling','auto');if($RC.settings.onCreateFrameUseThisURLAsTheLocation){_iframeElement.setAttribute('src',$RC.settings.onCreateFrameUseThisURLAsTheLocation);}138if($RC.settings.onCreateFrameDoNotInsertCSS){}else139{var _cssElement=$RC.document.createElement('style'),_cssText=''+'#'+_frame_id+' { '+'margin: 0; padding: 0; border: none; '+'position: absolute; '+'width: 10px; height: 10px; '+'top: -100px; left: -100px; '+'} '+'';_cssElement.setAttribute('id',_frame_id+'__css');_cssElement.setAttribute('type','text/css');if(_cssElement.styleSheet){_cssElement.styleSheet.cssText=_cssText;}140else{_cssElement.appendChild($RC.document.createTextNode(_cssText));}}141var _parent=($RC.settings.createFrameInsideElementWithThisId?$RC.document.getElementById($RC.settings.createFrameInsideElementWithThisId):false),_container=(_parent||$RC.document.body);if(_cssElement){_container.appendChild(_cssElement);}142_container.appendChild(_iframeElement);var _check1_interval=false;var _check1=function()143{var _iframe=$RC.document.getElementById(_frame_id);if(_iframe){}else{return;}144var _doc=(_iframe.contentDocument||_iframe.contentWindow.document);if(_doc){}else{return;}145if($RC.settings.onCreateFrameUseThisURLAsTheLocation)146{var _body=_doc.getElementById('body');if(_body){}else{return;}147_body.innerHTML=_iframeBodyHTML;}148else149{$RC.settings.doDocumentWrite(_doc,_iframeDocumentHTML);}150$RC.window.clearInterval(_check1_interval);};_check1_interval=$RC.window.setInterval(_check1,$RC.settings.onCreateFrameUseThisBaseTimer);var _check2_interval=false;var _check2=function()151{var _iframe=$RC.document.getElementById(_frame_id);if(_iframe){}else{return;}152var _doc=(_iframe.contentDocument||_iframe.contentWindow.document);if(_doc){}else{return;}153var _body=_doc.getElementById('bodyContent');if(_body){}else{return;}154for(var _var='',_i=0,_ii=$RC.settings.onCreateFrameWaitForTheseWindowVars.length;_i<_ii;_i++)155{_var=$RC.settings.onCreateFrameWaitForTheseWindowVars[_i];if(_var.indexOf('.')===false)156{if(_var in _iframe.contentWindow){}else{return;}}157else158{var _chain=_var.split('.'),_curr=_iframe.contentWindow;for(var _z=0,_zz=_chain.length;_z<_zz;_z++)159{if(_chain[_z]in _curr){}else{return;}160_curr=_curr[_chain[_z]];}}}161$RC.window.clearInterval(_check2_interval);$RC.iframe=_iframe;$RC.$iframe=$($RC.iframe);$RC.iframeDocument=_doc;$RC.$iframeDocument=$($RC.iframeDocument);$RC.iframeWindow=_iframe.contentWindow;$RC.$iframeWindow=$($RC.iframeWindow);$RC.$iframeBox=$RC.$iframeDocument.find('#box');$RC.$iframeContentToDisplay=$RC.$iframeDocument.find('#contentToDisplay');$RC.$iframeContentToSave=$RC.$iframeDocument.find('#contentToSave');$RC.$iframeBackground=$RC.$iframeDocument.find('#background');if($RC.callbacks&&$RC.callbacks.frameCreated){$RC.callbacks.frameCreated();}};_check2_interval=$RC.window.setInterval(_check2,($RC.settings.onCreateFrameUseThisBaseTimer));};$RC.displayDetected=function(_detected)162{switch(true)163{case(!_detected.site):case(!_detected.data):case(!$RC.sites[_detected.site.id]):$RC.detected=false;return;}164$RC.detected=_detected;$RC.$iframeDocument.find('#siteCSS').remove();$RC.$iframeDocument.find('head').append(''+'<link id="siteCSS" href="'+165$RC.escape_html($RC.settings.cssPath)+'site__'+$RC.escape_html($RC.detected.site.id)+'.css'+'" rel="stylesheet" type="text/css" />'+'');var _composer=$RC.sites[$RC.detected.site.id].composer;$RC.composed=_composer($RC.detected.data,$RC.composer__loop,$RC.composer__div,$RC.composer__raw,$RC.composer__n2b,$RC.composer__esc,$RC.composer__br,$RC.composer__hr);for(var _section in $RC.composed){if($RC.composed[_section]){}else{delete $RC.composed[_section];}}166var _sections_unchecked=(function(){var _r={},_a=$RC.sites[$RC.detected.site.id].sections_unchecked;for(var _i=0,_ii=_a.length;_i<_ii;_i++){_r[_a[_i]]=true;}167return _r;})();var _html='';$RC.loopThroughSections(function(_section,_index)168{_html+=''+'<div id="display__section__'+_section+'" class="section section__'+_section+' '+(_sections_unchecked[_section]?'unchecked':'checked')+'">'+169(_index?('<div class="checkbox" id="display__section__'+_section+'__checkbox"></div>'):'')+'<div class="section_content" id="display__section__'+_section+'__content">'+170$RC.composer__br(_index)+171$RC.composed[_section]+172$RC.composer__br()+'</div>'+'</div>'+173$RC.composer__hr()+'';});_html=_html.substr(0,(_html.length-$RC.composer__hr().length));$RC.$iframeContentToDisplay.html(_html);$RC.onlyCheckedSections();$RC.$iframeContentToDisplay.find('div.checkbox').click(function()174{var _$section=$(this.parentNode);switch(true)175{case(_$section.hasClass('unchecked')):_$section.removeClass('unchecked').addClass('checked');break;case(_$section.hasClass('checked')):_$section.removeClass('checked').addClass('unchecked');break;}176$RC.onlyCheckedSections();});};$RC.loopThroughSections=function(_callback)177{if($RC.detected){}else{return;}178if($RC.composed){}else{return;}179for(var _section=false,_i=0,_ii=$RC.sites[$RC.detected.site.id].sections_order.length;_i<_ii;_i++)180{_section=$RC.sites[$RC.detected.site.id].sections_order[_i];if($RC.composed[_section]){}else{continue;}181_callback(_section,((_i===0)?0:((_i==_ii)?-1:_i)));}};$RC.onlyCheckedSections=function()182{$RC.checkedSections=[];$RC.uncheckedSections=[];var _htmlToSave='';$RC.loopThroughSections(function(_section)183{var _$section=$RC.$iframeDocument.find('#display__section__'+_section),_$checkbox=$RC.$iframeDocument.find('#display__section__'+_section+'__checkbox'),_$content=$RC.$iframeDocument.find('#display__section__'+_section+'__content');if(_$section.hasClass('checked'))184{$RC.checkedSections.push(_section);_htmlToSave+=''+185_$content.html()+186$RC.composer__hr()+'';}187else188{$RC.uncheckedSections.push(_section);}});_htmlToSave=_htmlToSave.substr(0,(_htmlToSave.length-$RC.composer__hr().length));$RC.$iframeContentToSave.html(_htmlToSave);};$RC.getUncheckedSections=function()189{return $RC.uncheckedSections;};$RC.getCheckedSections=function()190{return $RC.checkedSections;};$RC.setUncheckedSections=function(_site_id,_unchecked_sections)191{if($RC.sites[_site_id]){}else{return;}192$RC.sites[_site_id].sections_unchecked=_unchecked_sections;};$RC.getContentToSaveNode=function()193{return $RC.$iframeContentToSave.get(0);};$RC.getContentToSaveHTML=function()194{var _node=$RC.getContentToSaveNode();if(_node){}else{return false;}195if(_node.innerHTML){}else{return false;}...
index.test.js
Source:index.test.js
1const SlateConfig = require('@shopify/slate-config');2jest.mock('../slate-rc.schema');3const MOCK_VALID_SLATE_RC = {4 uuid: '9a983jf94jk42',5};6beforeEach(() => jest.resetModules());7afterEach(() => require('mock-fs').restore());8describe('get()', () => {9 describe('if .slaterc exists in the `~/` directory', () => {10 test('returns its parsed JSON contents', () => {11 const slateRc = require('../index');12 const mock = require('mock-fs');13 const config = new SlateConfig(require('../slate-rc.schema'));14 mock({15 [config.get('paths.slateRc')]: JSON.stringify(MOCK_VALID_SLATE_RC),16 });17 expect(slateRc.get()).toMatchObject(MOCK_VALID_SLATE_RC);18 });19 test('throws an error if the JSON file is invalid', () => {20 const slateRc = require('../index');21 const SlateRcError = require('../slate-rc-error');22 const config = new SlateConfig(require('../slate-rc.schema'));23 const mock = require('mock-fs');24 mock({[config.get('paths.slateRc')]: 'some invalid JSON'});25 expect(() => {26 slateRc.get();27 }).toThrowError(SlateRcError);28 });29 test('returns null if file is empty', () => {30 const slateRc = require('../index');31 const config = new SlateConfig(require('../slate-rc.schema'));32 const mock = require('mock-fs');33 mock({[config.get('paths.slateRc')]: ''});34 expect(slateRc.get()).toBe(null);35 });36 });37 describe('if a .slaterc file does not exist in the `~/` ', () => {38 test('returns null', () => {39 const slateRc = require('../index');40 const results = slateRc.get();41 expect(results).toBe(null);42 });43 });44});45describe('generate()', () => {46 test('creates a .slaterc file in the `~/` directory and returns its contents', () => {47 const slateRc = require('../index');48 const config = new SlateConfig(require('../slate-rc.schema'));49 const mock = require('mock-fs');50 const fs = require('fs');51 mock();52 const content = slateRc.generate();53 expect(fs.existsSync(config.get('paths.slateRc'))).toBeTruthy();54 expect(content.uuid).toBeDefined();55 });56 describe('throws an error if', () => {57 test('.slaterc file already exists', () => {58 const slateRc = require('../index');59 const SlateRcError = require('../slate-rc-error');60 const mock = require('mock-fs');61 mock();62 slateRc.generate();63 expect(() => {64 slateRc.generate();65 }).toThrowError(SlateRcError);66 });67 });68});69describe('update()', () => {70 test('applies any changes to the .slaterc file', () => {71 const rc = require('../index');72 const mock = require('mock-fs');73 const config = new SlateConfig(require('../slate-rc.schema'));74 mock({[config.get('paths.slateRc')]: JSON.stringify(MOCK_VALID_SLATE_RC)});75 rc.update({someChange: 'value'});76 expect(rc.get().someChange).toBeDefined();77 });...
Using AI Code Generation
1var mb = require('mountebank');2var imposter = {3 {4 {5 is: {6 }7 }8 }9};10mb.create(imposter)11 .then(function (server) {12 console.log('imposter created at %s', server.url);13 })14 .catch(function (error) {15 console.log('failed to create imposter: %s', error.message);16 });17{18 {19 {20 "is": {21 }22 }23 }24}25{26 "requests": {27 "byVerb": {28 },29 "byPath": {30 },31 "byStatusCode": {32 }33 },34 "stubs": {35 "byPredicate": {
Using AI Code Generation
1var mb = require('mountebank');2var imposter = {3 stubs: [{4 responses: [{5 is: {6 headers: {7 },8 body: {9 { "name": "Ford", "models": ["Fiesta", "Focus", "Mustang"] },10 { "name": "BMW", "models": ["320", "X3", "X5"] },11 { "name": "Fiat", "models": ["500", "Panda"] }12 }13 }14 }]15 }]16};17mb.create(imposter).then(function (result) {18 console.log(result);19});20var mb = require('mountebank');21var imposter = {22 stubs: [{23 responses: [{24 is: {25 headers: {26 },27 body: {28 { "name": "Ford", "models": ["Fiesta", "Focus", "Mustang"] },29 { "name": "BMW", "models": ["320", "X3", "X5"] },30 { "name": "Fiat", "models": ["500", "Panda"] }31 }32 }33 }]34 }]35};36mb.create(imposter).then(function (result) {37 console.log(result);38});39var mb = require('mountebank');40var imposter = {41 stubs: [{42 responses: [{43 is: {44 headers: {45 },46 body: {47 { "name": "Ford", "models": ["Fiesta", "Focus", "Mustang"] },
Using AI Code Generation
1var mb = require('mountebank');2mb.create({port: 2525, pidfile: 'mb.pid', logfile: 'mb.log', protofile: 'mb.proto'}, function (error, mb) {3 if (error) {4 console.error('Failed to start mountebank', error);5 } else {6 console.log('Mountebank started on port', mb.port);7 }8});9var mb = require('mountebank');10mb.start({port: 2525, pidfile: 'mb.pid', logfile: 'mb.log', protofile: 'mb.proto'}, function (error) {11 if (error) {12 console.error('Failed to start mountebank', error);13 } else {14 console.log('Mountebank started on port', mb.port);15 }16});17mb.start({port: 2525, pidfile: 'mb.pid', logfile: 'mb.log', protofile: 'mb.proto'}, function (error) {18 if (error) {19 console.error('Failed to start mountebank', error);20 } else {21 console.log('Mountebank started on port', mb.port);22 }23});24mb.start({port: 2525, pidfile: 'mb.pid', logfile: 'mb.log', protofile: 'mb.proto'}, function (error) {25 if (error) {26 console.error('Failed to start mountebank', error);27 } else {28 console.log('Mountebank started on port', mb.port);29 }30});31mb.start({port: 2525, pidfile: 'mb.pid', logfile: 'mb.log', protofile: 'mb.proto'}, function (error) {32 if (error) {33 console.error('Failed to start mountebank', error);34 } else {35 console.log('Mountebank started on port', mb.port);36 }37});38mb.start({port: 2525, pidfile: 'mb.pid', logfile: 'mb.log', protofile: 'mb.proto'}, function (error) {39 if (error) {40 console.error('Failed to start mountebank', error);
Using AI Code Generation
1const mb = require('mountebank');2const imposterPort = 4545;3 {4 {5 {6 is: {7 headers: {8 },9 body: { "status": "success" }10 }11 }12 }13 }14];15mb.create({ imposters: imposters });
Using AI Code Generation
1var mb = require('mountebank');2var fs = require('fs');3var imposter = JSON.parse(fs.readFileSync('imposter.json', 'utf8'));4mb.create(imposter, 2525, function () {5 console.log('imposter created');6});7{8 {9 {10 "is": {11 "headers": {12 },13 }14 }15 }16}
Using AI Code Generation
1var mountebank = require('mountebank-cli');2mountebank.start({port: 2525, pidfile: 'mb.pid', logfile: 'mb.log', ipWhitelist: ['*']}, function () {3 console.log("Mountebank started");4 mountebank.createImposter(4545, {protocol: 'http', stubs: [5 {6 {7 is: {8 }9 }10 }11 ]}, function (imposter) {12 console.log(imposter);13 mountebank.getImposters(function (imposters) {14 console.log(imposters);15 mountebank.deleteImposter(4545, function () {16 console.log("Imposter deleted");17 mountebank.stop(function () {18 console.log("Mountebank stopped");19 });20 });21 });22 });23});
Using AI Code Generation
1var mb = require('mountebank');2var port = 2525;3var protocol = "http";4var host = "localhost";5var path = "/imposters";6var rc = new mb.RC(port, protocol, host, path);7var options = {8 stubs: [{9 predicates: [{10 equals: {11 }12 }],13 responses: [{14 is: {15 headers: {16 },17 }18 }]19 }]20};21rc.create(options, function (err, result) {22 if (err) {23 console.log(err);24 }25 else {26 console.log(result);27 }28});29{ port: 2525,30 stubs: [ { predicates: [Object], responses: [Object] } ],31 _links: { self: { href: '/imposters/2525' } } }
Using AI Code Generation
1var rc = require('mountebank').create({2});3var stub = {4 predicates: [{5 equals: {6 headers: {7 }8 }9 }],10 responses: [{11 is: {12 headers: {13 },14 body: {15 }16 }17 }]18};19rc.post('/imposters', stub, function (error, response) {20 if (error) {21 console.error('Error creating stub: ', error);22 } else {23 console.log('Stub created: ', response);24 }25});26var rc = require('mountebank').create({27});28var stub = {29 predicates: [{30 equals: {31 headers: {32 }33 }34 }],35 responses: [{36 is: {37 headers: {38 },39 body: {40 }41 }42 }]43};44rc.post('/imposters', stub, function (error, response) {45 if (error) {46 console.error('Error creating stub: ', error);47 } else {48 console.log('Stub created: ', response);49 }50});51{
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!