How to use proc method in mountebank

Best JavaScript code snippet using mountebank

ScrollManager.js

Source:ScrollManager.js Github

copy

Full Screen

1/**2 * Provides automatic scrolling of overflow regions in the page during drag operations.3 *4 * The ScrollManager configs will be used as the defaults for any scroll container registered with it, but you can also5 * override most of the configs per scroll container by adding a ddScrollConfig object to the target element that6 * contains these properties: {@link #hthresh}, {@link #vthresh}, {@link #increment} and {@link #frequency}. Example7 * usage:8 *9 * var el = Ext.get('scroll-ct');10 * el.ddScrollConfig = {11 * vthresh: 50,12 * hthresh: -1,13 * frequency: 100,14 * increment: 20015 * };16 * Ext.dd.ScrollManager.register(el);17 *18 * Note: This class is designed to be used in "Point Mode19 */20Ext.define('Ext.dd.ScrollManager', {21 singleton: true,22 requires: [23 'Ext.dd.DragDropManager'24 ],25 constructor: function() {26 var ddm = Ext.dd.DragDropManager;27 ddm.fireEvents = Ext.Function.createSequence(ddm.fireEvents, this.onFire, this);28 ddm.stopDrag = Ext.Function.createSequence(ddm.stopDrag, this.onStop, this);29 this.doScroll = Ext.Function.bind(this.doScroll, this);30 this.ddmInstance = ddm;31 this.els = {};32 this.dragEl = null;33 this.proc = {};34 },35 onStop: function(e){36 var sm = Ext.dd.ScrollManager;37 sm.dragEl = null;38 sm.clearProc();39 },40 triggerRefresh: function() {41 if (this.ddmInstance.dragCurrent) {42 this.ddmInstance.refreshCache(this.ddmInstance.dragCurrent.groups);43 }44 },45 doScroll: function() {46 if (this.ddmInstance.dragCurrent) {47 var proc = this.proc,48 procEl = proc.el,49 ddScrollConfig = proc.el.ddScrollConfig,50 inc = ddScrollConfig ? ddScrollConfig.increment : this.increment;51 if (!this.animate) {52 if (procEl.scroll(proc.dir, inc)) {53 this.triggerRefresh();54 }55 } else {56 procEl.scroll(proc.dir, inc, true, this.animDuration, this.triggerRefresh);57 }58 }59 },60 clearProc: function() {61 var proc = this.proc;62 if (proc.id) {63 clearInterval(proc.id);64 }65 proc.id = 0;66 proc.el = null;67 proc.dir = "";68 },69 startProc: function(el, dir) {70 this.clearProc();71 this.proc.el = el;72 this.proc.dir = dir;73 var group = el.ddScrollConfig ? el.ddScrollConfig.ddGroup : undefined,74 freq = (el.ddScrollConfig && el.ddScrollConfig.frequency)75 ? el.ddScrollConfig.frequency76 : this.frequency;77 if (group === undefined || this.ddmInstance.dragCurrent.ddGroup == group) {78 this.proc.id = setInterval(this.doScroll, freq);79 }80 },81 onFire: function(e, isDrop) {82 if (isDrop || !this.ddmInstance.dragCurrent) {83 return;84 }85 if (!this.dragEl || this.dragEl != this.ddmInstance.dragCurrent) {86 this.dragEl = this.ddmInstance.dragCurrent;87 // refresh regions on drag start88 this.refreshCache();89 }90 var xy = e.getXY(),91 pt = e.getPoint(),92 proc = this.proc,93 els = this.els,94 id, el, r, c;95 for (id in els) {96 el = els[id];97 r = el._region;98 c = el.ddScrollConfig ? el.ddScrollConfig : this;99 if (r && r.contains(pt) && el.isScrollable()) {100 if (r.bottom - pt.y <= c.vthresh) {101 if(proc.el != el){102 this.startProc(el, "down");103 }104 return;105 }else if (r.right - pt.x <= c.hthresh) {106 if (proc.el != el) {107 this.startProc(el, "left");108 }109 return;110 } else if(pt.y - r.top <= c.vthresh) {111 if (proc.el != el) {112 this.startProc(el, "up");113 }114 return;115 } else if(pt.x - r.left <= c.hthresh) {116 if (proc.el != el) {117 this.startProc(el, "right");118 }119 return;120 }121 }122 }123 this.clearProc();124 },125 /**126 * Registers new overflow element(s) to auto scroll127 * @param {String/HTMLElement/Ext.Element/String[]/HTMLElement[]/Ext.Element[]} el128 * The id of or the element to be scrolled or an array of either129 */130 register : function(el){131 if (Ext.isArray(el)) {132 for(var i = 0, len = el.length; i < len; i++) {133 this.register(el[i]);134 }135 } else {136 el = Ext.get(el);137 this.els[el.id] = el;138 }139 },140 /**141 * Unregisters overflow element(s) so they are no longer scrolled142 * @param {String/HTMLElement/Ext.Element/String[]/HTMLElement[]/Ext.Element[]} el143 * The id of or the element to be removed or an array of either144 */145 unregister : function(el){146 if(Ext.isArray(el)){147 for (var i = 0, len = el.length; i < len; i++) {148 this.unregister(el[i]);149 }150 }else{151 el = Ext.get(el);152 delete this.els[el.id];153 }154 },155 /**156 * The number of pixels from the top or bottom edge of a container the pointer needs to be to trigger scrolling157 */158 vthresh : 25,159 /**160 * The number of pixels from the right or left edge of a container the pointer needs to be to trigger scrolling161 */162 hthresh : 25,163 /**164 * The number of pixels to scroll in each scroll increment165 */166 increment : 100,167 /**168 * The frequency of scrolls in milliseconds169 */170 frequency : 500,171 /**172 * True to animate the scroll173 */174 animate: true,175 /**176 * The animation duration in seconds - MUST BE less than Ext.dd.ScrollManager.frequency!177 */178 animDuration: 0.4,179 /**180 * @property {String} ddGroup181 * The named drag drop {@link Ext.dd.DragSource#ddGroup group} to which this container belongs. If a ddGroup is182 * specified, then container scrolling will only occur when a dragged object is in the same ddGroup.183 */184 ddGroup: undefined,185 /**186 * Manually trigger a cache refresh.187 */188 refreshCache : function(){189 var els = this.els,190 id;191 for (id in els) {192 if(typeof els[id] == 'object'){ // for people extending the object prototype193 els[id]._region = els[id].getRegion();194 }195 }196 }...

Full Screen

Full Screen

procedureModel.js

Source:procedureModel.js Github

copy

Full Screen

1const db = require("../config/db");2// Contraindications DB table class3class Procedure {4 constructor(5 proc_id,6 proc_title_et,7 proc_title_ru,8 proc_title_en,9 proc_descr_et,10 proc_descr_ru,11 proc_descr_en,12 proc_duration,13 proc_price14 ) {15 this.proc_id = proc_id;16 this.proc_title_et = proc_title_et;17 this.proc_title_ru = proc_title_ru;18 this.proc_title_en = proc_title_en;19 this.proc_descr_et = proc_descr_et;20 this.proc_descr_ru = proc_descr_ru;21 this.proc_descr_en = proc_descr_en;22 this.proc_duration = proc_duration;23 this.proc_price = proc_price;24 }25 /**26 * MySQL statements for Procedures Controller methods27 */28 // Procedures on Any Filters29 // // Procedures on Targets and Symptoms30 // static getAllProcOnTarAndSymp() {31 // let sql = `SELECT procedures.proc_title_et, procedures.proc_descr_et, procedures.proc_duration, procedures.proc_price FROM procedures32 // INNER JOIN procedures_targets INNER JOIN targets INNER JOIN procedures_symptoms INNER JOIN symptoms33 // ON procedures.proc_id=procedures_targets.procedures_id AND procedures_targets.targets_id=targets.tar_id34 // AND procedures.proc_id=procedures_symptoms.procedures_id AND procedures_symptoms.symptoms_id=symptoms.symp_id35 // WHERE targets.tar_id IN (${tarIdsString}) AND symptoms.symp_id IN (${sympIdsString}) ORDER BY procedures.proc_price;`;36 // return db.execute(sql);37 // }38 // Procedures On All Filters dynamically, if exists39 static async getAllProcOnTarAndSymp(tarIds, sympIds, disIds, priceMax) {40 let join = [];41 let where = [];42 let namedPlaceholders = {};43 if (tarIds) {44 join.push(45 `procedures_targets USING (proc_id) JOIN targets USING (tar_id)`46 );47 where.push(`tar_id IN (:clientsTargets)`);48 namedPlaceholders.clientsTargets = tarIds.toString();49 }50 if (sympIds) {51 join.push(52 `procedures_symptoms USING (proc_id) JOIN symptoms USING (symp_id)`53 );54 where.push(`symp_id IN (:clientsSymptoms)`); // placeholder55 namedPlaceholders.clientsSymptoms = sympIds.toString();56 }57 if (disIds) {58 join.push(59 `procedures_diseases USING (proc_id) JOIN diseases USING (dis_id)`60 );61 where.push(`dis_id IN (:clientsDiseases)`);62 namedPlaceholders.clientsDiseases = disIds.toString();63 }64 if (priceMax) {65 where.push(`proc_price <= :clientsPrice`);66 namedPlaceholders.clientsPrice = Number(priceMax);67 }68 function implodeData(type, data, separator = " ") {69 data = data.join(" " + separator + " ");70 if (data.length) {71 data = type + " " + data;72 }73 return data;74 }75 join = implodeData("JOIN", join, "JOIN");76 where = implodeData("WHERE", where, "AND");77 const [rows] = await db.execute(78 `SELECT procedures.proc_title_et, procedures.proc_descr_et, procedures.proc_duration, procedures.proc_price 79 FROM procedures ${join} ${where} ORDER BY proc_price;`,80 namedPlaceholders81 );82 console.log(rows);83 return rows;84 }85 /** ------------------------------------------------------------------86 * ADMINS-PANEL MySQL statements for Procedures Controller methods87 */88 // Create new89 // async saveNewProcedure() {90 // let sql = `INSERT INTO procedures(proc_title_et,proc_title_ru,proc_title_en,proc_descr_et,proc_descr_ru,proc_descr_en,proc_duration,proc_price)91 // VALUES('${this.proc_title_et}','${this.proc_title_ru}','${this.proc_title_en}','${this.proc_descr_et}','${this.proc_descr_ru}','${this.proc_descr_en}','${this.proc_duration}','${this.proc_price}')`;92 // const [newProcedure, _] = await db.execute(sql);93 // return newProcedure;94 // }95 // // Find all procedures96 // static findAll() {97 // let sql = "SELECT * FROM procedures;";98 // return db.execute(sql);99 // }100 // // Find by ID101 // static findById(proc_id) {102 // let sql = `SELECT * FROM procedures WHERE proc_id = ${proc_id};`;103 // return db.execute(sql);104 // }105 // static findByIdAndUpdate(proc_id) {106 // let sql = `UPDATE procedures SET proc_title_et = ${this.proc_title_et},107 // proc_title_ru = ${this.proc_title_ru}, proc_title_en = ${this.proc_title_en} WHERE proc_id = ${proc_id} ;`;108 // return db.execute(sql);109 // }110 // static deleteById(proc_id) {111 // let sql = `DELETE FROM procedures WHERE proc_id = ${proc_id};`;112 // return db.execute(sql);113 // }114 // static findByPrice() {115 // let sql = `SELECT proc_id, proc_price FROM procedures;`;116 // return db.execute(sql);117 // }118}...

Full Screen

Full Screen

Scheduler.js

Source:Scheduler.js Github

copy

Full Screen

1/*2import Elm.Kernel.Utils exposing (Tuple0)3*/4// TASKS5function _Scheduler_succeed(value)6{7 return {8 $: __1_SUCCEED,9 __value: value10 };11}12function _Scheduler_fail(error)13{14 return {15 $: __1_FAIL,16 __value: error17 };18}19function _Scheduler_binding(callback)20{21 return {22 $: __1_BINDING,23 __callback: callback,24 __kill: null25 };26}27var _Scheduler_andThen = F2(function(callback, task)28{29 return {30 $: __1_AND_THEN,31 __callback: callback,32 __task: task33 };34});35var _Scheduler_onError = F2(function(callback, task)36{37 return {38 $: __1_ON_ERROR,39 __callback: callback,40 __task: task41 };42});43function _Scheduler_receive(callback)44{45 return {46 $: __1_RECEIVE,47 __callback: callback48 };49}50// PROCESSES51var _Scheduler_guid = 0;52function _Scheduler_rawSpawn(task)53{54 var proc = {55 $: __2_PROCESS,56 __id: _Scheduler_guid++,57 __root: task,58 __stack: null,59 __mailbox: []60 };61 _Scheduler_enqueue(proc);62 return proc;63}64function _Scheduler_spawn(task)65{66 return _Scheduler_binding(function(callback) {67 callback(_Scheduler_succeed(_Scheduler_rawSpawn(task)));68 });69}70function _Scheduler_rawSend(proc, msg)71{72 proc.__mailbox.push(msg);73 _Scheduler_enqueue(proc);74}75var _Scheduler_send = F2(function(proc, msg)76{77 return _Scheduler_binding(function(callback) {78 _Scheduler_rawSend(proc, msg);79 callback(_Scheduler_succeed(__Utils_Tuple0));80 });81});82function _Scheduler_kill(proc)83{84 return _Scheduler_binding(function(callback) {85 var task = proc.__root;86 if (task.$ === __1_BINDING && task.__kill)87 {88 task.__kill();89 }90 proc.__root = null;91 callback(_Scheduler_succeed(__Utils_Tuple0));92 });93}94/* STEP PROCESSES95type alias Process =96 { $ : tag97 , id : unique_id98 , root : Task99 , stack : null | { $: SUCCEED | FAIL, a: callback, b: stack }100 , mailbox : [msg]101 }102*/103var _Scheduler_working = false;104var _Scheduler_queue = [];105function _Scheduler_enqueue(proc)106{107 _Scheduler_queue.push(proc);108 if (_Scheduler_working)109 {110 return;111 }112 _Scheduler_working = true;113 while (proc = _Scheduler_queue.shift())114 {115 _Scheduler_step(proc);116 }117 _Scheduler_working = false;118}119function _Scheduler_step(proc)120{121 while (proc.__root)122 {123 var rootTag = proc.__root.$;124 if (rootTag === __1_SUCCEED || rootTag === __1_FAIL)125 {126 while (proc.__stack && proc.__stack.$ !== rootTag)127 {128 proc.__stack = proc.__stack.__rest;129 }130 if (!proc.__stack)131 {132 return;133 }134 proc.__root = proc.__stack.__callback(proc.__root.__value);135 proc.__stack = proc.__stack.__rest;136 }137 else if (rootTag === __1_BINDING)138 {139 proc.__root.__kill = proc.__root.__callback(function(newRoot) {140 proc.__root = newRoot;141 _Scheduler_enqueue(proc);142 });143 return;144 }145 else if (rootTag === __1_RECEIVE)146 {147 if (proc.__mailbox.length === 0)148 {149 return;150 }151 proc.__root = proc.__root.__callback(proc.__mailbox.shift());152 }153 else // if (rootTag === __1_AND_THEN || rootTag === __1_ON_ERROR)154 {155 proc.__stack = {156 $: rootTag === __1_AND_THEN ? __1_SUCCEED : __1_FAIL,157 __callback: proc.__root.__callback,158 __rest: proc.__stack159 };160 proc.__root = proc.__root.__task;161 }162 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var imposter = {3 {4 {5 is: {6 headers: {7 },8 body: JSON.stringify({})9 }10 }11 }12};13mb.create(imposter).then(function () {14 console.log("Imposter created");15});16{ [Error: connect ECONNREFUSED

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var imposter = {3 {4 {5 "is": {6 "headers": {7 },8 }9 }10 }11};12mb.create(imposter).then(function (response) {13 console.log(response);14}).catch(function (error) {15 console.error(error);16});17var mb = require('mountebank');18mb.create({19 {20 {21 "is": {22 "headers": {23 },24 }25 }26 }27}).then(function (response) {28 console.log(response);29}).catch(function (error) {30 console.error(error);31});32var mb = require('mountebank');33mb.create({34 {35 {36 "is": {37 "headers": {38 },39 }40 }41 }42}, function (error, response) {43 if (error) {44 console.error(error);45 } else {46 console.log(response);47 }48});49var mb = require('mountebank');50mb.create({51 {52 {53 "is": {54 "headers": {55 },56 }57 }58 }59}).then(function (response)

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var port = 2525;3var imposter = {4 stubs: [{5 responses: [{6 is: {7 }8 }]9 }]10};11mb.create(imposter).then(function () {12 console.log('Imposter created');13 return mb.get('/imposters', port);14}).then(function (response) {15 console.log('Imposter retrieved');16 return mb.del('/imposters', port);17}).then(function () {18 console.log('Imposter deleted');19});20var http = require('http');21var port = 2525;22var imposter = {23 stubs: [{24 responses: [{25 is: {26 }27 }]28 }]29};30var options = {31 headers: {32 }33};34var request = http.request(options, function (response) {35 console.log('Imposter created');36 options.method = 'GET';37 request = http.request(options, function (response) {38 console.log('Imposter retrieved');39 options.method = 'DELETE';40 request = http.request(options, function (response) {41 console.log('Imposter deleted');42 });43 request.write(JSON.stringify(imposter));44 request.end();45 });46 request.write(JSON.stringify(imposter));47 request.end();48});49request.write(JSON.stringify(imposter));50request.end();51import java.io.IOException;52import java.net.HttpURLConnection;53import java.net.URL;54import java.util.Scanner;55public class mb {56 public static void main(String[] args) throws IOException {57 int port = 2525;58 String imposter = "{ \"port\": " + port + ", \"

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var fs = require('fs');3var path = require('path');4var imposter = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'imposter.json'), 'utf8'));5mb.create(imposter, 2525).then(function (server) {6 console.log('Imposter running at %s', server.url);7 console.log('Press CTRL+C to quit');8});9{10 {11 {12 "is": {13 "headers": {14 },15 "body": {16 }17 }18 }19 }20}21{"status":"success","message":"Hello World"}22{"errors":[]}

Full Screen

Using AI Code Generation

copy

Full Screen

1var imposters = {2 "stubs": [{3 "responses": [{4 "is": {5 }6 }]7 }]8};9var options = {10};11request(options, function (error, response, body) {12 console.log(body);13});14var imposters = {15 "stubs": [{16 "responses": [{17 "is": {18 }19 }]20 }]21};22var options = {23};24request(options).then(function (response) {25 console.log(response.body);26});27var imposters = {28 "stubs": [{29 "responses": [{30 "is": {31 }32 }]33 }]34};35var options = {36};37request(options, function (error, response, body) {38 console.log(body);39});40var imposters = {41 "stubs": [{42 "responses": [{43 "is": {44 }45 }]46 }]47};48var options = {49};50request(options).then(function (response) {51 console.log(response.body);52});53var imposters = {54 "stubs": [{55 "responses": [{56 "is": {57 }58 }]59 }]60};

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var imposter = {3 {4 {5 equals: {6 }7 }8 {9 is: {10 headers: {11 },12 body: JSON.stringify({ test: 'test' })13 }14 }15 }16};17mb.create(imposter)18 .then(function (imposter) {19 console.log("Imposter created: " + imposter.port);20 })21 .catch(function (error) {22 console.error("Error creating imposter: " + error.message);23 });24mb.delete(2525)25 .then(function (imposter) {26 console.log("Imposter deleted: " + imposter.port);27 })28 .catch(function (error) {29 console.error("Error deleting imposter: " + error.message);30 });31mb.deleteAll()32 .then(function (imposters) {33 console.log("Imposters deleted: " + imposters.length);34 })35 .catch(function (error) {36 console.error("Error deleting imposters: " + error.message);37 });38mb.get()39 .then(function (imposters) {40 console.log("Imposters found: " + imposters.length);41 })42 .catch(function (error) {43 console.error("Error finding imposters: " + error.message);44 });45mb.get(2525)46 .then(function (imposter) {47 console.log("Imposter found: " + imposter.port

Full Screen

Using AI Code Generation

copy

Full Screen

1const { spawn } = require('child_process');2const mb = spawn('mb', ['--configfile', 'config.json', '--allowInjection', '--loglevel', 'debug']);3mb.stdout.on('data', (data) => {4 console.log(`stdout: ${data}`);5});6mb.stderr.on('data', (data) => {7 console.log(`stderr: ${data}`);8});9mb.on('close', (code) => {10 console.log(`child process exited with code ${code}`);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 mountebank 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