Best JavaScript code snippet using chromeless
forms.js
Source:forms.js
...90 };91 },92 getForms: function(options, cb) {93 var self = this;94 self.initConnection(options, function(err, connections) {95 if (err) {96 return cb(err);97 }98 return getForms.getForms(connections, options, cb);99 });100 },101 findForms: function(options, formsList, cb) {102 var self = this;103 self.initConnection(options, function(err, connections) {104 if (err) {105 return cb(err);106 }107 return getForms.findForms(connections, formsList, cb);108 });109 },110 submissionSearch: function(options, params, cb) {111 var self = this;112 self.initConnection(options, function(err, connections) {113 if (err) {114 return cb(err);115 }116 return require('./impl/searchSubmissions.js').submissionSearch(connections, options, params, cb);117 });118 },119 getForm: function(options, cb) {120 var self = this;121 self.initConnection(options, function(err, connections) {122 if (err) {123 return cb(err);124 }125 return require('./impl/getForm.js')(connections, options, cb);126 });127 },128 getAllForms: function(options, cb) {129 var self = this;130 self.initConnection(options, function(err, connections) {131 if (err) {132 return cb(err);133 }134 options.getAllForms = true;135 return getForms.getForms(connections, options, cb);136 });137 },138 /**139 * importForms - Importing Form Definitions From A ZIP File.140 *141 * @param {object} options142 * @param {string} options.zipFile A Path to a ZIP file on the file system.143 * @param {string} options.workingDir A Path to a directory where the zip file can be unzipped to.144 * @param {string} options.url The Mongo Database Connection URL.145 * @param {function} callback146 * @return {type}147 */148 importForms: function(options, cb) {149 var self = this;150 self.initConnection(options, function(err, connections) {151 if (err) {152 return cb(err);153 }154 return require('./impl/importForms').importForms(connections, options, cb);155 });156 },157 deleteForm : function(options, cb) {158 var self = this;159 self.initConnection(options, function(err, connections) {160 if (err) {161 return cb(err);162 }163 return require('./impl/deleteForm.js')(connections, options, cb);164 });165 },166 getTheme: function(options, cb) {167 var self = this;168 self.initConnection(options, function(err, connections) {169 if (err) {170 return cb(err);171 }172 if (options.appId) {173 return require('./impl/getThemeForApp.js')(connections, options, cb);174 } else {175 return require('./impl/getTheme.js')(connections, options, cb);176 }177 });178 },179 getAppTheme: function(options, cb) {180 var self = this;181 self.initConnection(options, function(err, connections) {182 if (err) {183 return cb(err);184 }185 return require('./impl/getThemeForApp.js')(connections, options, cb);186 });187 },188 setAppTheme: function(options, cb) {189 var self = this;190 self.initConnection(options, function(err, connections) {191 if (err) {192 return cb(err);193 }194 return require('./impl/setThemeForApp.js')(connections, options, cb);195 });196 },197 createTheme : function(options, themeData, cb) {198 var self = this;199 delete themeData._id;200 self.initConnection(options, function(err, connections) {201 if (err) {202 return cb(err);203 }204 return require('./impl/updateTheme.js')(connections, options, themeData, cb);205 });206 },207 updateOrCreateTheme : function(options, themeData, cb) {208 var self = this;209 options.createIfNotFound = true;210 self.initConnection(options, function(err, connections) {211 if (err) {212 return cb(err);213 }214 return require('./impl/updateTheme.js')(connections, options, themeData, cb);215 });216 },217 updateTheme : function(options, themeData, cb) {218 var self = this;219 self.initConnection(options, function(err, connections) {220 if (err) {221 return cb(err);222 }223 return require('./impl/updateTheme.js')(connections, options, themeData, cb);224 });225 },226 cloneTheme: function(options, cb) {227 var self = this;228 self.initConnection(options, function(err, connections) {229 if (err) {230 return cb(err);231 }232 return require('./impl/cloneTheme.js')(connections, options, cb);233 });234 },235 exportThemes: function(options, cb) {236 var self = this;237 self.initConnection(options, function(err, connections) {238 if (err) {239 return cb(err);240 }241 return require('./impl/exportThemes.js')(connections, options, cb);242 });243 },244 importThemes: function(options, themesToImport, cb) {245 var self = this;246 self.initConnection(options, function(err, connections) {247 if (err) {248 return cb(err);249 }250 return require('./impl/importThemes.js')(connections, options, themesToImport, cb);251 });252 },253 deleteTheme : function(options, cb) {254 var self = this;255 self.initConnection(options, function(err, connections) {256 if (err) {257 return cb(err);258 }259 return require('./impl/deleteTheme.js')(connections, options, cb);260 });261 },262 getThemes : function(options, cb) {263 var self = this;264 self.initConnection(options, function(err, connections) {265 if (err) {266 return cb(err);267 }268 return require('./impl/getThemes.js')(connections, options, cb);269 });270 },271 updateOrCreateForm: function(options, formData, cb) {272 var self = this;273 options.createIfNotFound = true;274 self.updateForm(options, formData, cb);275 },276 updateForm: function(options, formData, cb) {277 var self = this;278 self.initConnection(options, function(err, connections) {279 if (err) {280 return cb(err);281 }282 return require('./impl/updateForm.js')(connections, options, formData, cb);283 });284 },285 cloneForm: function(options, cb) {286 var self = this;287 self.initConnection(options, function(err, connections) {288 if (err) {289 return cb(err);290 }291 return require('./impl/cloneForm.js')(connections, options, cb);292 });293 },294 getSubmissions: function(options, params, cb) {295 var self = this;296 self.initConnection(options, function(err, connections) {297 if (err) {298 return cb(err);299 }300 return require('./impl/getSubmissions')(connections, options, params, cb);301 });302 },303 //Exports Submissions As CSV Files304 exportSubmissions: function(options, params, cb) {305 var self = this;306 self.initConnection(options, function(err, connections) {307 if (err) {308 return cb(err);309 }310 return require('./impl/exportSubmissions.js')(connections, options, params, cb);311 });312 },313 //Exports Submissions As CSV Files314 startCSVExport: function(options, cb) {315 var self = this;316 self.initConnection(options, function(err, connections) {317 if (err) {318 return cb(err);319 }320 return require('./impl/startSubmissionCSVExport.js')(connections, options, cb);321 });322 },323 getCSVExportStatus: function(options, cb) {324 var self = this;325 self.initConnection(options, function(err, connections) {326 if (err) {327 return cb(err);328 }329 return require('./impl/submissionExportHelper/getCSVExportStatus.js')(connections, cb);330 });331 },332 updateCSVExportStatus: function(options, status, cb) {333 var self = this;334 //Don't have to pass a callback, updates will be synced on the mongo server with write locks.335 cb = cb || _.noop;336 self.initConnection(options, function(err, connections) {337 if (err) {338 return cb(err);339 }340 return require('./impl/submissionExportHelper/updateCSVExportStatus.js')(connections, status, cb);341 });342 },343 resetExportCSV: function(options, cb) {344 var self = this;345 self.initConnection(options, function(err, connections) {346 if (err) {347 return cb(err);348 }349 return require('./impl/submissionExportHelper/resetCSVExportStatus.js')(connections, cb);350 });351 },352 getSubmission: function(options, params, cb) {353 var self = this;354 self.initConnection(options, function(err, connections) {355 if (err) {356 return cb(err);357 }358 return require('./impl/getSubmission.js')(connections, options, params, cb);359 });360 },361 getSubmissionEmailData: function(options, params, cb) {362 var self = this;363 self.initConnection(options, function(err, connections) {364 if (err) {365 return cb(err);366 }367 return require('./impl/getSubmissionEmailData.js')(connections, options, params, cb);368 });369 },370 generateSubmissionPdf: function(options, cb) {371 var self = this;372 self.initConnection(options, function(err, connections) {373 if (err) {374 return cb(err);375 }376 return require('./impl/generatePDF.js')(connections, options, cb);377 });378 },379 deleteSubmission: function(options, params, cb) {380 var self = this;381 self.initConnection(options, function(err, connections) {382 if (err) {383 return cb(err);384 }385 return require('./impl/deleteSubmission.js')(connections, options, params, cb);386 });387 },388 getSubmissionFile: function(options, params, cb) {389 var self = this;390 self.initConnection(options, function(err, connections) {391 if (err) {392 return cb(err);393 }394 return require('./impl/getSubmissionFile.js')(connections, options, params, cb);395 });396 },397 submitFormData: function(options, cb) {398 var self = this;399 self.initConnection(options, function(err, connections) {400 if (err) {401 return cb(err);402 }403 return require('./impl/submitFormData.js')(connections, options, cb);404 });405 },406 submitFormFile: function(options, cb) {407 var self = this;408 self.initConnection(options, function(err, connections) {409 if (err) {410 return cb(err);411 }412 logger.info("Submit Form File: ", options);413 return require('./impl/submitFormFile.js')(connections, options, cb);414 });415 },416 completeFormSubmission: function(options, cb) {417 var self = this;418 self.initConnection(options, function(err, connections) {419 if (err) {420 return cb(err);421 }422 return require('./impl/completeFormSubmission.js')(connections, options, cb);423 });424 },425 getSubmissionStatus: function(options, cb) {426 var self = this;427 self.initConnection(options, function(err, connections) {428 if (err) {429 return cb(err);430 }431 return require('./impl/getSubmissionStatus.js')(connections, options, cb);432 });433 },434 updateSubmission : function(options, cb) {435 var self = this;436 self.initConnection(options, function(err, connections) {437 if (err) {438 return cb(err);439 }440 // create & update submission both use same impl441 return require('./impl/submitFormData.js')(connections, options, cb);442 });443 },444 updateSubmissionFile : function(options, cb) {445 var self = this;446 self.initConnection(options, function(err, connections) {447 if (err) {448 return cb(err);449 }450 return require('./impl/updateSubmissionFile.js').updateSubmissionFile(connections, options, cb);451 });452 },453 getNotifications : function(options, cb) {454 var self = this;455 self.initConnection(options, function(err, connections) {456 if (err) {457 return cb(err);458 }459 return require('./impl/getNotifications.js')(connections, options, cb);460 });461 },462 updateNotifications : function(options, subscribers, cb) {463 var self = this;464 self.initConnection(options, function(err, connections) {465 if (err) {466 return cb(err);467 }468 return require('./impl/updateNotifications.js')(connections, options, subscribers, cb);469 });470 },471 getFormApps: function(options, cb) {472 var self = this;473 self.initConnection(options, function(err, connections) {474 if (err) {475 return cb(err);476 }477 return require('./impl/formapps.js').getFormApps(connections, options, cb);478 });479 },480 getPopulatedFormList: function(options, cb) {481 var self = this;482 self.initConnection(options,function(err, connections) {483 if (err) {484 return cb(err);485 }486 return require('./impl/getPopulatedFormsList.js')(connections, options, cb);487 });488 },489 updateAppForms: function(options, appForms, cb) {490 var self = this;491 self.initConnection(options, function(err, connections) {492 if (err) {493 return cb(err);494 }495 return require('./impl/appforms.js').updateAppForms(connections, options, appForms, cb);496 });497 },498 getAppFormsForApp: function(options, cb) {499 var self = this;500 self.initConnection(options, function(err, connections) {501 if (err) {502 return cb(err);503 }504 return require('./impl/appforms.js').getAppFormsForApp(connections, options, cb);505 });506 },507 getAllAppForms: function(options, cb) {508 var self = this;509 self.initConnection(options, function(err, connections) {510 if (err) {511 return cb(err);512 }513 return require('./impl/appforms.js').getAllAppForms(connections, options, cb);514 });515 },516 exportForms: function(options, callback) {517 var self = this;518 self.initConnection(options, function(err, connections) {519 if (err) {520 return callback(err);521 }522 return require('./impl/exportForms.js')(connections, callback);523 });524 },525 exportAppForms: function(options, cb) {526 var self = this;527 self.initConnection(options, function(err, connections) {528 if (err) {529 return cb(err);530 }531 return require('./impl/exportAppforms.js')(connections, options, cb);532 });533 },534 importAppForms: function(options, appFormsToImport, cb) {535 var self = this;536 self.initConnection(options, function(err, connections) {537 if (err) {538 return cb(err);539 }540 return require('./impl/importAppforms.js')(connections, options, appFormsToImport, cb);541 });542 },543 exportAppConfig: function(options, cb) {544 var self = this;545 self.initConnection(options, function(err, connections) {546 if (err) {547 return cb(err);548 }549 return require('./impl/exportAppConfig.js')(connections, options, cb);550 });551 },552 importAppConfig: function(options, configToImport, cb) {553 var self = this;554 self.initConnection(options, function(err, connections) {555 if (err) {556 return cb(err);557 }558 return require('./impl/importAppConfig.js')(connections, options, configToImport, cb);559 });560 },561 getAllAppsForUser: function(options, cb) {562 var self = this;563 self.initConnection(options, function(err, connections) {564 if (err) {565 return cb(err);566 }567 return groups.getAppsForUser(connections, options.restrictToUser, function(err, allowedApps) {568 if (err) {569 return cb(err);570 }571 return cb(undefined, allowedApps);572 });573 });574 },575 getAllGroups: function(options, cb) {576 var self = this;577 self.initConnection(options, function(err, connections) {578 if (err) {579 return cb(err);580 }581 return groups.getAllGroups(connections, options, function(err, result) {582 if (err) {583 return cb(err);584 }585 return cb(undefined, result);586 });587 });588 },589 getGroup: function(options, params, cb) {590 var self = this;591 self.initConnection(options, function(err, connections) {592 if (err) {593 return cb(err);594 }595 return groups.getGroup(connections, options, params, function(err, result) {596 if (err) {597 return cb(err);598 }599 return cb(undefined, result);600 });601 });602 },603 updateGroup: function(options, params, cb) {604 var self = this;605 self.initConnection(options, function(err, connections) {606 if (err) {607 return cb(err);608 }609 return groups.updateGroup(connections, options, params, function(err, result) {610 if (err) {611 return cb(err);612 }613 return cb(undefined, result);614 });615 });616 },617 addAppToUsersGroups : function(options,params, cb) {618 var self = this;619 self.initConnection(options, function(err, connections) {620 if (err) {621 return cb(err);622 }623 return groups.addAppToUsersGroups(connections,params.restrictToUser,params.appId, function(err, result) {624 if (err) {625 return cb(err);626 }627 return cb(undefined, result);628 });629 });630 },631 createAppConfig: function(options, params, cb) {632 var self = this;633 self.initConnection(options, function(err, connections) {634 if (err) {635 return cb(err);636 }637 return appConfig.createAppConfig(connections, options, params, function(err, result) {638 if (err) {639 return cb(err);640 }641 return cb(undefined, result);642 });643 });644 },645 updateAppConfig: function(options, params, cb) {646 var self = this;647 self.initConnection(options, function(err, connections) {648 if (err) {649 return cb(err);650 }651 return appConfig.updateAppConfig(connections, options, params, function(err, result) {652 if (err) {653 return cb(err);654 }655 return cb(undefined, result);656 });657 });658 },659 getAppConfig: function(options, params, cb) {660 var self = this;661 self.initConnection(options, function(err, connections) {662 if (err) {663 return cb(err);664 }665 return appConfig.getAppConfig(connections, options, params, function(err, result) {666 if (err) {667 return cb(err);668 }669 return cb(undefined, result);670 });671 });672 },673 setAppConfig: function(options, params, cb) {674 var self = this;675 self.initConnection(options, function(err, connections) {676 if (err) {677 return cb(err);678 }679 return appConfig.setAppConfig(connections, options, params, cb);680 });681 },682 deleteAppConfig: function(options, params, cb) {683 var self = this;684 self.initConnection(options, function(err, connections) {685 if (err) {686 return cb(err);687 }688 return appConfig.deleteAppConfig(connections, options, params, function(err, result) {689 if (err) {690 return cb(err);691 }692 return cb(undefined, result);693 });694 });695 },696 getAppClientConfig: function(options, cb) {697 var self = this;698 var params = {appId: options.appId};699 self.initConnection(options, function(err, connections) {700 if (err) {701 return cb(err);702 }703 return appConfig.getAppConfig(connections, options, params, function(err, result) {704 if (err) {705 return cb(err);706 }707 var clientConfig = result.client;708 var config_admin_user = false;709 if (options.deviceId && clientConfig.config_admin_user && (clientConfig.config_admin_user.length > 0)) {710 config_admin_user = deviceInClientAdminUserList(options.deviceId, clientConfig.config_admin_user);711 }712 clientConfig.config_admin_user = config_admin_user;713 return cb(undefined, clientConfig);714 function deviceInClientAdminUserList(deviceId, deviceList) {715 return deviceList.indexOf(deviceId) >= 0;716 }717 });718 });719 },720 createGroup: function(options, params, cb) {721 var self = this;722 self.initConnection(options, function(err, connections) {723 if (err) {724 return cb(err);725 }726 return groups.createGroup(connections, options, params, cb);727 });728 },729 deleteGroup: function(options, params, cb) {730 var self = this;731 self.initConnection(options, function(err, connections) {732 if (err) {733 return cb(err);734 }735 return groups.deleteGroup(connections, options, params, cb);736 });737 },738 deleteAppReferences: function(options, params, cb) {739 var self = this;740 self.initConnection(options, function(err, connections) {741 if (err) {742 return cb(err);743 }744 return deleteAppReferences.deleteAppRefrences(connections, options, params, cb);745 });746 },747 setLogger: function(logger) {748 return logfns.setLogger(logger);749 },750 dataSources: {751 get: function(options, params, cb) {752 forms.initConnection(options, function(err, connections) {753 if (err) {754 return cb(err);755 }756 return dataSourceImpl.get(connections, params, cb);757 });758 },759 getAuditLogEntry: function(options, params, cb) {760 forms.initConnection(options, function(err, connections) {761 if (err) {762 return cb(err);763 }764 return dataSourceImpl.getAuditLogEntry(connections, params, cb);765 });766 },767 create: function(options, dataSource, cb) {768 forms.initConnection(options, function(err, connections) {769 if (err) {770 return cb(err);771 }772 return dataSourceImpl.create(connections, dataSource, cb);773 });774 },775 list: function(options, params, cb) {776 forms.initConnection(options, function(err, connections) {777 if (err) {778 return cb(err);779 }780 return dataSourceImpl.list(connections, params, cb);781 });782 },783 update: function(options, dataSource, cb) {784 forms.initConnection(options, function(err, connections) {785 if (err) {786 return cb(err);787 }788 return dataSourceImpl.update(connections, dataSource, cb);789 });790 },791 deploy: function(options, dataSource, cb) {792 forms.initConnection(options, function(err, connections) {793 if (err) {794 return cb(err);795 }796 return dataSourceImpl.deploy(connections, dataSource, cb);797 });798 },799 updateCache: function(options, dataSources, params, cb) {800 forms.initConnection(options, function(err, connections) {801 if (err) {802 return cb(err);803 }804 return dataSourceImpl.updateCache(connections, dataSources, params, cb);805 });806 },807 validate: function(options, dataSource, cb) {808 forms.initConnection(options, function(err, connections) {809 if (err) {810 return cb(err);811 }812 return dataSourceImpl.validate(connections, dataSource, cb);813 });814 },815 remove: function(options, params, cb) {816 forms.initConnection(options, function(err, connections) {817 if (err) {818 return cb(err);819 }820 return dataSourceImpl.remove(connections, params, cb);821 });822 }823 },824 dataTargets: {825 get: function(options, params, cb) {826 forms.initConnection(options, function(err, connections) {827 if (err) {828 return cb(err);829 }830 return dataTargetImpl.get(connections, params, cb);831 });832 },833 create: function(options, dataTarget, cb) {834 forms.initConnection(options, function(err, connections) {835 if (err) {836 return cb(err);837 }838 return dataTargetImpl.create(connections, dataTarget, cb);839 });840 },841 list: function(options, params, cb) {842 forms.initConnection(options, function(err, connections) {843 if (err) {844 return cb(err);845 }846 return dataTargetImpl.list(connections, params, cb);847 });848 },849 update: function(options, dataTarget, cb) {850 forms.initConnection(options, function(err, connections) {851 if (err) {852 return cb(err);853 }854 return dataTargetImpl.update(connections, dataTarget, cb);855 });856 },857 validate: function(options, dataTarget, cb) {858 forms.initConnection(options, function(err, connections) {859 if (err) {860 return cb(err);861 }862 return dataTargetImpl.validate(connections, dataTarget, cb);863 });864 },865 remove: function(options, params, cb) {866 forms.initConnection(options, function(err, connections) {867 if (err) {868 return cb(err);869 }870 return dataTargetImpl.remove(connections, params, cb);871 });872 }873 }874};...
eventClass.js
Source:eventClass.js
1/*2* A Class to process events3*/4class Event {5 constructor() {6 // initialize Events dependency: AuthUser class on each new instance of Event Class7 this.authUser = new AuthUser();8 }9 /*10 * VerifyBiljett method11 * params: biljet Id: String12 * return json response from server 13 */14 verifyBiljett = (biljetId) => {15 // get login token from local storage16 const token = this.authUser.getToken();17 // log it18 console.log(token);19 // reassign it as an obj20 const biljetIdObj = {21 biljetId: biljetId22 }23 // configure the connection settings24 this.authUser.initConnection.fetchInfo.method = 'POST';25 this.authUser.initConnection.fetchInfo.endpoint = 'event';26 this.authUser.initConnection.fetchInfo.paramName = 'verify';27 this.authUser.initConnection.fetchInfo.headers = {28 'Authorization': `Bearer ${token}`,29 'Content-Type': 'application/json'30 };31 this.authUser.initConnection.fetchInfo.requestBody = biljetIdObj;32 // execute the conncetion to backend33 const data = this.authUser.initConnection.connectTopApi();34 // return server response 35 return data;36 }37 /*38 * bestallBiljett method39 * params: event Id: String40 * return json response from server 41 */42 bestallBiljett = async (eventId) => {43 // configure the connection settings44 this.authUser.initConnection.fetchInfo.method = 'GET';45 this.authUser.initConnection.fetchInfo.endpoint = 'event';46 this.authUser.initConnection.fetchInfo.paramName = 'book';47 this.authUser.initConnection.fetchInfo.paramValue = eventId;48 // execute the conncetion to backend49 const data = await this.authUser.initConnection.connectTopApi();50 // return server response 51 return data;52 }53 /*54 * renderItem method55 * receive data array from server then render them as html entities56 */57 renderItem = (data = '') => {58 // html container to load events entities inside it 59 let container = document.querySelector("#eventsListContainer");60 // check if we have an error response61 if (data.error && data.message) {62 container.innerHTML = `<b>${data.message}</b>`;63 }64 // otherwise loop through our data array 65 else data.forEach(el => {66 // create an article html obj that will represent each event to the client/browser67 const articleHtmlObj = document.createElement("article");68 // html article content69 let innerHtml = `70 <aside class="event-date"><div>${el.date}</div></aside>71 <div class="event-content"> 72 <h1><a href="buy.html?id=${el.id}">${el.title}</a></h1>73 74 75 <p class="publisher">76 ${el.publisher}77 </p>78 <p>79 ${el.biljetterKvar} biljeter Kvar 80 </p>81 <p>${el.time} <span class="price">${el.price} ${el.currency}</span></p>82 83 </div>84 `;85 // assign inner html content to our parent article obj86 articleHtmlObj.innerHTML = innerHtml;87 // append each article html item to dom88 container.appendChild(articleHtmlObj);89 })90 }91 renderSingleItem = (el = '') => {92 // html container to load events entities inside it 93 let container = document.querySelector("#eventsListContainer");94 // check if we have an error response95 if (el.error && el.message) {96 container.innerHTML = `<b>${data.message}</b>`;97 }98 // otherwise loop through our data array 99 // else data.forEach(el => {100 // create an article html obj that will represent each event to the client/browser101 const articleHtmlObj = document.createElement("div");102 articleHtmlObj.className = "event-details";103 // html article content104 let innerHtml = `105 <p>You are about to score some tickets to</p>106 <div class="event-content"> 107 <h1>${el.title}</h1>108 109 <p>110 <span>${el.date} ${el.time}</span>111 </p>112 <p class="publisher">113 @${el.publisher}114 </p>115 <p>116 ${el.price} ${el.currency}117 </p>118 119 <p>${el.biljetterKvar} biljeter Kvar </p>120 <p>121 <a href="ticket.html?eventId=${el.id}"><button class="book">122 Beställ123 </button></a>124 </p>125 </div>126 127 128 `;129 // assign inner html content to our parent article obj130 articleHtmlObj.innerHTML = innerHtml;131 // append each article html item to dom132 container.appendChild(articleHtmlObj);133 }134 /*135 * getEvents method136 * receive data array from server then execute the rendering mehtod on it137 */138 getEvents = async () => {139 // configure the connection140 this.authUser.initConnection.fetchInfo.method = 'GET';141 this.authUser.initConnection.fetchInfo.endpoint = 'event';142 // execute the connection143 const data = await this.authUser.initConnection.connectTopApi();144 // call rendering mehtod on the reposnse145 this.renderItem(data);146 }147 /**148 * Get single event details149 */150 getSingleEvent = async (eventId) => {151 // configure the connection152 this.authUser.initConnection.fetchInfo.method = 'GET';153 this.authUser.initConnection.fetchInfo.endpoint = 'event';154 this.authUser.initConnection.fetchInfo.paramName = 'buy';155 this.authUser.initConnection.fetchInfo.paramValue = eventId;156 // execute the connection157 const data = await this.authUser.initConnection.connectTopApi();158 console.log(data);159 // return event obj160 return data;161 }162 renderTicket = (el = '', ticketCode = '') => {163 // html container to load events entities inside it 164 let container = document.querySelector("#eventsListContainer");165 // check if we have an error response166 if (el.error && el.message) {167 container.innerHTML = `<b>${data.message}</b>`;168 }169 // create an article html obj that will represent each event to the client/browser170 const articleHtmlObj = document.createElement("div");171 articleHtmlObj.className = "ticket";172 // html article content173 let innerHtml = `174 <div class="ticket-content"> 175 <h1>${el.title}</h1>176 177 178 <p class="publisher"><span>Where</span>179 </br>180 ${el.publisher}181 </br>182 </br>183 </p>184 <p class="date">185 <span>When: ${el.date} </span><span>Time: ${el.time}</span>186 </p>187 188 <p class="barcode">189 <image src="barcode.png" alt="Ticket Barcode">190 </br>191 ${ticketCode}192 </p>193 </div>194 `;195 // assign inner html content to our parent article obj196 articleHtmlObj.innerHTML = innerHtml;197 // append each article html item to dom198 container.appendChild(articleHtmlObj);199 }...
testConnection.spec.ts
Source:testConnection.spec.ts
1import { createTestConnection } from './testConnection';2import { defaultTestFileSettings, sleep } from '../utils';3import { InitializeResult } from 'vscode-languageserver';4function InitConnection() {5 const { connection, controller } = createTestConnection();6 const File1Settings = { insertSpaces: true, tabSize: 7 };7 controller.documentConfigs['/file'] = {8 editor: File1Settings,9 };10 return { connection, controller, File1Settings };11}12test('Server: TestConnection getConfig no params', async () => {13 const { connection } = InitConnection();14 expect(await connection.workspace.getConfiguration()).toStrictEqual({15 editor: defaultTestFileSettings,16 });17});18test('Server: TestConnection getConfig string param', async () => {19 const { connection } = InitConnection();20 expect(await connection.workspace.getConfiguration('editor')).toStrictEqual(21 defaultTestFileSettings22 );23});24test('Server: TestConnection getConfig item param {}', async () => {25 const { connection } = InitConnection();26 expect(await connection.workspace.getConfiguration({})).toStrictEqual({27 editor: defaultTestFileSettings,28 });29});30test("Server: TestConnection getConfig item param { scopeUri: '/file' }", async () => {31 const { connection, File1Settings } = InitConnection();32 expect(await connection.workspace.getConfiguration({ scopeUri: '/file' })).toStrictEqual({33 editor: File1Settings,34 });35});36test("Server: TestConnection getConfig item param { section: 'editor' }", async () => {37 const { connection } = InitConnection();38 expect(await connection.workspace.getConfiguration({ section: 'editor' })).toStrictEqual(39 defaultTestFileSettings40 );41});42test("Server: TestConnection getConfig item param { scopeUri: '/file', section: 'editor' }", async () => {43 const { connection, File1Settings } = InitConnection();44 expect(45 await connection.workspace.getConfiguration({ scopeUri: '/file', section: 'editor' })46 ).toStrictEqual(File1Settings);47});48test("Server: TestConnection getConfig item param [{ scopeUri: '/file', section: 'editor' }, non existent file]", async () => {49 const { connection, File1Settings } = InitConnection();50 expect(51 await connection.workspace.getConfiguration([52 { scopeUri: '/file', section: 'editor' },53 { scopeUri: '/nonExistentFile' },54 ])55 ).toStrictEqual([File1Settings, undefined]);56});57test('Server: TestConnection getConfig non Existent Section', async () => {58 const { connection } = InitConnection();59 expect(await connection.workspace.getConfiguration('THE_NON_EXISTENT_SECTION')).toStrictEqual(60 undefined61 );62});63test('Server: TestConnection onDidOpenTextDocument', async () => {64 const { connection, controller } = InitConnection();65 const file1DocItem = { languageId: 'sass', text: '.class\n', uri: '/file', version: 0 };66 connection.onDidOpenTextDocument((p) => {67 expect(p.textDocument).toStrictEqual(file1DocItem);68 });69 controller.onDidOpenTextDocument({70 textDocument: file1DocItem,71 });72});73test('Server: TestConnection onDidChangeTextDocument', async () => {74 const { connection, controller } = InitConnection();75 const file1DocItem = { languageId: 'sass', text: '.class\n', uri: '/file', version: 0 };76 const contentChange = [77 { range: { start: { character: 10, line: 0 }, end: { character: 0, line: 1 } }, text: '' },78 ];79 connection.onDidChangeTextDocument((p) => {80 expect(p.textDocument).toStrictEqual(file1DocItem);81 expect(p.contentChanges).toStrictEqual(contentChange);82 });83 controller.onDidChangeTextDocument({84 textDocument: file1DocItem,85 contentChanges: contentChange,86 });87});88test('Server: TestConnection Initialize', async () => {89 const { connection, controller } = InitConnection();90 connection.onInitialize(async (params, cancellationToken, workDoneProgress, resultProgress) => {91 expect(params.capabilities).toStrictEqual({ workspace: { configuration: true } });92 const res: InitializeResult = { capabilities: {} };93 return res;94 });95 controller.onInitialize({96 capabilities: { workspace: { configuration: true } },97 processId: 0,98 rootUri: '/',99 workspaceFolders: [],100 });101});102test('Server: TestConnection OnDidChangeConfiguration', async () => {103 const { connection, controller } = InitConnection();104 connection.onInitialize(async (params) => {105 expect(params.capabilities).toStrictEqual({ workspace: { configuration: true } });106 const res: InitializeResult = { capabilities: {} };107 return res;108 });109 controller.onInitialize({110 capabilities: { workspace: { configuration: true } },111 processId: 0,112 rootUri: '/',113 workspaceFolders: [],114 });115 connection.onDidChangeConfiguration((p) => {116 expect(p.settings).toStrictEqual({ a: 2 });117 });118 controller.onDidChangeConfiguration({ settings: { a: 2 } });...
Using AI Code Generation
1var chromeless = require('chromeless')()2 .initConnection()3 .type('chromeless', 'input[name="q"]')4 .press(13)5 .wait('#resultStats')6 .evaluate(() => document.title)7 .end()8 .then(console.log)9 .catch(console.error)10var chromeless = require('chromeless')()11 .type('chromeless', 'input[name="q"]')12 .press(13)13 .wait('#resultStats')14 .evaluate(() => document.title)15 .end()16 .then(console.log)17 .catch(console.error)18 at ExecutionContext._evaluateInternal (/Users/.../node_modules/chromeless/dist/src/lib/ExecutionContext.js:97:13)19 at ExecutionContext.evaluate (/Users/.../node_modules/chromeless/dist/src/lib/ExecutionContext.js:42:12)20 at Chromeless.evaluate (/Users/.../node_modules/chromeless/dist/src/chromeless.js:154:29)21 at process._tickCallback (internal/process/next_tick.js:103:7)
Using AI Code Generation
1const chromeless = require('chromeless').initConnection();2(async () => {3 .type('chromeless', 'input[name="q"]')4 .press(13)5 .wait('#resultStats')6 .screenshot()7 await chromeless.end()8})()9const chromeless = require('chromeless').initConnection();10(async () => {11 .type('chromeless', 'input[name="q"]')12 .press(13)13 .wait('#resultStats')14 .screenshot()15 await chromeless.end()16})()17const chromeless = require('chromeless').initConnection();18(async () => {19 .type('chromeless', 'input[name="q"]')20 .press(13)21 .wait('#resultStats')22 .screenshot()23 await chromeless.end()24})()25const chromeless = require('chromeless').initConnection();26(async () => {27 .type('chromeless', 'input[name="q"]')28 .press(13)29 .wait('#resultStats')30 .screenshot()31 await chromeless.end()32})()33const chromeless = require('chromeless').initConnection();34(async () => {35 .type('chromeless', 'input[name="q"]')36 .press(13)37 .wait('#resultStats')38 .screenshot()39 await chromeless.end()40})()41const chromeless = require('chromeless').initConnection();42(async () => {43 .goto('https
Using AI Code Generation
1const chromeless = require('chromeless')()2const fs = require('fs')3async function run() {4 .type('chromeless', 'input[name="q"]')5 .press(13)6 .wait('#resultStats')7 .screenshot()8 await chromeless.end()9}10run().catch(console.error.bind(console))11const chromeless = require('chromeless')()12async function run() {13 .type('chromeless', 'input[name="q"]')14 .press(13)15 .wait('#resultStats')16 .screenshot()17 await chromeless.end()18}19run().catch(console.error.bind(console))20const chromeless = require('chromeless')()21async function run() {22 .type('chromeless', 'input[name="q"]')23 .press(13)24 .wait('#resultStats')25 .screenshot()26 await chromeless.end()27}28run().catch(console.error.bind(console))29const chromeless = require('chromeless')()30async function run() {31 .type('chromeless', 'input[name="q"]')32 .press(13)33 .wait('#resultStats')34 .screenshot()35 await chromeless.end()36}37run().catch(console.error.bind(console))38const chromeless = require('chromeless')()39async function run() {
Using AI Code Generation
1const chromeless = require('chromeless')()2const initConnection = require('./initConnection')3const myConnection = initConnection(chromeless)4 .type('chromeless', 'input[name="q"]')5 .press(13)6 .wait('#resultStats')7 .evaluate(() => {8 })9 .end()10 .then(console.log)11 .catch(console.error)12module.exports = function (chromeless) {13}14const chromeless = require('chromeless')()15const initConnection = require('./initConnection')16const myConnection = initConnection(chromeless)17 .type('chromeless', 'input[name="q"]')18 .press(13)19 .wait('#resultStats')20 .evaluate(() => {21 })22 .end()23 .then(console.log)24 .catch(console.error)25module.exports = function (chromeless) {26}
Using AI Code Generation
1const chromeless = require('chromeless')()2const initConnection = require('chromeless/dist/util/initConnection')3const connection = initConnection({4})5 .use(connection)6 .type('chromeless', 'input[name="q"]')7 .press(13)8 .wait('#resultStats')9 .evaluate(() => {10 })11 .end()12 .then((title) => {13 console.log('title', title)14 })15 .catch((e) => {16 console.error('error', e)17 })18const chromeless = require('chromeless')()19const initConnection = require('chromeless/dist/util/initConnection')20const connection = initConnection({21})22 .use(connection)23 .type('chromeless', 'input[name="q"]')24 .press(13)25 .wait('#resultStats')26 .evaluate(() => {27 })28 .end()29 .then((title) => {30 console.log('title', title)31 })32 .catch((e) => {33 console.error('error', e)34 })35const chromeless = require('chromeless')()36const initConnection = require('chromeless/dist/util/initConnection')37const connection = initConnection({38})39 .use(connection)40 .type('chromeless', 'input[name="q"]')41 .press(13)42 .wait('#resultStats')43 .evaluate(() => {44 })45 .end()46 .then((title) => {47 console.log('title', title)48 })49 .catch((e) => {50 console.error('error', e)51 })
Using AI Code Generation
1var Chromeless = require('chromeless').Chromeless2var fs = require('fs')3var chromeless = new Chromeless()4 .initConnection()5 .screenshot()6 .then((screenshot) => {7 fs.writeFileSync('screenshot.png', screenshot)8 })9 .end()10 .catch((err) => {11 console.error(err)12 })13var Chromeless = require('chromeless').Chromeless14var fs = require('fs')15var chromeless = new Chromeless()16 .initConnection()17 .screenshot('input[name="btnK"]')18 .then((screenshot) => {19 fs.writeFileSync('screenshot.png', screenshot)20 })21 .end()22 .catch((err) => {23 console.error(err)24 })
Using AI Code Generation
1const chromeless = require('chromeless')()2var initConnection = require('./chromeless.js');3var chromeless = initConnection.initConnection();4module.exports = {5};6const Chromeless = require('chromeless').Chromeless7var chromeless = new Chromeless({8})9module.exports = {10 initConnection: function() {11 return chromeless;12 }13};
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!!