How to use callbacks method in ng-mocks

Best JavaScript code snippet using ng-mocks

LKAPIClient.js

Source:LKAPIClient.js Github

copy

Full Screen

1/**2 * @license3 * Copyright 2016 Cluster Labs, Inc.4 *5 * Licensed under the Apache License, Version 2.0 (the "License");6 * you may not use this file except in compliance with the License.7 * You may obtain a copy of the License at8 *9 * http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17var iter = skit.platform.iter;18var util = skit.platform.util;19var LKAPIClientBase = library.api.LKAPIClientBase;20function LKAPIClient() {}21util.inherits(LKAPIClient, LKAPIClientBase);22LKAPIClient.prototype.healthCheck = function(callbacks) {23 this.send_('debug/health_check', {24 method: 'GET',25 callbacks: callbacks26 });27};28LKAPIClient.prototype.screenshotWithUploadId = function(uploadId, callbacks) {29 this.send_('screenshot_images', {30 method: 'POST',31 params: {'upload_id': uploadId},32 parse: function(data) {33 return [data['image']];34 },35 callbacks: callbacks36 });37};38LKAPIClient.prototype.backgroundWithUploadId = function(uploadId, callbacks) {39 this.send_('background_images', {40 method: 'POST',41 params: {'upload_id': uploadId},42 parse: function(data) {43 return [data['image']];44 },45 callbacks: callbacks46 });47};48LKAPIClient.prototype.websiteIconWithUploadId = function(uploadId, callbacks) {49 this.send_('website_icon_images', {50 method: 'POST',51 params: {'upload_id': uploadId},52 parse: function(data) {53 return [data['image']];54 },55 callbacks: callbacks56 });57};58LKAPIClient.prototype.websiteLogoWithUploadId = function(uploadId, callbacks) {59 this.send_('website_logo_images', {60 method: 'POST',61 params: {'upload_id': uploadId},62 parse: function(data) {63 return [data['image']];64 },65 callbacks: callbacks66 });67};68LKAPIClient.prototype.websiteBackgroundWithUploadId = function(uploadId, callbacks) {69 this.send_('website_background_images', {70 method: 'POST',71 params: {'upload_id': uploadId},72 parse: function(data) {73 return [data['image']];74 },75 callbacks: callbacks76 });77};78LKAPIClient.prototype.websiteScreenshotWithUploadId = function(uploadId, callbacks) {79 this.send_('website_screenshot_images', {80 method: 'POST',81 params: {'upload_id': uploadId},82 parse: function(data) {83 return [data['image']];84 },85 callbacks: callbacks86 });87};88LKAPIClient.prototype.signup = function(firstName, lastName, email, password, callbacks) {89 this.send_('signup', {90 method: 'POST',91 params: {92 'first_name': firstName,93 'last_name': lastName,94 'email': email,95 'password': password96 },97 callbacks: callbacks98 });99};100LKAPIClient.prototype.login = function(email, password, callbacks) {101 var params = {102 grant_type: 'password',103 scope: 'readwrite',104 username: email,105 password: password106 };107 this.send_('oauth2/token', {108 method: 'POST',109 params: params,110 callbacks: callbacks111 });112};113LKAPIClient.prototype.logout = function(callbacks) {114 this.send_('logout', {115 method: 'POST',116 callbacks: callbacks117 });118};119LKAPIClient.prototype.resetPassword = function(email, callbacks) {120 this.send_('reset_password', {121 params: {'email': email},122 method: 'POST',123 callbacks: callbacks124 });125};126LKAPIClient.prototype.setNewPassword = function(token, password, callbacks) {127 this.send_('reset_password/finish', {128 params: {'token': token, 'password': password},129 method: 'POST',130 callbacks: callbacks131 });132};133LKAPIClient.prototype.verifyEmailWithToken = function(token, callbacks) {134 this.send_('verify_email', {135 params: {'token': token},136 method: 'POST',137 callbacks: callbacks138 });139};140LKAPIClient.prototype.unsubscribeWithToken = function(token, callbacks) {141 this.send_('unsubscribe', {142 params: {'token': token},143 method: 'POST',144 callbacks: callbacks145 });146};147LKAPIClient.prototype.user = function(callbacks) {148 var allCallbacks = [{149 onSuccess: function(user) {150 this.currentUser = user;151 },152 context: this153 }];154 allCallbacks.push(callbacks);155 this.send_('user', {156 parse: function(data) {157 return [data['user']];158 },159 callbacks: allCallbacks160 });161};162var parseDetailsResponse = function(data) {163 return [data['user'], data['settings'], data['emails']];164};165LKAPIClient.prototype.userDetails = function(callbacks) {166 var allCallbacks = [{167 onSuccess: function(user) {168 this.currentUser = user;169 },170 context: this171 }];172 allCallbacks.push(callbacks);173 this.send_('user/details', {174 parse: parseDetailsResponse,175 callbacks: allCallbacks176 });177};178LKAPIClient.prototype.updateUserDetails = function(fields, callbacks) {179 this.send_('user/details', {180 method: 'POST',181 params: fields,182 parse: parseDetailsResponse,183 callbacks: callbacks184 });185};186LKAPIClient.prototype.setHasBeenReviewsOnboarded = function(callbacks) {187 var fields = {'has_reviews_onboarded': '1'};188 this.updateUserDetails(fields, callbacks);189};190LKAPIClient.prototype.setHasBeenSalesOnboarded = function(callbacks) {191 var fields = {'has_sales_onboarded': '1'};192 this.updateUserDetails(fields, callbacks);193};194LKAPIClient.prototype.updateUserPhoto = function(gaeUploadId, callbacks) {195 var fields = {'gae_upload_id': gaeUploadId};196 this.updateUserDetails(fields, callbacks);197};198LKAPIClient.prototype.deleteUserAccount = function(myEmailConfirmation, callbacks) {199 this.send_('user/delete', {200 method: 'POST',201 params: {'email': myEmailConfirmation},202 callbacks: callbacks203 });204};205LKAPIClient.prototype.addEmailAddress = function(email, callbacks) {206 this.send_('user/emails', {207 method: 'POST',208 params: {'email': email},209 parse: function(data) {210 return [data['email']]211 },212 callbacks: callbacks213 });214};215LKAPIClient.prototype.removeEmailAddress = function(email, callbacks) {216 this.send_('user/emails/delete', {217 method: 'POST',218 params: {'email': email},219 parse: function(data) {220 return [data['emails']]221 },222 callbacks: callbacks223 });224};225LKAPIClient.prototype.requestVerificationEmail = function(email, callbacks) {226 this.send_('user/emails/request_verification', {227 method: 'POST',228 params: {'email': email},229 parse: function(data) {230 return [data['emails']]231 },232 callbacks: callbacks233 });234};235LKAPIClient.prototype.setEmailAddressPrimary = function(email, callbacks) {236 this.send_('user/emails/set_primary', {237 method: 'POST',238 params: {'email': email},239 parse: function(data) {240 return [data['emails']]241 },242 callbacks: callbacks243 });244};245LKAPIClient.prototype.slackTokenFromCode = function(code, service, onboarding, callbacks) {246 this.send_('slack', {247 method: 'POST',248 params: {'code': code, 'service': service, 'onboarding': onboarding ? '1': '0'},249 callbacks: callbacks250 });251};252LKAPIClient.prototype.slackChannels = function(callbacks) {253 this.send_('slack/channels', {254 method: 'GET',255 parse: function(data) {256 return [data['tokenValid'], data['channels']];257 },258 callbacks: callbacks259 });260};261LKAPIClient.prototype.slackUsage = function(callbacks) {262 this.send_('slack/usage', {263 method: 'GET',264 parse: function(data) {265 return [data['connected'], data['channelsByProduct']];266 },267 callbacks: callbacks268 });269};270LKAPIClient.prototype.slackDisconnect = function(callbacks) {271 this.send_('slack/disconnect', {272 method: 'POST',273 callbacks: callbacks274 });275};276LKAPIClient.prototype.twitterConnect = function(appId, callbackUrl, callbacks) {277 this.send_('twitter/connect', {278 method: 'GET',279 params: {'app_id': appId, 'callback_url': callbackUrl},280 parse: function(data) {281 return [data['twitterConnectUrl']];282 },283 callbacks: callbacks284 });285};286LKAPIClient.prototype.twitterConnectFinish = function(token, verifier, appId, callbacks) {287 this.send_('twitter/finish', {288 method: 'POST',289 params: {'token': token, 'verifier': verifier, 'app_id': appId},290 callbacks: callbacks291 });292};293//294// APP STORE295//296LKAPIClient.prototype.appStoreInfo = function(country, appId, callbacks) {297 this.send_('appstore/' + country + '/' + appId, {298 method: 'GET',299 parse: function(data) {300 return [data['app'], data['related']];301 },302 callbacks: callbacks303 });304};305LKAPIClient.prototype.reviewsApps = function(callbacks) {306 this.send_('apps', {307 method: 'GET',308 parse: function(data) {309 return [data['apps']];310 },311 callbacks: callbacks312 });313};314LKAPIClient.prototype.addReviewsAppWithId = function(country, iTunesId, includeRelated, callbacks) {315 this.send_('apps', {316 method: 'POST',317 params: {318 'itunes_id': iTunesId,319 'country': country,320 'include_related': includeRelated ? '1': '0'321 },322 parse: function(data) {323 return [data['apps']];324 },325 callbacks: callbacks326 });327};328LKAPIClient.prototype.removeReviewsAppWithId = function(country, appId, callbacks) {329 this.send_('apps/' + country + '/' + appId + '/delete', {330 method: 'POST',331 callbacks: callbacks332 });333};334//335// REVIEWS336//337LKAPIClient.prototype.reviewSubscriptions = function(callbacks) {338 this.send_('reviews/subscriptions', {339 method: 'GET',340 parse: function(data) {341 return [data['subscriptions']];342 },343 callbacks: callbacks344 });345};346LKAPIClient.prototype.subscribeToReviewsWithEmail = function(email, callbacks) {347 this.send_('reviews/subscriptions', {348 method: 'POST',349 params: {'email': email},350 parse: function(data) {351 return [data['subscription']];352 },353 callbacks: callbacks354 });355};356LKAPIClient.prototype.subscribeToReviewsWithMyEmail = function(callbacks) {357 this.send_('reviews/subscriptions', {358 method: 'POST',359 params: {'my_email': '1'},360 parse: function(data) {361 return [data['subscription']];362 },363 callbacks: callbacks364 });365};366LKAPIClient.prototype.subscribeToReviewsWithSlackChannel = function(channelName, callbacks) {367 this.send_('reviews/subscriptions', {368 method: 'POST',369 params: {'slack_channel_name': channelName || ''},370 parse: function(data) {371 return [data['subscription']];372 },373 callbacks: callbacks374 });375};376LKAPIClient.prototype.subscribeToReviewsWithSlackUrl = function(url, callbacks) {377 this.send_('reviews/subscriptions', {378 method: 'POST',379 params: {'slack_url': url},380 parse: function(data) {381 return [data['subscription']];382 },383 callbacks: callbacks384 });385};386LKAPIClient.prototype.subscribeToReviewsWithTwitter = function(twitterAppConnectionId, callbacks) {387 this.send_('reviews/subscriptions', {388 method: 'POST',389 params: {'twitter_app_connection_id': twitterAppConnectionId},390 parse: function(data) {391 return [data['subscription']];392 },393 callbacks: callbacks394 });395};396LKAPIClient.prototype.autoSubscribeToReviewsWithTwitter = function(appId, callbacks) {397 this.send_('reviews/subscriptions', {398 method: 'POST',399 params: {'app_id': appId},400 parse: function(data) {401 return [data['subscription']];402 },403 callbacks: callbacks404 });405};406LKAPIClient.prototype.connectAppToTwitter = function(appId, twitterHandle, callbacks) {407 this.send_('twitter/connect_app', {408 method: 'POST',409 params: {'app_id': appId, 'twitter_handle': twitterHandle},410 callbacks: callbacks411 });412};413LKAPIClient.prototype.disconnectAppFromTwitter = function(connectionId, callbacks) {414 this.send_('twitter/disconnect_app', {415 method: 'POST',416 params: {'connection_id': connectionId},417 callbacks: callbacks418 });419};420LKAPIClient.prototype.twitterAppConnections = function(callbacks) {421 this.send_('twitter/connections', {422 method: 'GET',423 parse: function(data) {424 return [data['connections'], data['unconnectedApps'], data['handles']];425 },426 callbacks: callbacks427 });428};429LKAPIClient.prototype.removeReviewSubscription = function(subId, callbacks) {430 this.send_('reviews/subscriptions/' + subId + '/delete', {431 method: 'POST',432 callbacks: callbacks433 });434};435LKAPIClient.prototype.removeSubscriptionWithToken = function(token, callbacks) {436 this.send_('reviews/subscriptions/unsubscribe', {437 params: {'token': token},438 method: 'POST',439 callbacks: callbacks440 });441};442LKAPIClient.prototype.markSubscriptionFilterGood = function(subId, doFilterGood, callbacks) {443 this.send_('reviews/subscriptions/' + subId, {444 method: 'POST',445 params: {'filter_good': doFilterGood ? '1' : '0'},446 callbacks: callbacks447 });448};449function decorateReview(r, appsById) {450 r.app = appsById[r.appId];451 r.stars = '★★★★★'.substring(0, r.rating);452 r.emptyStars = '★★★★★'.substring(0, Math.min(-1 * (r.rating - 5), 5));453 r.needsTriage = r.rating < 4;454}455LKAPIClient.prototype.reviews = function(options, callbacks) {456 var params = {457 rating: options.rating || '',458 app_id: options.appId || '',459 start_review_id: options.startReviewId || '',460 limit: options.limit || '',461 country: options.country || ''462 };463 this.send_('reviews', {464 method: 'GET',465 params: params,466 parse: function(data) {467 var reviews = data['reviews'];468 var appsById = data['apps'];469 iter.forEach(reviews, function(r) {470 decorateReview(r, appsById);471 });472 return [reviews];473 },474 callbacks: callbacks475 });476};477LKAPIClient.prototype.review = function(reviewId, callbacks) {478 this.send_('reviews/' + reviewId, {479 method: 'GET',480 parse: function(data) {481 var review = data['review'];482 var appsById = data['apps'];483 decorateReview(review, appsById);484 return [review];485 },486 callbacks: callbacks487 })488};489LKAPIClient.prototype.tweetReview = function(twitterHandle, reviewId, tweetText, callbacks) {490 this.send_('twitter/tweet_review', {491 method: 'POST',492 params: {'twitter_handle': twitterHandle, 'review_id': reviewId, 'tweet_text': tweetText},493 callbacks: callbacks494 })495};496//497// SALES AND ITUNES CONNECT498//499LKAPIClient.prototype.salesMetrics = function(requestedDate, callbacks) {500 var date = null;501 if (requestedDate) {502 date = (+requestedDate) / 1000.0;503 }504 this.send_('itunes/sales_metrics', {505 method: 'GET',506 params: {'requested_date': date},507 callbacks: callbacks508 });509};510LKAPIClient.prototype.itunesConnect = function(appleId, password, callbacks) {511 this.send_('itunes/connect', {512 method: 'POST',513 params: {'apple_id': appleId, 'password': password},514 callbacks: callbacks515 });516};517LKAPIClient.prototype.disconnectItunes = function(callbacks) {518 this.send_('itunes/disconnect', {519 method: 'POST',520 callbacks: callbacks521 });522};523LKAPIClient.prototype.itunesVendors = function(callbacks) {524 this.send_('itunes/vendors', {525 method: 'GET',526 parse: function(data) {527 return [data['appleId'], data['vendors']]528 },529 callbacks: callbacks530 });531};532LKAPIClient.prototype.chooseVendor = function(vendorId, callbacks) {533 this.send_('itunes/choose_vendor', {534 method: 'POST',535 params: {'vendor_id': vendorId},536 callbacks: callbacks537 });538};539LKAPIClient.prototype.salesReportSubscriptions = function(callbacks) {540 this.send_('itunes/subscriptions', {541 method: 'GET',542 parse: function(data) {543 return [data['subscriptions']];544 },545 callbacks: callbacks546 });547};548LKAPIClient.prototype.subscribeToSalesReportsWithEmail = function(email, callbacks) {549 this.send_('itunes/subscriptions', {550 method: 'POST',551 params: {'email': email},552 parse: function(data) {553 return [data['subscription']];554 },555 callbacks: callbacks556 });557};558LKAPIClient.prototype.subscribeToSalesReportsWithMyEmail = function(callbacks) {559 this.send_('itunes/subscriptions', {560 method: 'POST',561 params: {'my_email': '1'},562 parse: function(data) {563 return [data['subscription']];564 },565 callbacks: callbacks566 });567};568LKAPIClient.prototype.subscribeToSalesReportsWithSlackUrl = function(url, callbacks) {569 this.send_('itunes/subscriptions', {570 method: 'POST',571 params: {'slack_url': url},572 parse: function(data) {573 return [data['subscription']];574 },575 callbacks: callbacks576 });577};578LKAPIClient.prototype.subscribeToSalesReportsWithSlackChannel = function(channelName, callbacks) {579 this.send_('itunes/subscriptions', {580 method: 'POST',581 params: {'slack_channel_name': channelName || ''},582 parse: function(data) {583 return [data['subscription']];584 },585 callbacks: callbacks586 });587};588LKAPIClient.prototype.removeSalesReportSubscription = function(subId, callbacks) {589 this.send_('itunes/subscriptions/' + subId + '/delete', {590 method: 'POST',591 callbacks: callbacks592 });593};594LKAPIClient.prototype.removeSalesReportSubscriptionWithToken = function(token, callbacks) {595 this.send_('itunes/subscriptions/unsubscribe', {596 params: {'token': token},597 method: 'POST',598 callbacks: callbacks599 });600};601//602// SCREENSHOT BUILDER603//604LKAPIClient.prototype.addScreenshotSet = function(appName, appVersion, platform, callbacks) {605 this.send_('screenshot_sets', {606 method: 'POST',607 params: {'name': appName, 'version': appVersion, 'platform': platform},608 parse: function(data) {609 var set = data['set'];610 return [set];611 },612 callbacks: callbacks613 });614};615LKAPIClient.prototype.screenshotSets = function(callbacks) {616 this.send_('screenshot_sets', {617 method: 'GET',618 parse: function(data) {619 var sets = data['sets'];620 return [sets];621 },622 callbacks: callbacks623 });624};625LKAPIClient.prototype.screenshotSetAndShots = function(setId, callbacks) {626 this.send_('screenshot_sets/' + setId, {627 method: 'GET',628 parse: function(data) {629 var set = data['set'];630 var shots = data['shots'];631 return [set, shots];632 },633 callbacks: callbacks634 });635};636LKAPIClient.prototype.deleteScreenshotSet = function(setId, callbacks) {637 this.send_('screenshot_sets/' + setId + '/delete', {638 method: 'POST',639 callbacks: callbacks640 })641};642LKAPIClient.prototype.updateScreenshotSet = function(setId, fields, callbacks) {643 this.send_('screenshot_sets/' + setId, {644 method: 'POST',645 params: fields,646 parse: function(data) {647 return [data['set']];648 },649 callbacks: callbacks650 })651};652LKAPIClient.prototype.duplicateScreenshotSet = function(setId, name, version, platform, callbacks) {653 this.send_('screenshot_sets/' + setId + '/duplicate', {654 method: 'POST',655 params: {'name': name, 'version': version, 'platform': platform},656 parse: function(data) {657 return [data['set']];658 },659 callbacks: callbacks660 });661};662LKAPIClient.prototype.addScreenshotSetBundle = function(setId, hq, uploadIds, uploadNames, callbacks) {663 var qs = 'hq=' + (hq ? '1' : '0');664 for (var i = 0; i < uploadIds.length; i++) {665 qs += '&upload_id=' + encodeURIComponent(uploadIds[i]) + '&upload_name=' + encodeURIComponent(uploadNames[i]);666 }667 this.send_('screenshot_sets/' + setId + '/create_bundle', {668 method: 'POST',669 params: qs,670 parse: function(data) {671 return [data['bundleId']]672 },673 callbacks: callbacks674 });675};676LKAPIClient.prototype.screenshotSetBundleStatus = function(bundleId, callbacks) {677 this.send_('screenshot_sets/bundle_status/' + bundleId, {678 method: 'GET',679 parse: function(data) {680 return [data['status']];681 },682 callbacks: callbacks683 });684};685LKAPIClient.prototype.screenshotSetDownloadUrl = function(setId, bundleId, token, callbacks) {686 this.send_('screenshot_sets/' + setId + '/download', {687 method: 'GET',688 params: {'bundle_id': bundleId, 'token': token},689 parse: function(data) {690 return [data['downloadUrl']];691 },692 callbacks: callbacks693 });694};695LKAPIClient.prototype.addShot = function(setId, formFields, callbacks) {696 this.send_('screenshot_sets/' + setId + '/add_shot', {697 method: 'POST',698 params: formFields,699 parse: function(data) {700 var shot = data['shot'];701 return [shot];702 },703 callbacks: callbacks704 })705};706LKAPIClient.prototype.updateShot = function(setId, shotId, formFields, callbacks) {707 this.send_('screenshot_sets/' + setId + '/' + shotId, {708 method: 'POST',709 params: formFields,710 parse: function(data) {711 var shot = data['shot'];712 return [shot];713 },714 callbacks: callbacks715 });716};717LKAPIClient.prototype.deleteShot = function(setId, shotId, callbacks) {718 this.send_('screenshot_sets/' + setId + '/' + shotId + '/delete', {719 method: 'POST',720 parse: function(data) {721 var shot = data['shot'];722 return [shot];723 },724 callbacks: callbacks725 });726};727LKAPIClient.prototype.addShotOverride = function(setId, shotId, imageId, deviceType, callbacks) {728 this.send_('screenshot_sets/' + setId + '/' + shotId + '/' + deviceType, {729 method: 'POST',730 params: {'image_id':imageId},731 parse: function(data) {732 var override = data['override'];733 return [override]734 },735 callbacks: callbacks736 })737};738LKAPIClient.prototype.deleteShotOverride = function(setId, shotId, deviceType, callbacks) {739 this.send_('screenshot_sets/' + setId + '/' + shotId + '/' + deviceType + '/delete', {740 method: 'POST',741 parse: function(data) {742 var shot = data['shot'];743 return [shot]744 },745 callbacks: callbacks746 })747};748// APP WEBSITES749LKAPIClient.prototype.getAllWebsites = function(callbacks) {750 this.send_('websites', {751 method: 'GET',752 parse: function(data) {753 return [data['websites']];754 },755 callbacks: callbacks756 });757};758LKAPIClient.prototype.trackWebsiteView = function(websiteId, host, referer, userAgent, path, callbacks) {759 var params = {760 'website_id': websiteId,761 'host': host,762 'referer': referer,763 'user_agent': userAgent,764 'path': path || ''765 };766 this.send_('websites/track', {767 method: 'POST',768 params: params,769 callbacks: callbacks770 });771};772LKAPIClient.prototype.getWebsite = function(id, callbacks) {773 this.send_('websites/' + id, {774 method: 'GET',775 parse: function(data) {776 return [data['website']];777 },778 callbacks: callbacks779 });780};781LKAPIClient.prototype.getFullWebsite = function(id, callbacks) {782 this.send_('websites/' + id + '?get_website_and_pages=1', {783 method: 'GET',784 parse: function(data) {785 return [data['website']];786 },787 callbacks: callbacks788 });789};790LKAPIClient.prototype.getWebsitePage = function(id, slug, callbacks) {791 this.send_('websites/' + id + '/' + slug, {792 method: 'GET',793 parse: function(data) {794 return [data['website'], data['page']];795 },796 callbacks: callbacks797 });798};799LKAPIClient.prototype.getWebsitePageByDomain = function(domain, slug, callbacks) {800 var path = 'websites/domains/' + encodeURIComponent(domain);801 if (slug) {802 path += '/' + encodeURIComponent(slug);803 }804 this.send_(path, {805 method: 'GET',806 parse: function(data) {807 return [data['website'], data['page']];808 },809 callbacks: callbacks810 });811};812LKAPIClient.prototype.checkDomainCname = function(domain, callbacks) {813 this.send_('websites/check_domain_cname', {814 method: 'POST',815 parse: function(data) {816 return [data['correct'], data['error']];817 },818 params: {'domain': domain},819 callbacks: callbacks820 });821};822LKAPIClient.prototype.getExampleWebsite = function(itunesId, country, callbacks) {823 this.send_('websites/example', {824 method: 'POST',825 parse: function(data) {826 return [data['website']];827 },828 params: {'itunes_id': itunesId, 'country': country},829 callbacks: callbacks830 });831};832LKAPIClient.prototype.createWebsite = function(params, callbacks) {833 this.send_('websites', {834 method: 'POST',835 params: params,836 parse: function(data) {837 return [data['website']];838 },839 callbacks: callbacks840 });841};842LKAPIClient.prototype.editWebsite = function(websiteId, serializedForm, callbacks) {843 this.send_('websites/' + websiteId, {844 method: 'POST',845 params: serializedForm,846 parse: function(data) {847 return [data['website']];848 },849 callbacks: callbacks850 });851};852LKAPIClient.prototype.deleteWebsite = function(id, callbacks) {853 this.send_('websites/' + id + '/delete', {854 method: 'POST',855 callbacks: callbacks856 });857};858// SIMPLE DASH859LKAPIClient.prototype.addDashboardWithObject = function(object, callbacks) {860 this.send_('dashboards', {861 method: 'POST',862 json: object,863 parse: function(data) {864 var dashboard = data['dashboard'];865 return [dashboard];866 },867 callbacks: callbacks868 });869};870LKAPIClient.prototype.updateDashboard = function(id, updates, callbacks) {871 this.send_('dashboards/' + id, {872 method: 'POST',873 json: {'dashboard': updates},874 parse: function(data) {875 var dashboard = data['dashboard'];876 return [dashboard];877 },878 callbacks: callbacks879 });880};881LKAPIClient.prototype.dashboards = function(callbacks) {882 this.send_('dashboards', {883 method: 'GET',884 parse: function(data) {885 var dashboards = data['dashboards'];886 return [dashboards];887 },888 callbacks: callbacks889 });890};891LKAPIClient.prototype.dashboardWithId = function(dashId, callbacks) {892 this.send_('dashboards/' + dashId, {893 method: 'GET',894 parse: function(data) {895 var dashboard = data['dashboard'];896 return [dashboard];897 },898 callbacks: callbacks899 });900};901LKAPIClient.prototype.filledDashboardWithId = function(dashId, callbacks) {902 this.send_('dashboards/' + dashId + '/filled', {903 method: 'GET',904 parse: function(data) {905 var dashboard = data['dashboard'];906 return [dashboard];907 },908 callbacks: callbacks909 });910};911LKAPIClient.prototype.addMetricToDashboard = function(dashId, metricForm, callbacks) {912 this.send_('dashboards/' + dashId, {913 method: 'POST',914 json: {'metric': metricForm},915 parse: function(data) {916 var metric = data['metric'];917 return [metric];918 },919 callbacks: callbacks920 });921};922LKAPIClient.prototype.updateMetric = function(dashId, metricId, metricForm, callbacks) {923 this.send_('dashboards/' + dashId + '/' + metricId, {924 method: 'POST',925 params: metricForm,926 parse: function(data) {927 var metric = data['metric'];928 return [metric];929 },930 callbacks: callbacks931 });932};933LKAPIClient.prototype.deleteMetric = function(dashId, metricId,callbacks) {934 this.send_('dashboards/' + dashId + '/' + metricId + '/delete', {935 method: 'POST',936 callbacks: callbacks937 });938};...

Full Screen

Full Screen

GroupActions.js

Source:GroupActions.js Github

copy

Full Screen

1var AppDispatcher = require('../dispatcher/AppDispatcher');2var AppConstants = require('../constants/AppConstants');3var ApiUtils = require('../utils/ApiUtils');4var Utils = require('../utils/Utils');5var GroupActions = {6 getGroups: function(callbacks) {7 callbacks = callbacks || {};8 Utils.wrapSuccess(callbacks, function(data) {9 AppDispatcher.dispatch({10 actionType: AppConstants.GET_GROUPS,11 data: data12 });13 });14 ApiUtils.Group.getGroups({full: true}, callbacks);15 },16 getGroup: function(groupName, callbacks) {17 callbacks = callbacks || {};18 Utils.wrapSuccess(callbacks, function(data) {19 AppDispatcher.dispatch({20 actionType: AppConstants.GET_GROUP,21 data: data22 });23 });24 ApiUtils.Group.getGroup(groupName, callbacks);25 },26 setGroup: function(data, callbacks) {27 callbacks = callbacks || {};28 Utils.wrapSuccess(callbacks, function(data) {29 GroupActions.getGroups();30 });31 ApiUtils.Group.setGroup(data, callbacks);32 },33 getNodeMetrics: function(groupName, data, callbacks) {34 callbacks = callbacks || {};35 Utils.wrapSuccess(callbacks, function(data) {36 AppDispatcher.dispatch({37 actionType: AppConstants.GET_NODE_METRICS,38 groupName: groupName,39 data: data40 });41 });42 ApiUtils.Group.getNodeMetrics(groupName, data, callbacks);43 },44 setNodeMetricsQuery: function(groupName, query) {45 AppDispatcher.dispatch({46 actionType: AppConstants.SET_NODE_METRICS_QUERY,47 groupName: groupName,48 data: query49 });50 },51 setNodeMetricsQueryOnlyAutoRefresh: function(groupName, autoRefresh) {52 AppDispatcher.dispatch({53 actionType: AppConstants.SET_NODE_METRICS_QUERY_ONLY_AUTO_REFRESH,54 groupName: groupName,55 autoRefresh: autoRefresh56 });57 },58 getGroupNotice: function(groupName, callbacks) {59 callbacks = callbacks || {};60 Utils.wrapSuccess(callbacks, function(data) {61 AppDispatcher.dispatch({62 actionType: AppConstants.GET_GROUP_NOTICE,63 groupName: groupName,64 data: data65 });66 });67 ApiUtils.Group.getGroupNotice(groupName, callbacks);68 },69 setGroupNotice: function(groupName, data, callbacks) {70 callbacks = callbacks || {};71 Utils.wrapSuccess(callbacks, function(data) {72 AppDispatcher.dispatch({73 actionType: AppConstants.GET_GROUP_NOTICE,74 groupName: groupName,75 data: data76 });77 });78 ApiUtils.Group.setGroupNotice(groupName, data, callbacks);79 },80 deleteGroup: function(groupName, callbacks) {81 callbacks = callbacks || {};82 Utils.wrapSuccess(callbacks, function(data) {83 GroupActions.getGroups();84 });85 ApiUtils.Group.deleteGroup(groupName, callbacks);86 },87 deleteGroupNode: function(groupName, hostAndPort, callbacks) {88 callbacks = callbacks || {};89 Utils.wrapSuccess(callbacks, function(data) {90 AppDispatcher.dispatch({91 actionType: AppConstants.GET_GROUP,92 data: data93 });94 });95 ApiUtils.Group.deleteGroupNode(groupName, hostAndPort, callbacks);96 },97 addGroupNodes: function(groupName, data, callbacks) {98 callbacks = callbacks || {};99 Utils.wrapSuccess(callbacks, function(data) {100 AppDispatcher.dispatch({101 actionType: AppConstants.GET_GROUP,102 data: data103 });104 });105 ApiUtils.Group.addGroupNodes(groupName, data, callbacks);106 },107 changeGroupName: function(groupName, data, callbacks) {108 callbacks = callbacks || {};109 Utils.wrapSuccess(callbacks, function(data) {110 GroupActions.getGroups();111 });112 ApiUtils.Group.changeGroupName(groupName, data, callbacks);113 },114 getSlowLog: function(groupName, data, callbacks) {115 callbacks = callbacks || {};116 Utils.wrapSuccess(callbacks, function(data) {117 AppDispatcher.dispatch({118 actionType: AppConstants.GET_GROUP_SLOWLOG,119 groupName: groupName,120 data: data121 });122 });123 ApiUtils.Group.getSlowLog(groupName, data, callbacks);124 }125};...

Full Screen

Full Screen

UserActions.js

Source:UserActions.js Github

copy

Full Screen

1var AppDispatcher = require('../dispatcher/AppDispatcher');2var AppConstants = require('../constants/AppConstants');3var ApiUtils = require('../utils/ApiUtils');4var Utils = require('../utils/Utils');5var UserActions = {6 getUsers: function(callbacks) {7 callbacks = callbacks || {};8 Utils.wrapSuccess(callbacks, function(data) {9 AppDispatcher.dispatch({10 actionType: AppConstants.GET_USERS,11 data: data12 });13 });14 ApiUtils.User.getUsers(callbacks);15 },16 updateMe: function(data, callbacks) {17 callbacks = callbacks || {};18 Utils.wrapSuccess(callbacks, function(data) {19 UserActions.getUsers();20 });21 ApiUtils.User.updateMe(data, callbacks);22 },23 changePassword: function(data, callbacks) {24 callbacks = callbacks || {};25 ApiUtils.User.changePassword(data, callbacks);26 },27 addUser: function(username, data, callbacks) {28 callbacks = callbacks || {};29 Utils.wrapSuccess(callbacks, function(data) {30 UserActions.getUsers();31 });32 ApiUtils.User.addUser(username, data, callbacks);33 },34 updateUser: function(username, data, callbacks) {35 callbacks = callbacks || {};36 Utils.wrapSuccess(callbacks, function(data) {37 UserActions.getUsers();38 });39 ApiUtils.User.updateUser(username, data, callbacks);40 },41 deleteUser: function(username, callbacks) {42 callbacks = callbacks || {};43 Utils.wrapSuccess(callbacks, function(data) {44 UserActions.getUsers();45 });46 ApiUtils.User.deleteUser(username, callbacks);47 }48};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import {TestBed} from '@angular/core/testing';2import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';3import {HttpClient, HttpErrorResponse} from '@angular/common/http';4describe('HttpClient testing', () => {5 let httpClient: HttpClient;6 let httpTestingController: HttpTestingController;7 beforeEach(() => {8 TestBed.configureTestingModule({9 imports: [HttpClientTestingModule]10 });11 httpClient = TestBed.get(HttpClient);12 httpTestingController = TestBed.get(HttpTestingController);13 });14 afterEach(() => {15 httpTestingController.verify();16 });17 describe('#getHero', () => {18 let expectedHeroes: Hero[];19 beforeEach(() => {20 httpClient = TestBed.get(HttpClient);21 httpTestingController = TestBed.get(HttpTestingController);22 { id: 1, name: 'A' },23 { id: 2, name: 'B' }24 ] as Hero[];25 });26 it('should return expected heroes (called once)', () => {27 httpClient.get<Hero[]>('api/heroes')28 .subscribe(heroes => expect(heroes).toEqual(expectedHeroes, 'should return expected heroes'),29 );30 const req = httpTestingController.expectOne('api/heroes');31 expect(req.request.method).toEqual('GET');32 req.flush(expectedHeroes);33 });34 });35});36import 'zone.js/dist/zone-testing';37import { getTestBed } from '@angular/core/testing';38import {39} from '@angular/platform-browser-dynamic/testing';40getTestBed().initTestEnvironment(41 platformBrowserDynamicTesting()42);43{44 "compilerOptions": {45 },46}47module.exports = function (

Full Screen

Using AI Code Generation

copy

Full Screen

1import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';2import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';3import { ComponentFixture, TestBed } from '@angular/core/testing';4describe('TestComponent', () => {5 beforeEach(() => MockBuilder(TestComponent));6 it('should render', () => {7 const fixture = MockRender(TestComponent);8 expect(ngMocks.find('div')).toBeTruthy();9 expect(ngMocks.formatText(fixture)).toEqual('Hello world!');10 });11});12import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';13import { ComponentFixture, TestBed } from '@angular/core/testing';14describe('TestComponent', () => {15 beforeEach(() => MockBuilder(TestComponent));16 it('should render', async () => {17 const fixture = await MockRender(TestComponent);18 expect(ngMocks.find('div')).toBeTruthy();19 expect(ngMocks.formatText(fixture)).toEqual('Hello world!');20 });21});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';2import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';3import { MyComponent } from './my.component';4describe('MyComponent', () => {5 beforeEach(() => MockBuilder(MyComponent));6 it('should render', () => {7 const fixture = MockRender(MyComponent);8 expect(ngMocks.formatText(fixture)).toEqual('');9 });10});11import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';12import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';13import { MyComponent } from './my.component';14describe('MyComponent', () => {15 beforeEach(() => MockBuilder(MyComponent));16 it('should render', () => {17 const fixture = MockRender(MyComponent);18 expect(ngMocks.formatText(fixture)).toEqual('');19 });20});21import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';22import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';23import { MyComponent } from './my.component';24describe('MyComponent', () => {25 beforeEach(() => MockBuilder(MyComponent));26 it('should render', () => {27 const fixture = MockRender(MyComponent);28 expect(ngMocks.formatText(fixture)).toEqual('');29 });30});31import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';32import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';33import { MyComponent } from './my.component';34describe('MyComponent', () => {35 beforeEach(() => MockBuilder(MyComponent));36 it('should render', () => {37 const fixture = MockRender(MyComponent);38 expect(ngMocks.formatText(fixture)).toEqual('');39 });40});41import { Mock

Full Screen

Using AI Code Generation

copy

Full Screen

1var ngMocks = require('ng-mocks');2var myModule = ngMocks.module('myModule');3var myFactory = ngMocks.factory('myFactory', myModule);4var myService = ngMocks.service('myService', myModule);5myFactory.doSomething();6myService.doSomething();7myService.doSomethingElse();8var ngMocks = require('ng-mocks');9var myModule = ngMocks.module('myModule');10var myInjector = ngMocks.injector(myModule);11var myService = myInjector.get('myService');12myService.doSomething();13myService.doSomethingElse();14var ngMocks = require('ng-mocks');15var myModule = ngMocks.module('myModule');16var myProvider = ngMocks.provider('myService', myModule);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { mock, instance, when, verify, deepEqual, anything } from 'ts-mockito';2import {TestComponent} from './test.component';3import {TestService} from './test.service';4describe('TestComponent', () => {5 let component: TestComponent;6 let service: TestService;7 let mockService: TestService;8 beforeEach(() => {9 mockService = mock(TestService);10 service = instance(mockService);11 component = new TestComponent(service);12 });13 it('should create', () => {14 expect(component).toBeTruthy();15 });16 it('should get data', () => {17 const data = 'test';18 when(mockService.getData()).thenReturn(data);19 component.getData();20 verify(mockService.getData()).once();21 expect(component.data).toEqual(data);22 });23 it('should get data with params', () => {24 const data = 'test';25 const param = 'testParam';26 when(mockService.getDataWithParams(deepEqual(param))).thenReturn(data);27 component.getDataWithParams(param);28 verify(mockService.getDataWithParams(deepEqual(param))).once();29 expect(component.data).toEqual(data);30 });31 it('should get data with any param', () => {32 const data = 'test';33 when(mockService.getDataWithParams(anything())).thenReturn(data);34 component.getDataWithParams('any');35 verify(mockService.getDataWithParams(anything())).once();36 expect(component.data).toEqual(data);37 });38});39import { Injectable } from '@angular/core';40@Injectable()41export class TestService {42 constructor() { }43 getData() {44 return 'test';45 }46 getDataWithParams(param: string) {47 return 'test';48 }49}50import { Component, OnInit } from '@angular/core';51import { TestService } from './test.service';52@Component({53})54export class TestComponent implements OnInit {55 data: string;56 constructor(private service: TestService) { }57 ngOnInit() {58 }59 getData() {60 this.data = this.service.getData();61 }62 getDataWithParams(param: string) {63 this.data = this.service.getDataWithParams(param);64 }65}66 <button (click)="getData()">Get data</

Full Screen

Using AI Code Generation

copy

Full Screen

1var $injector = angular.injector(['ng', 'ngMock']);2var $httpBackend = $injector.get('$httpBackend');3$httpBackend.expectGET('/test').respond(200, {test: 'test'});4$httpBackend.whenGET('/test').respond(200, {test: 'test'});5$httpBackend.whenGET('/test').respond(200, {test: 'test'});6$httpBackend.whenGET('/test').respond(200, {test: 'test'});7$httpBackend.whenGET('/test').respond(200, {test: 'test'});8$httpBackend.whenGET('/test').respond(200, {test: 'test'});9$httpBackend.whenGET('/test').respond(200, {test: 'test'});10$httpBackend.whenGET('/test').respond(200, {test: 'test'});11$httpBackend.whenGET('/test').respond(200, {test: 'test'});12$httpBackend.whenGET('/test').respond(200, {test: 'test'});13$httpBackend.whenGET('/test').respond(200, {test: 'test'});14$httpBackend.whenGET('/test').respond(200, {test: 'test'});15$httpBackend.whenGET('/test').respond(200, {test: 'test'});16$httpBackend.whenGET('/test').respond(200, {test: 'test'});17$httpBackend.whenGET('/test').respond(200, {test: 'test'});18$httpBackend.whenGET('/test').respond(200, {test: 'test'});19$httpBackend.whenGET('/test').respond(200, {test: 'test'});20$httpBackend.whenGET('/test').respond(200, {test: 'test'});21$httpBackend.whenGET('/test').respond(200, {test: 'test'});22$httpBackend.whenGET('/test').respond(200, {test: 'test'});23$httpBackend.whenGET('/test').respond(200, {test: 'test'});24$httpBackend.whenGET('/test').respond(200, {test: 'test'});25$httpBackend.whenGET('/test').respond(200, {test: 'test'});26$httpBackend.whenGET('/test').respond(200, {test: 'test'});27$httpBackend.whenGET('/test').respond(200, {test: 'test'});28$httpBackend.whenGET('/test').respond(200, {test: 'test'});29$httpBackend.whenGET('/test').respond(200, {test: 'test

Full Screen

Using AI Code Generation

copy

Full Screen

1var ngMocks = require('ng-mocks');2var mockModule = ngMocks.module;3var mockInject = ngMocks.inject;4var mockController = ngMocks.controller;5var mockDirective = ngMocks.directive;6var mockComponent = ngMocks.component;7var mockService = ngMocks.service;8var mockFactory = ngMocks.factory;9var mockProvider = ngMocks.provider;10var mockFilter = ngMocks.filter;11var mockValue = ngMocks.value;12var mockConstant = ngMocks.constant;13var mockDecorator = ngMocks.decorator;14var mockConfig = ngMocks.config;15var mockRun = ngMocks.run;16var mockFactory = ngMocks.factory;

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 ng-mocks 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