How to use entryCount method in mountebank

Best JavaScript code snippet using mountebank

jquery.socialcards.js

Source:jquery.socialcards.js Github

copy

Full Screen

1/*!2 * SocialCards v. 3.03 * http://www.pixelatedviews.com/socialcards.html4 *5 * Copyright (c) 2016, Brian Whaley <brian.whaley@gmail.com>6 * Released under the MIT license7 * https://opensource.org/licenses/mit-license.php8 *9 * Date: 2019-12-01T12:58Z10 *11 * ADDED: Shutterfly12 * ADDED 500px (NOTE must use 'SOOpx' for properties - numerics not allowed)13 * FIXED: Instagram feed14 * FIXED: Remove use of QUERY.YAHOOAPIS.COM YQL15 * FIXED: YouTube card content16 * FIXED: Use of entryCount17 * FIXED: Remove Google Plus18 * TODO: Goodreads Cards19 * TODO: Foursquare Feed20 * 21 */22/* ========================================23===== GLOBAL VARIABLES =====24======================================== */25function socialCards() {26 $.socialCards();27}28/* ========================================29===== SOCIALCARDS PLUGIN =====30======================================== */31(function($) {32 /* $.fn.socialCards = function(options) { */33 $.socialCards = function(options) {34 this.defaults = {35 targetID: '#social', 36 blank: {37 url: '',38 entryCount: 5,39 iconSrc: '',40 iconSrcAlt: ''41 },42 SOOpx: {43 url: '',44 entryCount: 5,45 iconSrc: 'images/500px-logo.png',46 iconSrcAlt: '500px Post'47 },48 blog: {49 url: '',50 entryCount: 5,51 iconSrc: 'images/blog-logo.png',52 iconSrcAlt: 'Blog Post'53 },54 etsy: {55 url: '',56 entryCount: 5,57 iconSrc: 'images/etsy-logo.png',58 iconSrcAlt: 'Etsy Favorite'59 },60 /* facebook: {61 iconSrc: 'images/facebook-logo.png',62 iconSrcAlt: 'Facebook Wall Post'63 }, */64 flickr: {65 userID: '',66 apiKey: '',67 tags: '',68 entryCount: 5,69 iconSrc: 'images/flickr-logo.png',70 iconSrcAlt: 'Flickr Photo'71 },72 foursquare: {73 url: '',74 entryCount: 5,75 iconSrc: 'images/foursquare-logo.png',76 iconSrcAlt: 'FourSquare Checkin'77 },78 goodreads:{79 url: '',80 entryCount: 5,81 iconSrc: 'images/goodreads-logo.png',82 iconSrcAlt: 'GoodReads Currently Reading'83 },84 instagram: {85 userID: '',86 entryCount: 5,87 iconSrc: 'images/instagram-logo.jpg',88 iconSrcAlt: 'Instagram Photo'89 },90 pinterest: {91 url: '',92 entryCount: 5,93 iconSrc: 'images/pinterest-logo.png',94 iconSrcAlt: 'Pinterest Pin'95 },96 shutterfly: {97 url: '',98 entryCount: 5,99 iconSrc: 'images/shutterfly-logo.jpg',100 iconSrcAlt: 'Shutterfly Items'101 },102 tumblr: {103 url: '',104 entryCount: 5,105 iconSrc: 'images/tumblr-logo.png',106 iconSrcAlt: 'Tumblr Post'107 },108 twitter: {109 url: '',110 entryCount: 5,111 iconSrc: 'images/twitter-logo.png',112 iconSrcAlt: 'Twitter Tweet'113 },114 youtube: {115 url: '',116 entryCount: 5,117 iconSrc: 'images/youtube-logo.png',118 iconSrcAlt: 'Youtube Favorite Video'119 },120 other: {121 url: '',122 entryCount: 5,123 iconSrc: 'images/blog-logo.png',124 iconSrcAlt: 'Post'125 }126 };127 /* first param true = recursive */128 var options = $.extend( true, this.defaults, options );129 var mySocialCards = [];130 mySocialCards.cards = [];131 132 this.myCards = function() { return mySocialCards.cards ; }133 /* ========================================134 ===== FEEDS API =====135 ======================================== */136 function getFeedEntries(myURL, entryCount) {137 $.ajax({138 url: 'https://api.rss2json.com/v1/api.json',139 method: 'GET',140 dataType: 'json',141 data: {142 rss_url: myURL,143 api_key: 'c3wsmqh4h1iydxxip3sgkr1jtk3brllbp61jc6yd', 144 count: entryCount145 }146 }).done( function(data) {147 $.each(data.items, function(itemIndex, thisItem){148 var myNewCard = [];149 myNewCard = data.items[itemIndex];150 /* ===== FIX FOR DESCRIPTION ===== */151 myNewCard.content = thisItem.description;152 if ( thisItem.description ) {153 } else {154 var myImgBase = thisItem.thumbnail ;155 var myImgTag = '<img src="' + myImgBase + '" alt="' + thisItem.title + '" title="' + thisItem.title + '">';156 myNewCard.content = '<p>' + myImgTag + thisItem.title + '</p>' ;157 myNewCard.description = myNewCard.content; 158 }159 /* ===== FIX FOR SOURCE ===== */160 if ( $(thisItem).hasOwnProperty('source') ) {161 } else {162 if($.isArray(thisItem.link)) {163 if($.isPlainObject(thisItem.link[0])){164 myNewCard.source = thisItem.link[0].href;165 } else {166 myNewCard.source = thisItem.link[0];167 }168 } else {169 myNewCard.source = thisItem.link;170 }171 }172 mySocialCards.cards.push(myNewCard);173 mySocialCards.cards.sort(sortCardsByPubDate);174 if (itemIndex >= entryCount) { return false; }175 }); 176 renderSocialCards(options.targetID, mySocialCards);177 })178 .fail(function() {179 console.log('RSS2JSON API Call failed.');180 })181 .always(function() {182 }); 183 }184 /* ========================================185 ===== FLICKR API =====186 ======================================== */187 /* ========== ========== ========== */188 function getFlickrEntries(userID, apiKey, tags, entryCount){189 $.getJSON( 'https://api.flickr.com/services/rest/?jsoncallback=?', {190 method: 'flickr.photos.search',191 api_key: apiKey,192 user_id: userID,193 tags: tags,194 per_page: entryCount, // 500195 page: 1,196 format: 'json',197 extras: 'description, date_upload, date_taken, owner_name, tags'198 })199 .done(function(data){200 flickrToCards(data, entryCount);201 })202 .fail(function() {203 console.log('Flickr API Call failed.');204 })205 .always(function() {206 }); 207 }; 208 /* ========== ========== ========== */209 function flickrToCards(data, entryCount){210 $.each(data.photos.photo, function(index) {211 var myImg = data.photos.photo[index];212 var myImgBase = 'https://farm' + myImg.farm + '.static.flickr.com/' + myImg.server + '/' + myImg.id + '_' + myImg.secret + '.jpg';213 var myImgTag = '<img src="' + myImgBase + '" alt="' + myImg.title + '" title="' + myImg.title + '">';214 var myCard = {};215 myCard = {216 author: myImg.ownername,217 categories: [],218 content: '<p>' + myImgTag + myImg.description._content + '</p>',219 contentSnippet: '',220 link: myImgBase ,221 pubDate: myImg.datetaken ,222 source: 'www.flickr.com',223 title: myImg.title224 };225 mySocialCards.cards.push(myCard);226 mySocialCards.cards.sort(sortCardsByPubDate);227 if (index >= entryCount) { return false; }228 });229 renderSocialCards(options.targetID, mySocialCards);230 }231 /* ========================================232 ===== GOODREADS API =====233 ======================================== */234 /* ========== ========== ========== */235 function getGoodreadsEntries(myURL, entryCount){236 $.get( myURL, {237 })238 .done(function(data){239 console.log(data);240 })241 .fail(function() {242 console.log('Goodreads Call failed.');243 })244 .always(function() {245 }); 246 };247 /* ========================================248 ===== INSTAGRAM API =====249 ======================================== */250 /* ========== ========== ========== */251 function getInstagramEntries(userID, entryCount){252 $.getJSON('https://www.instagram.com/' + userID + '/?__a=1',{253 })254 .done(function(data){255 instagramToCards(data, entryCount);256 })257 .fail(function() {258 console.log('Instagram Call failed.');259 })260 .always(function() {261 }); 262 };263 /* ========== ========== ========== */264 function instagramToCards(data, entryCount){265 $.each(data.graphql.user.edge_owner_to_timeline_media.edges, function(index) {266 var myGram = data.graphql.user.edge_owner_to_timeline_media.edges[index].node;267 var myGramBase = myGram.thumbnail_src;268 var myGramName = myGram.owner.username;269 if (myGram.location) { myGramName = myGram.location.name; }270 var myGramTag = '<img src="' + myGramBase + '" alt="' + myGramName + '" title="' + myGramName + '">';271 var myCard = {};272 myCard = {273 author: myGram.owner.username,274 categories: [],275 content: '<p>' + myGramTag + myGramName + '</p>',276 contentSnippet: '',277 link: myGramBase ,278 pubDate: new Date(myGram.taken_at_timestamp * 1000) ,279 source: 'www.instagram.com',280 title: myGramName281 };282 mySocialCards.cards.push(myCard);283 mySocialCards.cards.sort(sortCardsByPubDate);284 if (index >= entryCount) { return false; }285 });286 renderSocialCards(options.targetID, mySocialCards);287 }288 /* ========================================289 ===== CARD GENERATION =====290 ======================================== */291 /* ========== ========== ========== */292 function sortCardsByPubDate(a, b) {293 var property = 'pubDate';294 var dateA = new Date(a[property]);295 var dateB = new Date(b[property]);296 if (dateA < dateB) {297 return 1;298 } else if (dateA > dateB) {299 return -1;300 } else {301 return 0;302 }303 }304 /* ========== ========== ========== */305 function renderSocialCards(myDivId, data){306 $(myDivId).empty();307 $.each(data.cards, function(entryIndex, entry){308 var myFeedIcon = '';309 switch (true) {310 case (entry.source.indexOf('500px.com') > -1): myOptions = options.SOOpx; break;311 case (entry.source.indexOf('blog') > -1): myOptions = options.blog; break;312 case (entry.source.indexOf('etsy.com') > -1): myOptions = options.etsy; break;313 case (entry.source.indexOf('foursquare.com') > -1): myOptions = options.foursquare; break;314 case (entry.source.indexOf('flickr.com') > -1): myOptions = options.flickr; break;315 case (entry.source.indexOf('goodreads.com') > -1): myOptions = options.goodreads; break;316 case (entry.source.indexOf('instagram') > -1): myOptions = options.instagram; break;317 case (entry.source.indexOf('pinterest.com') > -1): myOptions = options.pinterest; break;318 case (entry.source.indexOf('shutterfly.com') > -1): myOptions = options.shutterfly; break;319 case (entry.source.indexOf('tumblr.com') > -1): myOptions = options.tumblr; break;320 case (entry.source.indexOf('twitter') > -1): myOptions = options.twitter; break;321 case (entry.source.indexOf('youtube') > -1): myOptions = options.youtube; break;322 case (entry.source.indexOf('other') > -1): myOptions = options.other; break;323 default: myOptions = options.blank; break;324 }325 myFeedIcon = '<img class="cardIcon" src="' + myOptions.iconSrc + '" alt="' + myOptions.iconSrcAlt + '" />';326 var myHTML = '<div class="masonry-item">';327 myHTML += '<div class="card">';328 myHTML += '<div class="cardTitle"><a href="' + entry.link + '" target="_blank">' + myFeedIcon + entry.title + '</a></div>';329 if (entry.content.length > 500) {330 var $entryContent = $($.parseHTML(entry.content));331 $entryContent = $entryContent.filter('p:first').html();332 myHTML += '<div class="cardBody">' + $entryContent + '</div>'; 333 } else {334 myHTML += '<div class="cardBody">' + entry.content + '</div>'; 335 }336 myHTML += '<div class="cardDate">' + entry.pubDate + '</div>'337 myHTML += '</div>';338 myHTML += '</div>';339 $(myDivId).append(myHTML);340 });341 }342 343 344 /* ========== ========== ========== */345 function gatherData() {346 for(var prop in options) {347 var option = options[prop] ;348 if (option.hasOwnProperty('url')) {349 if (option.url){350 getFeedEntries(option.url, option.entryCount);351 }352 }353 }354 if(options.flickr.userID){ getFlickrEntries(options.flickr.userID, options.flickr.apiKey, options.flickr.tags, options.flickr.entryCount); }355 if(options.goodreads.url){ getGoodreadsEntries(options.goodreads.url, options.goodreads.entryCount); }356 if(options.instagram.userID){ getInstagramEntries(options.instagram.userID, options.instagram.entryCount); }357 };358 359 360 361 /* ========== ========== ========== */362 this.init = function(){363 gatherData();364 renderSocialCards(options.targetID, mySocialCards);365 return this;366 }367 return this.init();368 369 };370 ...

Full Screen

Full Screen

20.index.test.ts

Source:20.index.test.ts Github

copy

Full Screen

1import assert from 'node:assert/strict'2import { join, fileShortPath, genCurrentDirname } from '@waiting/shared-core'3import {4 walk,5 DirFilterCbParams,6 DirFilterCbRet,7 EntryType,8} from '../src/index.js'9const testRootDir = genCurrentDirname(import.meta.url)10describe(fileShortPath(import.meta.url), () => {11 it('Should walk() works', (resolve) => {12 const path = join(testRootDir, 'test_dirs')13 const assertDirCount = 714 const assertFileCount = 815 let dirCount = 016 let fileCount = 017 let linkCount = 018 let entryCount = 019 walk(path).subscribe(20 (data) => {21 switch (data.type) {22 case EntryType.dir:23 dirCount += 124 entryCount += 125 break26 case EntryType.file:27 fileCount += 128 entryCount += 129 break30 case EntryType.link:31 linkCount += 132 break33 case EntryType.noAcessPermission:34 entryCount += 135 break36 }37 },38 (err) => {39 assert(false, (err as Error).message)40 resolve()41 },42 () => {43 assertCount({44 path, dirCount, fileCount, entryCount, assertDirCount, assertFileCount,45 })46 resolve()47 },48 )49 })50 it('Should walk() works', (resolve) => {51 const path = join(testRootDir, 'test_dirs/dir-level1-a')52 const assertDirCount = 253 const assertFileCount = 254 let dirCount = 055 let fileCount = 056 let entryCount = 057 walk(path).subscribe(58 (data) => {59 switch (data.type) {60 case EntryType.dir:61 dirCount += 162 entryCount += 163 break64 case EntryType.file:65 fileCount += 166 entryCount += 167 break68 case EntryType.noAcessPermission:69 entryCount += 170 break71 }72 },73 (err) => {74 assert(false, (err as Error).message)75 resolve()76 },77 () => {78 assertCount({79 path, dirCount, fileCount, entryCount, assertDirCount, assertFileCount,80 })81 resolve()82 },83 )84 })85 it('Should walk() works with path not existing', (resolve) => {86 const path = join(testRootDir, 'test_dirsFAKE')87 const assertDirCount = 088 const assertFileCount = 089 let dirCount = 090 let fileCount = 091 let entryCount = 092 walk(path).subscribe(93 (data) => {94 switch (data.type) {95 case EntryType.dir:96 dirCount += 197 entryCount += 198 break99 case EntryType.file:100 fileCount += 1101 entryCount += 1102 break103 case EntryType.noAcessPermission:104 entryCount += 1105 break106 }107 },108 (err) => {109 assert(false, (err as Error).message)110 resolve()111 },112 () => {113 assertCount({114 path, dirCount, fileCount, entryCount, assertDirCount, assertFileCount,115 })116 resolve()117 },118 )119 })120 it('Should walk() works with options.maxDepth == 0', (resolve) => {121 const path = join(testRootDir, 'test_dirs')122 const assertDirCount = 1123 const assertFileCount = 0124 let dirCount = 0125 let fileCount = 0126 let entryCount = 0127 const maxDepth = 0128 walk(path, { maxDepth }).subscribe(129 (data) => {130 switch (data.type) {131 case EntryType.dir:132 dirCount += 1133 entryCount += 1134 break135 case EntryType.file:136 fileCount += 1137 entryCount += 1138 break139 case EntryType.noAcessPermission:140 entryCount += 1141 break142 }143 },144 (err) => {145 assert(false, (err as Error).message)146 resolve()147 },148 () => {149 assertCount({150 path, dirCount, fileCount, entryCount, assertDirCount, assertFileCount,151 })152 resolve()153 },154 )155 })156 it('Should walk() works with options.maxDepth == 1', (resolve) => {157 const path = join(testRootDir, 'test_dirs')158 const assertDirCount = 4159 const assertFileCount = 2160 let dirCount = 0161 let fileCount = 0162 let entryCount = 0163 const maxDepth = 1164 walk(path, { maxDepth }).subscribe(165 (data) => {166 switch (data.type) {167 case EntryType.dir:168 dirCount += 1169 entryCount += 1170 break171 case EntryType.file:172 fileCount += 1173 entryCount += 1174 break175 case EntryType.noAcessPermission:176 entryCount += 1177 break178 }179 },180 (err) => {181 assert(false, (err as Error).message)182 resolve()183 },184 () => {185 assertCount({186 path, dirCount, fileCount, entryCount, assertDirCount, assertFileCount,187 })188 resolve()189 },190 )191 })192 it('Should walk() works with DirFilterCb returining Array', (resolve) => {193 const path = join(testRootDir, 'test_dirs')194 const assertDirCount = 7195 const assertFileCount = 8196 let dirCount = 0197 let fileCount = 0198 let entryCount = 0199 const dirFilterCb = ({ files }: DirFilterCbParams): DirFilterCbRet => {200 return files201 }202 walk(path, { dirFilterCb }).subscribe(203 (data) => {204 switch (data.type) {205 case EntryType.dir:206 dirCount += 1207 entryCount += 1208 break209 case EntryType.file:210 fileCount += 1211 entryCount += 1212 break213 case EntryType.noAcessPermission:214 entryCount += 1215 break216 }217 },218 (err) => {219 assert(false, (err as Error).message)220 resolve()221 },222 () => {223 assertCount({224 path, dirCount, fileCount, entryCount, assertDirCount, assertFileCount,225 })226 resolve()227 },228 )229 })230 it('Should walk() works with DirFilterCb returining Array filtered by name', (resolve) => {231 const path = join(testRootDir, 'test_dirs')232 // test_dirs, test_dirs/dir-level1-a, test_dirs/dir-level1-a/dir-level2-a233 const assertDirCount = 3234 // test_dirs/level1-a.txt, test_dirs/dir-level1-a/level2-a.txt, test_dirs/dir-level1-a/dir-level2-a/level3-a.txt235 const assertFileCount = 3236 let dirCount = 0237 let fileCount = 0238 let entryCount = 0239 const dirFilterCb = ({ files }: DirFilterCbParams): DirFilterCbRet => {240 return files.filter((file) => {241 return file.includes('a') ? true : false242 })243 }244 walk(path, { dirFilterCb }).subscribe(245 (data) => {246 switch (data.type) {247 case EntryType.dir:248 dirCount += 1249 entryCount += 1250 break251 case EntryType.file:252 fileCount += 1253 entryCount += 1254 break255 case EntryType.noAcessPermission:256 entryCount += 1257 break258 }259 },260 (err) => {261 assert(false, (err as Error).message)262 resolve()263 },264 () => {265 assertCount({266 path, dirCount, fileCount, entryCount, assertDirCount, assertFileCount,267 })268 resolve()269 },270 )271 })272 it('Should walk() works with DirFilterCb returining Array filtered by parentPath', (resolve) => {273 const path = join(testRootDir, 'test_dirs')274 // test_dirs, test_dirs/dir-level1-a, test_dirs/dir-level1-b, test_dirs/dir-level1-z,275 // dir-level1-a/dir-level2-a276 const assertDirCount = 5277 // test_dirs/level1-a.txt, test_dirs/level1-b.txt278 // test_dirs/dir-level1-a/level2-a.txt, test_dirs/dir-level1-a/dir-level2-a/level3-a.txt279 const assertFileCount = 4280 let dirCount = 0281 let fileCount = 0282 let entryCount = 0283 const dirFilterCb = ({ parentPath, files, curDepth }: DirFilterCbParams): DirFilterCbRet => {284 if (curDepth > 1) {285 if (/test_dirs\/[\w\d/-]+?a/u.exec(parentPath.replace(/\\/g, '/'))) {286 return files287 }288 }289 else {290 return files291 }292 }293 walk(path, { dirFilterCb }).subscribe(294 (data) => {295 switch (data.type) {296 case EntryType.dir:297 dirCount += 1298 entryCount += 1299 break300 case EntryType.file:301 fileCount += 1302 entryCount += 1303 break304 case EntryType.noAcessPermission:305 entryCount += 1306 break307 }308 },309 (err) => {310 assert(false, (err as Error).message)311 resolve()312 },313 () => {314 assertCount({315 path, dirCount, fileCount, entryCount, assertDirCount, assertFileCount,316 })317 resolve()318 },319 )320 })321 it('Should walk() works with DirFilterCb returining Array filtered by name and maxDepth', (resolve) => {322 const path = join(testRootDir, 'test_dirs')323 const assertDirCount = 2 // test_dirs, test_dirs/dir-level1-a324 const assertFileCount = 1 // test_dirs/level1-a.txt325 let dirCount = 0326 let fileCount = 0327 let entryCount = 0328 const dirFilterCb = ({ files, curDepth }: DirFilterCbParams): DirFilterCbRet => {329 return files.filter((file) => {330 return file.includes('a') && curDepth < 2 ? true : false331 })332 }333 walk(path, { dirFilterCb }).subscribe(334 (data) => {335 switch (data.type) {336 case EntryType.dir:337 dirCount += 1338 entryCount += 1339 break340 case EntryType.file:341 fileCount += 1342 entryCount += 1343 break344 case EntryType.noAcessPermission:345 entryCount += 1346 break347 }348 },349 (err) => {350 assert(false, (err as Error).message)351 resolve()352 },353 () => {354 assertCount({355 path, dirCount, fileCount, entryCount, assertDirCount, assertFileCount,356 })357 resolve()358 },359 )360 })361})362interface AssertCountParams {363 path: string364 dirCount: number365 fileCount: number366 entryCount: number367 assertDirCount: number368 assertFileCount: number369}370function assertCount({371 path, dirCount, fileCount, entryCount, assertDirCount, assertFileCount,372}: AssertCountParams): void {373 console.info(`path: "${path}": dirCount: ${dirCount}, fileCount: ${fileCount}, entryCount: ${entryCount}\n`)374 assert(dirCount === assertDirCount, 'dirs not equivalent')375 assert(fileCount === assertFileCount, 'files not equivalent')376 assert(dirCount + fileCount === assertDirCount + assertFileCount, 'entries not equivalent')...

Full Screen

Full Screen

init.js

Source:init.js Github

copy

Full Screen

1var lastTime;2var entryCount;3$(document).ready(function() {4 entryCount = 0;5 var displayCount = 0;6 //capture key presses7 $(document).on("keypress", function(e) {8 e.preventDefault();9 entryCount ++;10 displayCount ++;11 //translate unicode to characters 12 var char = String.fromCharCode(e.which);13 console.log("entry #" + entryCount + " : " + e.which + " | " + char + ". Showing " + displayCount);14 createElement(char,entryCount);15 });16 //capture function keys17 $(document).on("keydown", function(e) {18 var nowTime = Date.now();19 if(lastTime !== undefined) {20 var difference = nowTime - lastTime;21 // this tells you the number of time between each press22 transform(difference, entryCount);23 }24 function transform(difference, entryCount){25 console.log(difference);26 var elem = document.getElementById(entryCount);27 //$( "div span:last-child" ).style.fontWeight = difference;28 if (elem){29 elem.style.letterSpacing = difference/3 + "px"; 30 elem.style.opacity = difference/90;31 };32 console.log(elem);33 }34 // now we're done with everything35 lastTime = nowTime;36 //if pressed key is a backspace37 if (e.which == 8){38 e.preventDefault();39 entryCount ++;40 console.log("entry #" + entryCount + " : " + e.which + " | BKSP. Showing " + displayCount);41 deleteElement();42 displayCount --;43 if (displayCount < 0) {44 displayCount = 0;45 }46 }47}); 48});49function createElement(k,entryCount) {50// letters51 var elem = $('#cursor');52 if (k == "a" || k == "A") { 53 elem.before('<span id = "' + entryCount + '" class="inner">A</span>'); 54 }55 if (k == "b" || k == "B") { 56 elem.before('<span id = "' + entryCount + '" class="inner">B</span>'); 57 }58 if (k == "c" || k == "C") { 59 elem.before('<span id = "' + entryCount + '" class="inner">C</span>'); 60 }61 if (k == "d" || k == "D") { 62 elem.before('<span id = "' + entryCount + '" class="inner">D</span>'); 63 }64 if (k == "e" || k == "E") { 65 elem.before('<span id = "' + entryCount + '" class="inner">E</span>'); 66 }67 if (k == "f" || k == "F") { 68 elem.before('<span id = "' + entryCount + '" class="inner">F</span>'); 69 }70 if (k == "g" || k == "G") { 71 elem.before('<span id = "' + entryCount + '" class="inner">G</span>'); 72 }73 if (k == "h" || k == "H") { 74 elem.before('<span id = "' + entryCount + '" class="inner">H</span>'); 75 }76 if (k == "i" || k == "I") { 77 elem.before('<span id = "' + entryCount + '" class="inner">I</span>'); 78 }79 if (k == "j" || k == "J") { 80 elem.before('<span id = "' + entryCount + '" class="inner">J</span>'); 81 }82 if (k == "k" || k == "K") { 83 elem.before('<span id = "' + entryCount + '" class="inner">K</span>'); 84 }85 if (k == "l" || k == "L") { 86 elem.before('<span id = "' + entryCount + '" class="inner">L</span>'); 87 }88 if (k == "m" || k == "M") { 89 elem.before('<span id = "' + entryCount + '" class="inner">M</span>'); 90 }91 if (k == "n" || k == "N") { 92 elem.before('<span id = "' + entryCount + '" class="inner">N</span>'); 93 }94 if (k == "o" || k == "O") { 95 elem.before('<span id = "' + entryCount + '" class="inner">O</span>'); 96 }97 if (k == "p" || k == "P") { 98 elem.before('<span id = "' + entryCount + '" class="inner">P</span>'); 99 }100 if (k == "q" || k == "Q") { 101 elem.before('<span id = "' + entryCount + '" class="inner">Q</span>'); 102 }103 if (k == "r" || k == "R") { 104 elem.before('<span id = "' + entryCount + '" class="inner">R</span>'); 105 }106 if (k == "s" || k == "S") { 107 elem.before('<span id = "' + entryCount + '" class="inner">S</span>'); 108 }109 if (k == "t" || k == "T") { 110 elem.before('<span id = "' + entryCount + '" class="inner">T</span>'); 111 }112 if (k == "u" || k == "U") { 113 elem.before('<span id = "' + entryCount + '" class="inner">U</span>'); 114 }115 if (k == "v" || k == "V") { 116 elem.before('<span id = "' + entryCount + '" class="inner">V</span>'); 117 }118 if (k == "w" || k == "W") { 119 elem.before('<span id = "' + entryCount + '" class="inner">W</span>'); 120 }121 if (k == "x" || k == "X") { 122 elem.before('<span id = "' + entryCount + '" class="inner">X</span>'); 123 }124 if (k == "y" || k == "Y") { 125 elem.before('<span id = "' + entryCount + '" class="inner">Y</span>'); 126 }127 if (k == "z" || k == "Z") { 128 elem.before('<span id = "' + entryCount + '" class="inner">Z</span>'); 129 }130//numbers131 if (k == "1" || k == "1") { 132 elem.before('<span id = "' + entryCount + '" class="inner">1</span>'); 133 }134 if (k == "2" || k == "2") { 135 elem.before('<span id = "' + entryCount + '" class="inner">2</span>'); 136 }137 if (k == "3" || k == "3") { 138 elem.before('<span id = "' + entryCount + '" class="inner">3</span>'); 139 }140 if (k == "4" || k == "4") { 141 elem.before('<span id = "' + entryCount + '" class="inner">4</span>'); 142 }143 if (k == "5" || k == "5") { 144 elem.before('<span id = "' + entryCount + '" class="inner">5</span>'); 145 }146 if (k == "6" || k == "6") { 147 elem.before('<span id = "' + entryCount + '" class="inner">6</span>'); 148 }149 if (k == "7" || k == "7") { 150 elem.before('<span id = "' + entryCount + '" class="inner">7</span>'); 151 }152 if (k == "8" || k == "8") { 153 elem.before('<span id = "' + entryCount + '" class="inner">8</span>'); 154 }155 if (k == "9" || k == "9") { 156 elem.before('<span id = "' + entryCount + '" class="inner">9</span>'); 157 }158 if (k == "0" || k == "0") { 159 elem.before('<span id = "' + entryCount + '" class="inner">0</span>'); 160 }161 if (k == " ") { elem.before('<span class="inner">&nbsp;</span>'); }162};163//this is for backspace164function deleteElement(){165 $(".inner").last().remove();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var assert = require('assert');3mb.start({port: 2525, pidfile: 'mb.pid', logfile: 'mb.log', ipWhitelist: ['*']}, function () {4 {5 {6 {7 is: {8 }9 }10 }11 }12 ];13 mb.createImposters(2525, imposters, function (error, createdImposters) {14 assert.strictEqual(error, null);15 assert.strictEqual(createdImposters.length, 1);16 console.log('Imposter created');17 var imposter = createdImposters[0];18 console.log(imposter.port);19 console.log(imposter.protocol);20 console.log(imposter.stubs.length);21 console.log(imposter.stubs[0].responses.length);22 console.log(imposter.stubs[0].responses[0].is.statusCode);23 console.log(imposter.stubs[0].responses[0].is.body);24 console.log(imposter._links.self.href);25 console.log(imposter._links.config.href);26 console.log(imposter._links.requests.href);27 console.log(imposter._links.responses.href);28 console.log(imposter._links.stub.href);29 console.log(imposter._links.replay.href);30 console.log(imposter._links.replayProxy.href);31 console.log(imposter._links.proxy.href);32 console.log(imposter._links.proxyLogs.href);33 console.log(imposter._links.proxyResponses.href);34 console.log(imposter._links.proxyRequests.href);35 console.log(imposter._links.proxyImposter.href);

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var fs = require('fs');3var imposters = JSON.parse(fs.readFileSync('imposters.json', 'utf8'));4mb.create({port: 2525, pidfile: 'mb.pid', logfile: 'mb.log'}, imposters).then(function () {5 console.log('mountebank started');6 return mb.get('/imposters/3000').then(function (response) {7 console.log(response.body);8 return mb.del('/imposters/3000');9 }).then(function () {10 console.log('imposter deleted');11 return mb.del('/imposters/3001');12 }).then(function () {13 console.log('imposter deleted');14 return mb.del('/imposters/3002');15 }).then(function () {16 console.log('imposter deleted');17 return mb.del('/imposters/3003');18 }).then(function () {19 console.log('imposter deleted');20 return mb.del('/imposters/3004');21 }).then(function () {22 console.log('imposter deleted');23 return mb.del('/imposters/3005');24 }).then(function () {25 console.log('imposter deleted');26 return mb.del('/imposters/3006');27 }).then(function () {28 console.log('imposter deleted');29 return mb.del('/imposters/3007');30 }).then(function () {31 console.log('imposter deleted');32 return mb.del('/imposters/3008');33 }).then(function () {34 console.log('imposter deleted');35 return mb.del('/imposters/3009');36 }).then(function () {37 console.log('imposter deleted');38 return mb.del('/imposters/3010');39 }).then(function () {40 console.log('imposter deleted');41 return mb.del('/imposters/3011');42 }).then(function () {43 console.log('imposter deleted');44 return mb.del('/imposters/3012');45 }).then(function () {46 console.log('imposter deleted');47 return mb.del('/imposters/3013');48 }).then(function () {49 console.log('imposter deleted');50 return mb.del('/imposters/3014');51 }).then(function () {52 console.log('imposter deleted');53 return mb.del('/imposters/3015');

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2mb.create({port: 2525}, function (error, mbServer) {3 mbServer.get('/imposters', function (request, response) {4 mbServer.get('/imposters/2525', function (request, response) {5 mbServer.get('/imposters/2525/requests', function (request, response) {6 console.log(response.body);7 });8 });9 });10});

Full Screen

Using AI Code Generation

copy

Full Screen

1const mb = require('mountebank');2const imposters = await mb.get('/imposters');3console.log(imposters.body.length);4const mb = require('mountebank');5const imposters = await mb.get('/imposters');6console.log(imposters.body.length);7const mb = require('mountebank');8const imposters = await mb.get('/imposters');9console.log(imposters.body.length);10const mb = require('mountebank');11const imposters = await mb.get('/imposters');12console.log(imposters.body.length);13const mb = require('mountebank');14const imposters = await mb.get('/imposters');15console.log(imposters.body.length);16const mb = require('mountebank');17const imposters = await mb.get('/imposters');18console.log(imposters.body.length);19const mb = require('mountebank');20const imposters = await mb.get('/imposters');21console.log(imposters.body.length);22const mb = require('mountebank');23const imposters = await mb.get('/imposters');24console.log(imposters.body.length);25const mb = require('mountebank');26const imposters = await mb.get('/imposters');27console.log(imposters.body.length);28const mb = require('mountebank');29const imposters = await mb.get('/imposters');30console.log(imposters.body.length);31const mb = require('mountebank');32const imposters = await mb.get('/imposters');33console.log(imposters.body.length

Full Screen

Using AI Code Generation

copy

Full Screen

1const mb = require('mountebank');2const mbHelper = require('mountebank-helper');3const mbHelperOptions = {4};5mbHelper.mbHelper(mbHelperOptions).then((mbHelper) => {6 mbHelper.mountebank.get('/imposters/5000').then((imposter) => {7 console.log(imposter.body.requests.entryCount);8 });9});10{11 "scripts": {12 },13 "dependencies": {14 }15}

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2mb.create({port:2525, pidfile:'mb.pid', logfile:'mb.log'}, function(){3 mb.get('/imposters', function (error, response) {4 console.log(response.body);5 });6});7(function (exports, require, module, __filename, __dirname) { var mb = require('mountebank');8 at Function.Module._resolveFilename (module.js:538:15)9 at Function.Module._load (module.js:468:25)10 at Module.require (module.js:587:17)11 at require (internal/module.js:11:18)12 at Object.<anonymous> (C:\Users\testuser\mountebank\test.js:1:27)13 at Module._compile (module.js:643:30)14 at Object.Module._extensions..js (module.js:654:10)15 at Module.load (module.js:556:32)16 at tryModuleLoad (module.js:499:12)17 at Function.Module._load (module.js:491:3)18var request = require('request');

Full Screen

Using AI Code Generation

copy

Full Screen

1var imposter = require('mountebank').create();2imposter.post('/test', function (request, response) {3 response.body = { result: 'success' };4}).then(function () {5 return imposter.get('/imposters');6}).then(function (imposters) {7 return imposter.get('/imposters/' + imposters[0].port + '/requests');8}).then(function (requests) {9 console.log('Number of requests: ' + requests.length);10}).finally(function () {11 imposter.del('/imposters');12});13var imposter = require('mountebank').create();14describe('Mountebank', function () {15 it('should return success', function (done) {16 imposter.post('/test', function (request, response) {17 response.body = { result: 'success' };18 }).then(function () {19 expect(response.statusCode).toEqual(200);20 expect(JSON.parse(body).result).toEqual('success');21 done();22 });23 });24 });25});26var imposter = require('mountebank').create();27describe('Mountebank', function () {28 it('should return success', function (done) {29 imposter.post('/test', function (request, response) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var assert = require('assert');3var port = 2525;4var host = "localhost";5var protocol = "http";6var path = "/test";7var imposter = {8 "stubs": [{9 "responses": [{10 "is": {11 }12 }]13 }]14};15var options = {16};17mb.post(options, function (error, response) {18 assert.strictEqual(response.statusCode, 201);19 mb.get("/imposters", function (error, response) {20 assert.strictEqual(response.statusCode, 200);21 assert.strictEqual(response.body.length, 1);22 assert.strictEqual(response.body[0].port, port);23 assert.strictEqual(response.body[0].protocol, protocol);24 assert.strictEqual(response.body[0].numberOfRequests, 0);25 mb.get("/imposters/" + port, function (error, response) {26 assert.strictEqual(response.statusCode, 200);27 assert.strictEqual(response.body.port, port);28 assert.strictEqual(response.body.protocol, protocol);29 assert.strictEqual(response.body.numberOfRequests, 0);30 mb.get("/imposters/" + port + "/requests", function (error, response) {31 assert.strictEqual(response.statusCode, 200);32 assert.strictEqual(response.body.length, 0);33 mb.get("/imposters/" + port + "/requests/1", function (error, response) {34 assert.strictEqual(response.statusCode, 404);35 mb.get("/imposters/" + port + "/requests/0", function (error, response) {36 assert.strictEqual(response.statusCode, 404);37 mb.get("/imposters/" + port + "/requests/2", function (error, response) {38 assert.strictEqual(response.statusCode, 404);39 mb.get("/imposters/" + port + "/requests/0", function (error, response) {40 assert.strictEqual(response.statusCode, 404);41 mb.get("/imposters/" + port + "/requests/0", function (error, response) {42 assert.strictEqual(response.statusCode, 404);43 mb.get("/imposters/" + port + "/requests/

Full Screen

Using AI Code Generation

copy

Full Screen

1const mb = require('mountebank');2const port = 2525;3const protocol = 'http';4const imposters = mb.createClient({port: port, protocol: protocol});5const imposter = {6 {7 {8 is: {9 }10 }11 }12};13imposters.post('/', imposter).then((response) => {14 console.log(response.body);15 imposters.get('/2525').then((response) => {16 console.log(response.body);17 });18});19const mb = require('mountebank');20const port = 2525;21const protocol = 'http';22const imposters = mb.createClient({port: port, protocol: protocol});23const imposter = {24 {25 {26 is: {27 }28 }29 }30};31imposters.post('/', imposter).then((response) => {32 console.log(response.body);33 imposters.get('/2525').then((response) => {34 console.log(response.body);35 });36});37{ port: 2525, protocol: 'http', numberOfRequests: 0, stubs: [ { responses: [Object], predicates: [] } ], _links: { self: [Object] } }38{ port: 2525, protocol: 'http', numberOfRequests: 0, stubs: [ { responses: [Object], predicates: [] } ], _links: { self: [Object] } }39const mb = require('mountebank

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