How to use optionsFor method in mountebank

Best JavaScript code snippet using mountebank

syntax.test.js

Source:syntax.test.js Github

copy

Full Screen

...42 expect(parseBlock("when gf clicked").info).toMatchObject(flag)43 })44 test("when flag clicked: de", () => {45 expect(46 parseBlock("Wenn die grüne Flagge angeklickt", optionsFor("de")).info,47 ).toMatchObject(flag)48 expect(49 parseBlock("Wenn ⚑ angeklickt wird", optionsFor("de")).info,50 ).toMatchObject(flag)51 expect(52 parseBlock("Wenn @greenFlag angeklickt wird", optionsFor("de")).info,53 ).toMatchObject(flag)54 })55 test("when flag clicked: ja", () => {56 expect(parseBlock("⚑ が押されたとき", optionsFor("ja")).info).toMatchObject(57 flag,58 )59 })60 const turnLeft = {61 selector: "turnLeft:",62 shape: "stack",63 category: "motion",64 }65 test("turn left", () => {66 expect(parseBlock("turn ccw (15) degrees").info).toMatchObject(turnLeft)67 expect(parseBlock("turn left (15) degrees").info).toMatchObject(turnLeft)68 expect(parseBlock("turn @turnLeft (15) degrees").info).toMatchObject(69 turnLeft,70 )71 })72 test("turn left: de", () => {73 expect(74 parseBlock("drehe dich nach links um (15) Grad", optionsFor("de")).info,75 ).toMatchObject(turnLeft)76 expect(77 parseBlock("drehe dich ↺ um (15) Grad", optionsFor("de")).info,78 ).toMatchObject(turnLeft)79 expect(80 parseBlock("drehe dich @turnLeft um (15) Grad", optionsFor("de")).info,81 ).toMatchObject(turnLeft)82 })83 const turnRight = {84 selector: "turnRight:",85 shape: "stack",86 category: "motion",87 }88 test("turn right", () => {89 expect(parseBlock("turn cw (15) degrees").info).toMatchObject(turnRight)90 expect(parseBlock("turn right (15) degrees").info).toMatchObject(turnRight)91 expect(parseBlock("turn @turnRight (15) degrees").info).toMatchObject(92 turnRight,93 )94 })95 test("turn right: de", () => {96 expect(97 parseBlock("drehe dich nach rechts um (15) Grad", optionsFor("de")).info,98 ).toMatchObject(turnRight)99 expect(100 parseBlock("drehe dich ↻ um (15) Grad", optionsFor("de")).info,101 ).toMatchObject(turnRight)102 expect(103 parseBlock("drehe dich @turnRight um (15) Grad", optionsFor("de")).info,104 ).toMatchObject(turnRight)105 })106})107describe("literals", () => {108 test("can be parsed", () => {109 const b = parseBlock("say [Hello!] for (2) secs")110 expect(b.children[1].isInput).toBe(true)111 expect(b.children[3].isInput).toBe(true)112 })113 // test('numbers can be scientific', () => {114 // testBlock('change [foo v] by (2e-50)', ['changeVar:by:', 'foo', 2e-50])115 // })116 test("variables are not numbers", () => {117 const b = parseBlock("say [Hello!] for (foo) secs")118 expect(b.children[3].info).toMatchObject({119 category: "variables",120 })121 })122 test("strings can be backslash-escaped", () => {123 const b = parseBlock("say [hello \\] world]")124 expect(b.children[1].isInput).toBe(true)125 expect(b.children[1].value).toBe("hello ] world")126 })127 test("labels can contain backslashes", () => {128 const code = "foo \\]"129 expect(parseBlock(code).stringify()).toBe(code)130 // var code = 'foo ]' // TODO don't escape lone slashes131 // expect(parseBlock(code).stringify()).toBe(code)132 })133})134describe("escaping and stringifying", () => {135 test("closing bracket", () => {136 const code = String.raw`say [\]]`137 expect(parseBlock(code).stringify()).toBe(code)138 })139 test("backslash", () => {140 const code = String.raw`say [\\]`141 expect(parseBlock(code).stringify()).toBe(code)142 })143 test("dropdown v should be escaped", () => {144 const code = String.raw`say [ \v]`145 expect(parseBlock(code).stringify()).toBe(code)146 })147 test("non-dropdown v should not be escaped", () => {148 const code = String.raw`say [v]`149 expect(parseBlock(code).stringify()).toBe(code)150 })151 test("backslash and v", () => {152 const code = String.raw`say [ \\v]`153 expect(parseBlock(code).stringify()).toBe(code)154 })155 test("multiple escapes", () => {156 const code = String.raw`say [\\\] \v]`157 expect(parseBlock(code).stringify()).toBe(code)158 })159 test("unnecessary escapes should be removed", () => {160 const input = String.raw`say [\[\)\v]`161 const expected = String.raw`say [[)v]`162 expect(parseBlock(input).stringify()).toBe(expected)163 })164})165describe("color literals", () => {166 test("work", () => {167 const b = parseBlock("<touching color [#f0f] ?>")168 expect(b.children[2].shape).toBe("color")169 expect(b.children[2].value).toBe("#f0f")170 })171 test("can be round", () => {172 const b = parseBlock("<touching color (#f0f) ?>")173 expect(b.children[2].shape).toBe("color")174 expect(b.children[2].value).toBe("#f0f")175 })176})177describe("recognise lists", () => {178 const variable = {179 category: "variables",180 selector: "readVariable",181 }182 test("not a list", () => {183 const b = parseBlock("say (list)")184 expect(b.children[1].info).toMatchObject(variable)185 })186 const list = {187 category: "list",188 selector: "contentsOfList:",189 }190 test("from add command", () => {191 const s = parseScript("say (list)\nadd [x] to [list v]")192 const b = s.blocks[0]193 expect(b.children[1].info).toMatchObject(list)194 })195 test("from insert command", () => {196 const s = parseScript("say (list)\ninsert [x] at (99 v) of [list v]")197 const b = s.blocks[0]198 expect(b.children[1].info).toMatchObject(list)199 })200 test("from show command", () => {201 const s = parseScript("say (list)\nshow list [list v]")202 const b = s.blocks[0]203 expect(b.children[1].info).toMatchObject(list)204 })205})206describe("disambiguation", () => {207 const stringLength = {208 category: "operators",209 selector: "stringLength:",210 }211 test("green: length of string", () => {212 expect(parseBlock("(length of [world])").info).toMatchObject(stringLength)213 expect(parseBlock("(length of (foo))").info).toMatchObject(stringLength)214 })215 const lineCount = {216 category: "list",217 selector: "lineCountOfList:",218 }219 test("orange: length of list", () => {220 expect(parseBlock("(length of [list v])").info).toMatchObject(lineCount)221 })222 const mathFunc = {223 category: "operators",224 selector: "computeFunction:of:",225 }226 test("green: math op", () => {227 expect(parseBlock("([sqrt v] of (9))").info).toMatchObject(mathFunc)228 expect(parseBlock("([sqrt v] of (foo))").info).toMatchObject(mathFunc)229 expect(parseBlock("([e ^ v] of (20))").info).toMatchObject(mathFunc)230 })231 const attributeOf = {232 category: "sensing",233 selector: "getAttribute:of:",234 }235 test("blue: attribute of", () => {236 expect(parseBlock("([x position v] of [Sprite1 v])").info).toMatchObject(237 attributeOf,238 )239 expect(parseBlock("([x position v] of (foo))").info).toMatchObject(240 attributeOf,241 )242 // invalid --not a math function243 expect(parseBlock("([e^ v] of (9)").info).toMatchObject(attributeOf)244 })245 const setGraphicEffect = {246 category: "looks",247 id: "LOOKS_SETEFFECTTO",248 }249 const changeGraphicEffect = {250 category: "looks",251 id: "LOOKS_CHANGEEFFECTBY",252 }253 test("looks: graphic effects", () => {254 expect(parseBlock("set [ghost v] effect to (100)").info).toMatchObject(255 setGraphicEffect,256 )257 expect(parseBlock("change [ghost v] effect by (5)").info).toMatchObject(258 changeGraphicEffect,259 )260 })261 test("looks: graphic effects: de", () => {262 expect(263 parseBlock("setze Effekt [Farbe v] auf (100)", optionsFor("de")).info,264 ).toMatchObject(setGraphicEffect)265 })266 const setSoundEffect = {267 category: "sound",268 id: "SOUND_SETEFFECTO",269 }270 const changeSoundEffect = {271 category: "sound",272 id: "SOUND_CHANGEEFFECTBY",273 }274 test("sound: sound effects", () => {275 expect(parseBlock("set [pitch v] effect to (100)").info).toMatchObject(276 setSoundEffect,277 )278 expect(279 parseBlock("set [pan left/right v] effect to (100)").info,280 ).toMatchObject(setSoundEffect)281 expect(parseBlock("change [pitch v] effect by (5)").info).toMatchObject(282 changeSoundEffect,283 )284 })285 test("sound: sound effects: de", () => {286 expect(287 parseBlock("setze Effekt [Höhe v] auf (100)", optionsFor("de")).info,288 ).toMatchObject(setSoundEffect)289 expect(290 parseBlock("setze Effekt [Hohe v] auf (100)", optionsFor("de")).info,291 ).toMatchObject(setSoundEffect)292 })293 const listContains = {294 category: "list",295 selector: "list:contains:",296 }297 test("red: list contains", () => {298 expect(parseBlock("<[list v] contains [f] ?>").info).toMatchObject(299 listContains,300 )301 })302 const stringContains = {303 category: "operators",304 id: "OPERATORS_CONTAINS",305 }306 test("green: string contains", () => {307 expect(parseBlock("<[foo] contains [f] ?>").info).toMatchObject(308 stringContains,309 )310 expect(parseBlock("<(foo) contains [f] ?>").info).toMatchObject(311 stringContains,312 )313 })314 // TODO test all disambiguations for other languages315 const stopCap = {316 shape: "cap",317 selector: "stopScripts",318 category: "control",319 }320 test("stop block cap", () => {321 expect(parseBlock("stop [all v]").info).toMatchObject(stopCap)322 })323 test("stop block cap: de", () => {324 expect(parseBlock("stoppe [alles v]", optionsFor("de")).info).toMatchObject(325 stopCap,326 )327 })328 test("stop block cap: ja", () => {329 expect(330 parseBlock("[すべてを止める v]", optionsFor("ja")).info,331 ).toMatchObject(stopCap)332 })333 const stopStack = {334 shape: "stack",335 selector: "stopScripts",336 }337 test("stop block stack", () => {338 expect(parseBlock("stop [other scripts in sprite v]").info).toMatchObject(339 stopStack,340 )341 })342 test("stop block stack: de", () => {343 expect(344 parseBlock("stoppe [andere Skripte der Figur v]", optionsFor("de")).info,345 ).toMatchObject(stopStack)346 })347 test("stop block stack: ja", () => {348 expect(349 parseBlock("[スプライトの他のスクリプトを止める v]", optionsFor("ja"))350 .info,351 ).toMatchObject(stopStack)352 })353 const looksSay = {354 shape: "stack",355 id: "LOOKS_SAY",356 }357 test("looks say", () => {358 expect(parseBlock("say [hello]").info).toMatchObject(looksSay)359 })360 test("looks say: de", () => {361 expect(parseBlock("sage [Hallo]", optionsFor("de")).info).toMatchObject(362 looksSay,363 )364 })365 test("looks say: ja", () => {366 expect(parseBlock("[Hello] と言う", optionsFor("ja")).info).toMatchObject(367 looksSay,368 )369 })370 const microbitWhen = {371 shape: "hat",372 id: "microbit.whenGesture",373 }374 test("microbit when", () => {375 expect(parseBlock("when [moved v]").info).toMatchObject(microbitWhen)376 })377 test("microbit when: de", () => {378 expect(parseBlock("Wenn [bewegt v]", optionsFor("de")).info).toMatchObject(379 microbitWhen,380 )381 })382 test("microbit when: ja", () => {383 expect(parseBlock("[動いた v]とき", optionsFor("ja")).info).toMatchObject(384 microbitWhen,385 )386 })387 const simpleRemapping = new Map([388 [389 {390 en: "when tilted [any v]",391 de: "Wenn [biliebig v] geneigt",392 ja: "[どれかの向き v]に傾いたとき",393 },394 {395 shape: "hat",396 id: "microbit.whenTilted",397 },398 ],399 [400 {401 en: "tilted [any v]?",402 de: "[biliebig v] geneigt?",403 ja: "[どれかの向き v]に傾いた",404 },405 {406 shape: "boolean",407 id: "microbit.isTilted",408 },409 ],410 [411 {412 en: "tilt angle [front v]",413 de: "Neigungswinkel [nach vorne v]",414 ja: "[前 v]方向の傾き",415 },416 {417 shape: "reporter",418 id: "microbit.tiltAngle",419 },420 ],421 [422 {423 en: "when [any v] key pressed",424 de: "Wenn Taste [biliebiges v] gedrückt wird",425 ja: "[どれかの v]キーが押されたとき",426 },427 {428 shape: "hat",429 id: "EVENT_WHENKEYPRESSED",430 },431 ],432 [433 {434 en: "motor [A v] position",435 de: "Position von Motor [A v]",436 ja: "モーター[A v]の位置",437 },438 {439 shape: "reporter",440 id: "ev3.getMotorPosition",441 },442 ],443 [444 {445 en: "distance",446 de: "Abstand",447 ja: "距離",448 },449 {450 shape: "reporter",451 id: "ev3.getDistance",452 },453 ],454 [455 {456 en: "set light color to (0)",457 de: "setze Lichtfarbe auf (0)",458 ja: "ライトの色を (0) にする",459 },460 {461 shape: "stack",462 id: "wedo2.setLightHue",463 },464 ],465 [466 {467 en: "button [1 v] pressed?",468 de: "Knopf [1 v] gedrückt?",469 ja: "ボタン [1 v]が押された",470 },471 {472 shape: "boolean",473 id: "ev3.buttonPressed",474 },475 ],476 [477 {478 en: "[A v] button pressed?",479 de: "Knopf [A v] gedrückt?",480 ja: "ボタン [A v]が押された",481 },482 {483 shape: "boolean",484 id: "microbit.isButtonPressed",485 },486 ],487 ])488 simpleRemapping.forEach((result, messages) => {489 test(result.id, () => {490 expect(parseBlock(messages.en).info).toMatchObject(result)491 })492 test(result.id + ": de", () => {493 expect(parseBlock(messages.de, optionsFor("de")).info).toMatchObject(494 result,495 )496 })497 test(result.id + ": ja", () => {498 expect(parseBlock(messages.ja, optionsFor("ja")).info).toMatchObject(499 result,500 )501 })502 })503})504describe("standalone blocks", () => {505 test("reporters may stand alone", () => {506 expect(parseBlock("(variable)").info.shape).toBe("reporter")507 expect(parseBlock("<loud?>").info.shape).toBe("boolean")508 })509 test("standalone inputs get put in stack block", () => {510 expect(parseBlock("[cheesecake]").info.shape).toBe("stack")511 expect(parseBlock("(3.12)").info.shape).toBe("stack")512 expect(parseBlock("(menu v)").info.shape).toBe("stack")513 expect(parseBlock("[dropdown v]").info.shape).toBe("stack")514 })515 test("stack blocks always stand alone", () => {516 expect(parseBlock("stamp").info.shape).toBe("stack")517 expect(parseBlock("say [hi]").info.shape).toBe("stack")518 expect(parseBlock("[thing] (123) (variable)").info.shape).toBe("stack")519 // expect(parseBlock('[attribute v] of [Stage v]').info.shape).toBe('stack') // oops v3 changed this520 })521})522describe("c blocks", () => {523 const ifBlock = {524 selector: "doIf",525 }526 test("if else", () => {527 // We used to give these different IDs for toJSON(); we no longer need to.528 expect(parseBlock("if <> then \n \nend").info).toMatchObject(ifBlock)529 expect(parseBlock("if <> then \n \nelse\nend").info).toMatchObject(ifBlock)530 })531 test("standalone else", () => {532 expect(parseBlock("else").info.shape).toBe("stack")533 expect(parseBlock("end").info.shape).toBe("stack")534 })535})536describe("comparison ops: < and > ", () => {537 test("ahahahaha", () => {538 expect(parseBlock("<[10]<(foo)>").info.selector).toBe("<")539 expect(parseBlock("<[10]<[11]>").info.selector).toBe("<")540 expect(parseBlock("<(foo)<(foo)>").info.selector).toBe("<")541 expect(parseBlock("<(foo)<[11]>").info.selector).toBe("<")542 expect(parseBlock("<[10]>(foo)>").info.selector).toBe(">")543 expect(parseBlock("<[10]>[11]>").info.selector).toBe(">")544 expect(parseBlock("<(foo)>(foo)>").info.selector).toBe(">")545 expect(parseBlock("<(foo)>[11]>").info.selector).toBe(">")546 expect(parseBlock("<<><<>>").info.selector).toBe("<")547 expect(parseBlock("<<>><>>").info.selector).toBe(">")548 })549 test("regression for #399", () => {550 expect(parseBlock("join (1) <(1)=(1)>").children.length).toBe(3)551 expect(552 parseBlock("go [forward v] <(1) = (1)> layers").children.length,553 ).toBe(4)554 })555})556// Test that blocks renamed between Scratch 2 and Scratch 3 work in either form.557describe("renamed blocks", () => {558 const say = {559 selector: "say:duration:elapsed:from:",560 }561 test("say for secs", () => {562 expect(parseBlock("say [Hello!] for (2) secs").info).toMatchObject(say)563 expect(parseBlock("say [Hello!] for (2) seconds").info).toMatchObject(say)564 })565 const think = {566 selector: "think:duration:elapsed:from:",567 }568 test("think for secs", () => {569 expect(parseBlock("think [Hmm...] for (2) secs").info).toMatchObject(think)570 expect(parseBlock("think [Hmm...] for (2) seconds").info).toMatchObject(571 think,572 )573 })574 const playSound = {575 selector: "playSound:",576 }577 test("play sound", () => {578 expect(parseBlock("play sound [moo v]").info).toMatchObject(playSound)579 expect(parseBlock("start sound [moo v]").info).toMatchObject(playSound)580 })581 const eraseAll = {582 selector: "clearPenTrails",583 }584 test("clear", () => {585 expect(parseBlock("clear").info).toMatchObject(eraseAll)586 expect(parseBlock("erase all").info).toMatchObject(eraseAll)587 })588 const wait = {589 selector: "wait:elapsed:from:",590 }591 test("wait secs", () => {592 expect(parseBlock("wait (1) secs").info).toMatchObject(wait)593 expect(parseBlock("wait (1) seconds").info).toMatchObject(wait)594 })595 const setTempo = {596 selector: "setTempoTo:",597 }598 test("set tempo", () => {599 expect(parseBlock("set tempo to (120) bpm").info).toMatchObject(setTempo)600 expect(parseBlock("set tempo to (120)").info).toMatchObject(setTempo)601 })602})603describe("translate", () => {604 test("reorders arguments: en -> de", () => {605 const b = parseBlock("go [back v] (1) layers")606 b.translate(allLanguages.de)607 expect(b.stringify()).toEqual("gehe (1) Ebenen [back v]")608 })609 test("reorders arguments: de -> en", () => {610 const b = parseBlock("gehe (1) Ebenen [back v]", optionsFor("de"))611 b.translate(allLanguages.en)612 expect(b.stringify()).toEqual("go [back v] (1) layers")613 })614 test("turn left: en -> de", () => {615 const b = parseBlock("turn cw (45) degrees")616 b.translate(allLanguages.de)617 expect(b.stringify()).toEqual("drehe dich nach rechts um (45) Grad")618 })619 test("turn left: de -> en", () => {620 const b = parseBlock(621 "drehe dich nach rechts um (45) Grad",622 optionsFor("de"),623 )624 b.translate(allLanguages.en)625 expect(b.stringify()).toEqual("turn cw (45) degrees")626 })627 test("c blocks", () => {628 const b = parseBlock("forever\nmove (10) steps\nend")629 b.translate(allLanguages.de)630 expect(b.stringify()).toEqual(631 "wiederhole fortlaufend \n gehe (10) er Schritt\nend",632 )633 })634 test("if else: en -> de", () => {635 const b = parseBlock("if <> then\n stamp\nelse\n clear\nend")636 b.translate(allLanguages.de)637 expect(b.stringify()).toEqual(638 "falls <> , dann \n hinterlasse Abdruck\nsonst \n lösche alles\nend",639 )640 })641 test("when flag clicked: en -> de", () => {642 const b = parseBlock("when flag clicked")643 b.translate(allLanguages.de)644 expect(b.stringify()).toEqual("Wenn die grüne Flagge angeklickt")645 })646 test("when flag clicked: en -> ja", () => {647 const b = parseBlock("when flag clicked")648 b.translate(allLanguages.ja)649 expect(b.stringify()).toEqual("緑の旗が押されたとき")650 })651 test("escapes brackets in labels: en -> ko", () => {652 const b = parseBlock("if <mouse down?> then")653 b.translate(allLanguages.ko)654 expect(b.stringify()).toEqual(655 "만약 <마우스를 클릭했는가?> \\(이\\)라면\nend",656 )657 })658 test("translates stop block: en -> ja", () => {659 const b = parseBlock("stop [all v]")660 b.translate(allLanguages.ja)661 // Note: currently we don't translate dropdown menu contents.662 expect(b.stringify()).toEqual("[all v]")663 })664 // TODO translate end665})666describe("define hats", () => {667 const defineHat = {668 shape: "define-hat",669 category: "custom",670 selector: "procDef",671 }672 test("empty", () => {673 const b = parseBlock("define")674 expect(b.info).toMatchObject(defineHat)675 })676 test("en", () => {677 expect(parseBlock("define foo (bar) quxx").info).toMatchObject(defineHat)678 })679 test("translate en -> de", () => {680 const b = parseBlock("define foo (bar) quxx")681 b.translate(allLanguages.de)682 // TODO omit custom-arg here683 expect(b.stringify()).toEqual("Definiere foo (bar :: custom-arg) quxx")684 })685 test("de", () => {686 expect(687 parseBlock("Definiere foo (bar) quxx", optionsFor("de")).info,688 ).toMatchObject(defineHat)689 })690 test("matches define keyword last", () => {691 expect(692 parseBlock(693 "defina o estilo de rotação para [left-right v]",694 optionsFor("pt_br"),695 ).info,696 ).toMatchObject({697 category: "motion",698 selector: "setRotationStyle",699 })700 expect(701 parseBlock("defina o tamanho como (100) %", optionsFor("pt_br")).info,702 ).toMatchObject({703 category: "looks",704 selector: "setSizeTo:",705 })706 expect(707 parseBlock("defina foo (bar) quxx", optionsFor("pt_br")).info,708 ).toMatchObject(defineHat)709 })710 test("rap: three-word define prefix", () => {711 expect(712 parseBlock("haka tano te foo (bar) quxx", optionsFor("rap")).info,713 ).toMatchObject(defineHat)714 })715 test("uz: two-word define suffix", () => {716 expect(717 parseBlock("foo (bar) quxx ni belgilash", optionsFor("uz")).info,718 ).toMatchObject(defineHat)719 })720})...

Full Screen

Full Screen

http-method-decorators.test.ts

Source:http-method-decorators.test.ts Github

copy

Full Screen

...6 class Test { public foo() {} }7 decoration(Test.prototype, "foo", Object.getOwnPropertyDescriptor(Test.prototype, "foo") as any);8 return getHandlerMeta(Test)[0];9 }10 function optionsFor(method: string) {11 return { method, handler: "foo", options: {}, path: "/" };12 }13 describe("Get()", () => {14 it("should attach a GET request handler", () => {15 expect(withDecoration(Get())).toEqual(optionsFor("GET"));16 });17 });18 describe("Post()", () => {19 it("should attach a POST request handler", () => {20 expect(withDecoration(Post())).toEqual(optionsFor("POST"));21 });22 });23 describe("Patch()", () => {24 it("should attach a PATCH request handler", () => {25 expect(withDecoration(Patch())).toEqual(optionsFor("PATCH"));26 });27 });28 describe("Put()", () => {29 it("should attach a PUT request handler", () => {30 expect(withDecoration(Put())).toEqual(optionsFor("PUT"));31 });32 });33 describe("Delete()", () => {34 it("should attach a DELETE request handler", () => {35 expect(withDecoration(Delete())).toEqual(optionsFor("DELETE"));36 });37 });38 describe("Head()", () => {39 it("should attach a HEAD request handler", () => {40 expect(withDecoration(Head())).toEqual(optionsFor("HEAD"));41 });42 });43 describe("Options()", () => {44 it("should attach a OPTIONS request handler", () => {45 expect(withDecoration(Options())).toEqual(optionsFor("OPTIONS"));46 });47 });48 describe("Use()", () => {49 it("should attach an express USE handler", () => {50 expect(withDecoration(Use())).toEqual(optionsFor("USE"));51 });52 });53 describe("All()", () => {54 it("should attach an express ALL handler", () => {55 expect(withDecoration(All())).toEqual(optionsFor("ALL"));56 });57 });58 describe("Catch()", () => {59 it("should attach an express error handler", () => {60 expect(withDecoration(Catch())).toEqual({ ...optionsFor("USE"), errorHandler: true });61 });62 });...

Full Screen

Full Screen

apiStubBuilder.js

Source:apiStubBuilder.js Github

copy

Full Screen

1require('dotenv-extended').load();2const config = require("../../config/" + process.env.HOSTED_ENVIRONMENT + "_config.json");3const getEmployeeStubforHolidays = (sendMailTo) => {4 const requestOptionsforHolidays = {};5 requestOptionsforHolidays.requestBody = JSON.stringify({6 "tenantId": config.API.APICredentials.tenantID,7 "emailId": sendMailTo,8 "period": "FULL"9 });10 requestOptionsforHolidays.method = config.API.APIList.getHolidayList.Method;11 requestOptionsforHolidays.url = config.API.APIList.getHolidayList.Endpoint;12 requestOptionsforHolidays.header = {13 'Secret': config.API.APICredentials.Secret,14 'Content-Type': 'application/json'15 };16 return requestOptionsforHolidays;17};18module.exports = {19 getEmployeeStubforHolidays20 ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const options = {2 headers: {3 }4}5const request = http.request(options, res => {6 console.log(`statusCode: ${res.statusCode}`)7 res.on('data', d => {8 process.stdout.write(d)9 })10})11request.on('error', error => {12 console.error(error)13})14const imposters = {15 {16 {17 "is": {18 }19 }20 }21}22request.write(JSON.stringify(imposters))23request.end()24describe('Mountebank', () => {25 describe('POST /imposters', () => {26 it('should create a new imposter', async () => {27 const options = {28 headers: {29 }30 }31 const request = http.request(options, res => {32 console.log(`statusCode: ${res.statusCode}`)33 res.on('data', d => {34 process.stdout.write(d)35 })36 })37 request.on('error', error => {38 console.error(error)39 })40 const imposters = {41 {42 {43 "is": {44 }45 }46 }47 }48 request.write(JSON.stringify(imposters))49 request.end()50 })51 })52})

Full Screen

Using AI Code Generation

copy

Full Screen

1var options = {2 headers: {3 }4};5request(options, function (error, response, body) {6 if (error) throw new Error(error);7 console.log(body);8});9{10 {11 }12}13var options = {14 headers: {15 },16 body: {17 },18};19request(options, function (error, response, body) {20 if (error) throw new Error(error);21 console.log(body);22});23{24 {25 }26}27var options = {

Full Screen

Using AI Code Generation

copy

Full Screen

1var options = {2 body: {3 {4 {5 equals: {6 }7 }8 {9 is: {10 }11 }12 }13 },14};15request(options).then(function (response) {16}).catch(function (err) {17});18var options = {19 body: {20 {21 {22 equals: {23 }24 }25 {26 is: {27 }28 }29 }30 },31};32request(options).then(function (response) {33}).catch(function (err) {34});35var options = {36 body: {37 {38 {39 equals: {40 }41 }42 {43 is: {44 }45 }46 }47 },48};49request(options).then(function (response) {50}).catch(function (err) {51});52var options = {

Full Screen

Using AI Code Generation

copy

Full Screen

1const options = {2 headers: {3 },4};5rp(options)6 .then(function (parsedBody) {7 console.log(parsedBody);8 })9 .catch(function (err) {10 console.log(err);11 });12{ allowInjection: false,13 defaultResponseHeaders: {},14 defaultProxyResponseHeaders: {},15 defaultStubResponseHeaders: {},16 defaultRecordResponseHeaders: {},

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var options = {3};4mb.optionsFor(options, function (err, options) {5 mb.create(options, function (err, mbServer) {6 console.log('Mountebank server started');7 mbServer.close();8 });9});

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1var optionsFor = require('mountebank').optionsFor;2var imposter = {3 {4 {5 is: {6 }7 }8 }9};10options.createImposter(imposter);

Full Screen

Using AI Code Generation

copy

Full Screen

1var optionsFor = require('mountebank').optionsFor;2var config = {3 stubs: [{4 predicates: [{5 equals: {path: '/test'}6 }],7 responses: [{8 is: {body: 'Hello World!'}9 }]10 }]11};12var mb = optionsFor(config);13require('mountebank').create(mb, function (err, imposter) {14 console.log('Imposter started on port ' + imposter.port);15});16var optionsFor = require('mountebank').optionsFor;17var config = {18 stubs: [{19 predicates: [{20 equals: {path: '/test'}21 }],22 responses: [{23 is: {body: 'Hello World!'}24 }]25 }]26};27var mb = optionsFor(config);28require('mountebank').create(mb, function (err, imposter) {29 console.log('Imposter started on port ' + imposter.port);30});31var optionsFor = require('mountebank').optionsFor;32var config = {33 stubs: [{34 predicates: [{35 equals: {path: '/test'}36 }],37 responses: [{38 is: {body: 'Hello World!'}39 }]40 }]41};42var mb = optionsFor(config);43require('mountebank').create(mb, function (err, imposter) {44 console.log('Imposter started on port ' + imposter.port);45});46var optionsFor = require('mountebank').optionsFor;47var config = {48 stubs: [{49 predicates: [{50 equals: {path: '/test'}51 }],52 responses: [{53 is: {body: 'Hello World!'}54 }]55 }]56};57var mb = optionsFor(config);58require('mountebank').create(mb, function (err, imposter) {59 console.log('Imposter started on port ' + imposter.port);60});

Full Screen

Using AI Code Generation

copy

Full Screen

1const mb = require('mountebank');2mb.create({3})4 .then(function (imposter) {5 imposter.optionsFor(2525).then(function (options) {6 console.log(options);7 });8 });9const mb = require('mountebank');10mb.create({

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