Best JavaScript code snippet using jest
card.js
Source:card.js
1(function () {2 'use strict';3 var services = angular.module('lavagna.services');4 var extractData = function (data) {5 return data.data;6 };7 var extractActionLists = function (data) {8 var rawData = data.data;9 var actionLists = {lists: [], items: {}};10 for (var i = 0; i < rawData.length; i++) {11 // if it's a list, push it to the array12 if (rawData[i].type === 'ACTION_LIST') { actionLists.lists.push(rawData[i]); }13 // if it's an item, check if the array already exists, and then push into it14 if (rawData[i].type === 'ACTION_CHECKED' || rawData[i].type === 'ACTION_UNCHECKED') {15 if (actionLists.items[rawData[i].referenceId] === undefined) { actionLists.items[rawData[i].referenceId] = []; }16 actionLists.items[rawData[i].referenceId].push(rawData[i]);17 }18 }19 return actionLists;20 };21 var isInCardLabels = function (cardLabels, labelName, currentUserId) {22 if (cardLabels === undefined || cardLabels.length === 0) { return false; } // empty, no labels at all23 for (var i = 0; i < cardLabels.length; i++) {24 if (cardLabels[i].labelName === labelName && cardLabels[i].labelDomain === 'SYSTEM' && cardLabels[i].value.valueUser === currentUserId) {25 return true;26 }27 }28 return false;29 };30 // FIXME: useless parameters, check one by one31 services.factory('Card', function ($http, $window, FileUploader) {32 return {33 findCardByBoardShortNameAndSeqNr: function (shortName, seqNr) {34 return $http.get('api/card-by-seq/' + shortName + '-' + seqNr).then(extractData);35 },36 findCardById: function (id) {37 return $http.get('api/card/' + id).then(extractData);38 },39 findCardsByMilestone: function (projectName) {40 function insertStatusIfExists(milestone, source, target, status) {41 if (source[status] !== undefined) {42 target[target.length] = {status: status, count: source[status]};43 milestone.totalCards += source[status];44 }45 }46 function orderByStatus(milestone) {47 milestone.totalCards = 0;48 var sorted = [];49 insertStatusIfExists(milestone, milestone.cardsCountByStatus, sorted, 'BACKLOG');50 insertStatusIfExists(milestone, milestone.cardsCountByStatus, sorted, 'OPEN');51 insertStatusIfExists(milestone, milestone.cardsCountByStatus, sorted, 'DEFERRED');52 insertStatusIfExists(milestone, milestone.cardsCountByStatus, sorted, 'CLOSED');53 return sorted;54 }55 return $http.get('api/project/' + projectName + '/cards-by-milestone').then(extractData).then(function (response) {56 response.cardsCountByStatus = {};57 angular.forEach(response.milestones, function (milestone) {58 response.cardsCountByStatus[milestone.labelListValue.id] = orderByStatus(milestone);59 });60 return response;61 });62 },63 findCardsByMilestoneDetail: function (projectName, milestoneId) {64 return $http.get('api/project/' + projectName + '/cards-by-milestone-detail/' + milestoneId).then(extractData);65 },66 findByColumn: function (columnId) {67 return $http.get('api/column/' + columnId + '/card').then(extractData);68 },69 moveAllFromColumnToLocation: function (columnId, cardIds, location) {70 return $http.post('api/card/from-column/' + columnId + '/to-location/' + location, {cardIds: cardIds}).then(extractData);71 },72 update: function (id, name) {73 return $http.post('api/card/' + id, {name: name}).then(extractData);74 },75 description: function (id) {76 return $http.get('api/card/' + id + '/description').then(extractData);77 },78 clone: function (cardId, columnId) {79 return $http.post('api/card/' + cardId + '/clone-to/column/' + columnId).then(extractData);80 },81 updateDescription: function (id, description) {82 return $http.post('api/card/' + id + '/description', {content: description}).then(extractData);83 },84 comments: function (id) {85 return $http.get('api/card/' + id + '/comments').then(extractData);86 },87 addComment: function (id, comment) {88 return $http.post('api/card/' + id + '/comment', comment).then(extractData);89 },90 updateComment: function (commentId, comment) {91 return $http.post('api/card-data/comment/' + commentId, comment).then(extractData);92 },93 deleteComment: function (commentId) {94 return $http['delete']('api/card-data/comment/' + commentId).then(extractData);95 },96 undoDeleteComment: function (eventId) {97 return $http.post('api/card-data/undo/' + eventId + '/comment', null).then(extractData);98 },99 //100 actionLists: function (id) {101 return $http.get('api/card/' + id + '/actionlists').then(extractActionLists);102 },103 addActionList: function (id, actionList) {104 return $http.post('api/card/' + id + '/actionlist', {content: actionList}).then(extractData);105 },106 updateActionList: function (itemId, content) {107 return $http.post('api/card-data/actionlist/' + itemId + '/update', {content: content}).then(extractData);108 },109 deleteActionList: function (itemId) {110 return $http['delete']('api/card-data/actionlist/' + itemId).then(extractData);111 },112 undoDeleteActionList: function (eventId) {113 return $http.post('api/card-data/undo/' + eventId + '/actionlist', null).then(extractData);114 },115 addActionItem: function (referenceId, actionItem) {116 return $http.post('api/card-data/actionlist/' + referenceId + '/item', {content: actionItem}).then(extractData);117 },118 toggleActionItem: function (itemId, status) {119 return $http.post('api/card-data/actionitem/' + itemId + '/toggle/' + status, null).then(extractData);120 },121 updateActionItem: function (itemId, content) {122 return $http.post('api/card-data/actionitem/' + itemId + '/update', {content: content}).then(extractData);123 },124 deleteActionItem: function (itemId) {125 return $http['delete']('api/card-data/actionitem/' + itemId).then(extractData);126 },127 undoDeleteActionItem: function (eventId) {128 return $http.post('api/card-data/undo/' + eventId + '/actionitem', null).then(extractData);129 },130 updateActionItemOrder: function (listId, order) {131 return $http.post('api/card-data/actionlist/' + listId + '/order', order).then(extractData);132 },133 updateActionListOrder: function (cardId, order) {134 return $http.post('api/card/' + cardId + '/order/actionlist', order).then(extractData);135 },136 moveActionItem: function (itemId, newActionList, sortedActionLists) {137 return $http.post('api/card-data/actionitem/' + itemId + '/move-to-actionlist/' + newActionList, sortedActionLists).then(extractData);138 },139 files: function (id) {140 return $http.get('api/card/' + id + '/files').then(extractData);141 },142 getMaxFileSize: function () {143 return $http.get('api/configuration/max-upload-file-size').then(extractData);144 },145 getFileUploader: function (cardId) {146 return new FileUploader({147 url: 'api/card/' + cardId + '/file',148 alias: 'files',149 autoUpload: true,150 headers: { 'x-csrf-token': $window.csrfToken }151 });152 },153 getNewCardFileUploader: function () {154 return new FileUploader({155 url: 'api/card/file',156 alias: 'files',157 autoUpload: true,158 headers: { 'x-csrf-token': $window.csrfToken }159 });160 },161 deleteFile: function (cardDataId) {162 return $http['delete']('api/card-data/file/' + cardDataId, null).then(extractData);163 },164 undoDeleteFile: function (eventId) {165 return $http.post('api/card-data/undo/' + eventId + '/file').then(extractData);166 },167 activity: function (cardId) {168 return $http.get('api/card/' + cardId + '/activity').then(extractData);169 },170 activityData: function (id) {171 return $http.get('api/card-data/activity/' + id).then(extractData);172 },173 isWatchedByUser: function (labels, userId) {174 return isInCardLabels(labels, 'WATCHED_BY', userId);175 },176 isAssignedToUser: function (labels, userId) {177 return isInCardLabels(labels, 'ASSIGNED', userId);178 }179 };180 });...
project.js
Source:project.js
1(function () {2 'use strict';3 var services = angular.module('lavagna.services');4 var extractData = function (data) {5 return data.data;6 };7 var extractMetadata = function (data) {8 var metadata = data.data;9 // provide better format for some data10 metadata.milestones = [];11 metadata.userLabels = [];12 angular.forEach(metadata.labels, function (label, labelId) {13 if (label.name === 'MILESTONE') {14 angular.forEach(metadata.labelListValues, function (labelValue) {15 if (labelValue.cardLabelId === label.id) {16 metadata.milestones.push({17 id: labelValue.id,18 labelId: labelId,19 name: labelValue.value,20 status: labelValue.metadata.status || null,21 metadata: labelValue.metadata,22 order: labelValue.order23 });24 }25 });26 }27 if (label.domain === 'USER') {28 metadata.userLabels.push(label);29 }30 });31 return metadata;32 };33 services.factory('Project', function ($http, $filter, StompClient) {34 return {35 // ordered by archived, name36 list: function () {37 return $http.get('api/project').then(extractData).then(function (res) {38 return $filter('orderBy')(res, function (elem) {39 return (elem.archived ? '1' : '0') + elem.shortName;40 });41 });42 },43 create: function (project) {44 return $http.post('api/project', project).then(extractData);45 },46 update: function (project) {47 return $http.post('api/project/' + project.shortName, {48 name: project.name,49 description: project.description,50 isArchived: project.archived51 }).then(extractData);52 },53 suggestShortName: function (name) {54 return $http.get('api/suggest-project-short-name', {params: {name: name}}).then(extractData);55 },56 checkShortName: function (name) {57 return $http.get('api/check-project-short-name', {params: {name: name.toUpperCase()}}).then(extractData).then(function (res) {58 return res === true;59 });60 },61 findByShortName: function (shortName) {62 return $http.get('api/project/' + shortName).then(extractData);63 },64 createBoard: function (shortName, board) {65 return $http.post('api/project/' + shortName + '/board', board).then(extractData);66 },67 findBoardsInProject: function (shortName) {68 return $http.get('api/project/' + shortName + '/board').then(extractData).then(function (res) {69 return $filter('orderBy')(res, function (elem) {70 return (elem.archived ? '1' : '0') + elem.shortName;71 });72 });73 },74 columnsDefinition: function (shortName) {75 return $http.get('api/project/' + shortName + '/definitions').then(extractData);76 },77 taskStatistics: function (shortName) {78 return $http.get('api/project/' + shortName + '/task-statistics').then(extractData);79 },80 statistics: function (shortName, days) {81 return $http.get('api/project/' + shortName + '/statistics/' + days).then(extractData);82 },83 getMetadata: function (shortName) {84 return $http.get('api/project/' + shortName + '/metadata').then(extractMetadata);85 },86 getAvailableTrelloBoards: function (trello) {87 return $http.post('/api/import/trello/boards', trello).then(extractData);88 },89 importFromTrello: function (trello) {90 return $http.post('api/import/trello/', trello).then(extractData);91 },92 updateColumnDefinition: function (shortName, definition, color) {93 return $http.put('api/project/' + shortName + '/definition', {94 definition: definition,95 color: color96 }).then(extractData);97 },98 findAllColumns: function (shortName) {99 return $http.get('api/project/' + shortName + '/columns-in/').then(extractData);100 },101 loadMetadataAndSubscribe: function (shortName, targetObject, assignToMap) {102 var Project = this;103 function loadProjectMetadata() {104 Project.getMetadata(shortName).then(function (metadata) {105 metadata = extractMetadata({data: metadata});106 if (assignToMap) {107 targetObject[shortName] = metadata;108 } else {109 targetObject.metadata = metadata;110 }111 });112 }113 loadProjectMetadata();114 return StompClient.subscribe('/event/project/' + shortName, function (ev) {115 if (ev.body === '"PROJECT_METADATA_HAS_CHANGED"') {116 loadProjectMetadata();117 }118 });119 },120 gridByDescription: function (items, skipArchived) {121 var itemsLeft = [];122 var itemsRight = [];123 var rightCount = 0;124 var leftCount = 0;125 for (var i = 0; i < items.length; i++) {126 var item = items[i].project || items[i];127 if (skipArchived && item.archived) {128 continue;129 }130 var descriptionCount = item.description !== null ? item.description.length : 0;131 if (descriptionCount > 0) {132 var newLineMatch = item.description.match(/[\n\r]/g);133 descriptionCount += newLineMatch !== null ? newLineMatch.length * 50 : 0;134 }135 if (leftCount <= rightCount) {136 leftCount += descriptionCount;137 itemsLeft.push(items[i]);138 } else {139 rightCount += descriptionCount;140 itemsRight.push(items[i]);141 }142 }143 return {144 left: itemsLeft,145 right: itemsRight146 };147 },148 getMailConfigs: function (shortName) {149 return $http.get('/api/project/' + shortName + '/mailConfigs').then(extractData);150 },151 createMailConfig: function (shortName, name, config, subject, body) {152 return $http.post('/api/project/' + shortName + '/mailConfig', {153 name: name,154 config: config,155 subject: subject,156 body: body157 }).then(extractData);158 },159 updateMailConfig: function (shortName, id, name, enabled, config, subject, body) {160 return $http.post('/api/project/' + shortName + '/mailConfig/' + id, {161 name: name,162 enabled: enabled,163 config: config,164 subject: subject,165 body: body166 }).then(extractData);167 },168 deleteMailConfig: function (shortName, id) {169 return $http['delete']('/api/project/' + shortName + '/mailConfig/' + id).then(extractData);170 },171 createMailTicket: function (shortName, name, alias, sendByAlias, overrideNotification, subject, body, columnId, configId, metadata) {172 return $http.post('/api/project/' + shortName + '/ticketConfig', {173 name: name,174 alias: alias,175 sendByAlias: sendByAlias,176 overrideNotification: overrideNotification,177 subject: subject,178 body: body,179 columnId: columnId,180 configId: configId,181 metadata: metadata182 }).then(extractData);183 },184 updateMailTicket: function (shortName, id, name, enabled, alias, sendByAlias, overrideNotification, subject, body, columnId, configId, metadata) {185 return $http.post('/api/project/' + shortName + '/ticketConfig/' + id, {186 name: name,187 enabled: enabled,188 alias: alias,189 sendByAlias: sendByAlias,190 overrideNotification: overrideNotification,191 subject: subject,192 body: body,193 columnId: columnId,194 configId: configId,195 metadata: metadata196 }).then(extractData);197 },198 deleteMailTicket: function (shortName, id) {199 return $http['delete']('/api/project/' + shortName + '/ticketConfig/' + id).then(extractData);200 }201 };202 });...
board.js
Source:board.js
1(function () {2 'use strict';3 var services = angular.module('lavagna.services');4 var extractData = function (data) {5 return data.data;6 };7 services.factory('Board', function ($http) {8 return {9 findByShortName: function (shortName) {10 return $http.get('api/board/' + shortName).then(extractData);11 },12 suggestShortName: function (name) {13 return $http.get('api/suggest-board-short-name', {params: {name: name}}).then(extractData);14 },15 checkShortName: function (name) {16 return $http.get('api/check-board-short-name', {params: {name: name.toUpperCase()}}).then(extractData).then(function (res) {17 return res === true;18 });19 },20 update: function (board) {21 return $http.post('api/board/' + board.shortName, {22 name: board.name,23 description: board.description,24 isArchived: board.archived25 }).then(extractData);26 },27 // TODO column: move to another service28 column: function (id) {29 return $http.get('api/column/' + id).then(extractData);30 },31 moveColumnToLocation: function (id, location) {32 return $http.post('api/column/' + id + '/to-location/' + location).then(extractData);33 },34 columns: function (shortName) {35 return $http.get('api/board/' + shortName + '/columns-in').then(extractData);36 },37 columnsByLocation: function (shortName, location) {38 return $http.get('api/board/' + shortName + '/columns-in/' + location).then(extractData);39 },40 createColumn: function (shortName, createColumn) {41 return $http.post('api/board/' + shortName + '/column',42 createColumn).then(extractData);43 },44 reorderColumn: function (shortName, location, orderedColumnId) {45 return $http.post('api/board/' + shortName + '/columns-in/' + location + '/column/order',46 orderedColumnId).then(extractData);47 },48 // FIXME remove shortName parameter49 renameColumn: function (shortName, columnId, newName) {50 return $http.post(51 'api/column/' + columnId + '/rename/' + newName).then(extractData);52 },53 // FIXME remove shortName parameter54 redefineColumn: function (shortName, columnId, definition) {55 return $http.post(56 'api/column/' + columnId + '/redefine/' + definition).then(extractData);57 },58 cardsInLocationPaginated: function (shortName, location, page) {59 return $http.get('api/board/' + shortName + '/cards-in/' + location + '/' + page).then(extractData);60 },61 createCard: function (columnId, createCard) {62 return $http.post('api/column/' + columnId + '/card', createCard).then(extractData);63 },64 createCardFromTop: function (columnId, createCard) {65 return $http.post('api/column/' + columnId + '/card-top', createCard).then(extractData);66 },67 moveCardToColumn: function (cardId, previousColumnId, newColumnId, columnOrders) {68 return $http.post('api/card/' + cardId + '/from-column/' + previousColumnId + '/to-column/' + newColumnId, columnOrders)69 .then(extractData);70 },71 moveCardToColumnEnd: function (cardId, previousColumnId, newColumnId) {72 return $http.post('api/card/' + cardId + '/from-column/' + previousColumnId + '/to-column/' + newColumnId + '/end')73 .then(extractData);74 },75 // FIXME remove shortName parameter76 updateCardOrder: function (shortName, columnId, cardIds) {77 return $http.post('api/column/' + columnId + '/order', cardIds).then(extractData);78 },79 // FIXME remove shortName parameter80 taskStatistics: function (shortName) {81 return $http.get('api/board/' + shortName + '/task-statistics').then(extractData);82 },83 // FIXME remove shortName parameter84 statistics: function (shortName, days) {85 return $http.get('api/board/' + shortName + '/statistics/' + days).then(extractData);86 }87 };88 });...
search1.js
Source:search1.js
1import Like from "./modals/like";2import Search from "./modals/Search";3import { elements } from "./views/assets";4import * as searchView from "./views/searchView";5// import Like from "./modals/like";6// import * as search1 from './modals/Search';7const event = {};8if(localStorage.getItem("array")===null){9 event.like=new Like();}10const ExtractData = async (query) => {11 12// Clear the Search13searchView.clearSearch();14// Clear previous data15searchView.clearPrevData();16 17// Create object of Search18event.search = new Search(query);19// Create Loader20 searchView.addLoader();21// Do async call22 await event.search.getOutput();23 // Delete Loader24 searchView.deleteLoader();25 // Print data26 console.log(event.search.result);27 searchView.printData(event.search.result);28};29elements.main.addEventListener('click',(e)=>{30 31 if(e.target.matches(".like"))32 { 33 searchView.updateChanges(event.search.result,e.target);34 }35})36window.addEventListener("load", () => {37 let a = localStorage.getItem("element");38 if(a){39 if (a !== "") {40 localStorage.removeItem("element");41 ExtractData(a);42 }43}44else if(localStorage.getItem("photo1"))45{46 let b=localStorage.getItem("photo1");47 localStorage.removeItem("photo1");48 ExtractData(b);49}50else if(localStorage.getItem("photo2"))51{52 let b=localStorage.getItem("photo2");53 localStorage.removeItem("photo2");54 ExtractData(b);55}56else if(localStorage.getItem("photo3"))57{58 let b=localStorage.getItem("photo3");59 localStorage.removeItem("photo3");60 ExtractData(b);61}62else if(localStorage.getItem("photo4"))63{64 let b=localStorage.getItem("photo4");65 localStorage.removeItem("photo4");66 ExtractData(b);67}68else if(localStorage.getItem("photo5"))69{70 let b=localStorage.getItem("photo5");71 localStorage.removeItem("photo5");72 ExtractData(b);73}74else if(localStorage.getItem("photo6"))75{76 let b=localStorage.getItem("photo6");77 localStorage.removeItem("photo6");78 ExtractData(b);79}80else if(localStorage.getItem("photo7"))81{82 let b=localStorage.getItem("photo7");83 localStorage.removeItem("photo7");84 ExtractData(b);85}86else if(localStorage.getItem("photo8"))87{88 let b=localStorage.getItem("photo8");89 localStorage.removeItem("photo8");90 ExtractData(b);91}92else if(localStorage.getItem("photo9"))93{94 let b=localStorage.getItem("photo9");95 localStorage.removeItem("photo9");96 ExtractData(b);97}98else if(localStorage.getItem("photo10"))99{100 let b=localStorage.getItem("photo10");101 localStorage.removeItem("photo10");102 ExtractData(b);103}104else if(localStorage.getItem("photo11"))105{106 let b=localStorage.getItem("photo11");107 localStorage.removeItem("photo11");108 ExtractData(b);109}110else if(localStorage.getItem("photo12"))111{112 let b=localStorage.getItem("photo12");113 localStorage.removeItem("photo12");114 ExtractData(b);115}116else if(localStorage.getItem("photo13"))117{118 let b=localStorage.getItem("photo13");119 localStorage.removeItem("photo13");120 ExtractData(b);121}122else if(localStorage.getItem("photo14"))123{124 let b=localStorage.getItem("photo14");125 localStorage.removeItem("photo14");126 ExtractData(b);127}128else if(localStorage.getItem("photo15"))129{130 let b=localStorage.getItem("photo15");131 localStorage.removeItem("photo15");132 ExtractData(b);133}134else if(localStorage.getItem("like-redirect"))135{136 let b=localStorage.getItem("like-redirect");137 localStorage.removeItem("like-redirect");138 ExtractData(b);139}140else if(localStorage.getItem("like-search-data"))141{142 let b=localStorage.getItem("like-search-data");143 localStorage.removeItem("like-search-data");144 ExtractData(b);145}146});147const doSomething=()=>{148 const query=searchView.data1();149 ExtractData(query);150}151elements.search1.addEventListener("click", () => {152 doSomething();153});154document.addEventListener("keypress", function (e) {155 if (e.keyCode === 13) {156 doSomething();157 }...
index.js
Source:index.js
1import axios from "axios";2export const ApiClient = axios.create({3 // baseURL: process.env.API_URL,4 // baseURL: "https://api.hwaseon2.com:5000",5 baseURL: process.env.VUE_APP_API_URL,6});7const extractData = (res) => res.data;8export const fetchPublishCount = (keyword, startDate, endDate) =>9 ApiClient.get("api/v1/keyword-services/publish-count", {10 params: {11 keyword,12 startDate,13 endDate,14 },15 }).then(extractData);16export const fetchSearchSectionOrder = (keyword) =>17 ApiClient.get("api/v1/keyword-services/search-section-order", {18 params: { keyword },19 }).then(extractData);20export const fetchRelKeywordStatistics = (keyword, month) =>21 ApiClient.get("api/v1/keyword-services/relkeyword-search-statistics", {22 params: { keyword, month },23 }).then(extractData);24export const fetchRelativeRatio = (keywords, startDate, endDate) =>25 ApiClient.get("api/v1/keyword-services/relative", {26 params: { keywords, startDate, endDate },27 }).then(extractData);28export const fetchNaverCategory = (categoryId) =>29 ApiClient.get("api/v1/proxy-services/get-search-category", {30 params: { categoryId },31 }).then(extractData);32 33export const fetchNaverSearchRelatedKeywords = (keyword) =>34 ApiClient.get("/api/v1/keyword-services/naver-search-related", {35 params: { keyword },36 }).then(extractData);37export const fetchNaverSearchAutocompleteKeywords = (keyword) =>38 ApiClient.get("api/v1/keyword-services/naver-search-autocomplete", {39 params: { keyword },40 }).then(extractData);41export const fetchNaverShoppingAutocompleteKeywords = (keyword) =>42 ApiClient.get("api/v1/keyword-services/naver-shopping-autocomplete", {43 params: { keyword },44 }).then(extractData);45export const fetchCategoryShoppingTrendingKeywords = (46 categoryId,47 startDate,48 endDate49) =>50 ApiClient.get(51 "api/v1/proxy-services/get-category-shopping-trending-keywords",52 {53 params: { categoryId, startDate, endDate },54 }55 ).then(extractData);56export const fetchNaverShoppingProducts = (keyword) =>57 ApiClient.get("api/v1/keyword-services/get-naver-shopping-products", {58 params: { keyword },59 }).then(extractData);60// Blog61export const fetchBlogPosts = (blogId) =>62 ApiClient.get("api/v1/blog-services/get-blog-posts", {63 params: { blogId },64 }).then(extractData);65export const fetchHashTags = (blogId, postId) =>66 ApiClient.get("api/v1/keyword-services/get-blog-post-hashtags", {67 params: { blogId, postId },68 }).then(extractData);69export const fetchBlogPostSearchRank = (keyword, postId) =>70 ApiClient.get(71 "api/v1/keyword-services/get-blog-post-naver-main-search-rank",72 { params: { keyword, postId } }73 ).then(extractData);74export const fetchProductRankWithinKeywordsCoupang = (keywords, productUrl) =>75 ApiClient.post(76 "/api/v1/product-services/get-product-rank-within-keywords/coupang",77 {78 keywords,79 productUrl,80 }81 ).then(extractData);82export const fetchProductRankWithinKeywordsNaver = (keywords, productUrl) =>83 ApiClient.post(84 "/api/v1/product-services/get-product-rank-within-keywords/naver",85 {86 keywords,87 productUrl,88 }89 ).then(extractData);90export const fetchNaverShoppingProductCount = (keyword) =>91 ApiClient.get("/api/v1/keyword-services/naver-shopping-product-count", {92 params: { keyword },93 }).then(extractData);94export const fetchNaverShoppingKeywordCategory = (keyword) =>95 ApiClient.get(96 "/api/v1/category-services/get-naver-shopping-keyword-category",97 { params: { keyword } }98 ).then(extractData);99export const fetchKeywordGraphStatistics = (100 keyword,101 categoryId,102 startDate,103 endDate,104 timeUnit105) =>106 ApiClient.get("/api/v1/keyword-services/fetch_keyword_graph_statistics", {107 params: { categoryId, startDate, timeUnit, keyword, endDate },...
admin.js
Source:admin.js
1(function () {2 'use strict';3 var services = angular.module('lavagna.services');4 var extractData = function (data) {5 return data.data;6 };7 services.factory('Admin', function ($http, $window, FileUploader) {8 return {9 endpointInfo: function () {10 return $http.get('api/admin/endpoint-info').then(extractData);11 },12 findAllConfiguration: function () {13 return $http.get('api/application-configuration/').then(extractData);14 },15 findByKey: function (key) {16 return $http.get('api/application-configuration/' + key).then(extractData);17 },18 updateConfiguration: function (values) {19 return $http.post('api/application-configuration/', values).then(extractData);20 },21 updateKeyConfiguration: function (k, v) {22 return $http.post('api/application-configuration/', {toUpdateOrCreate: [{first: k, second: v}]}).then(extractData);23 },24 deleteKeyConfiguration: function (key) {25 return $http['delete']('api/application-configuration/' + key).then(extractData);26 },27 checkLdap: function (ldap, usernameAndPwd) {28 return $http.post('api/check-ldap/', angular.extend({}, ldap, usernameAndPwd)).then(extractData);29 },30 getImportUsersUploader: function () {31 return new FileUploader({32 url: 'api/user/bulk-insert',33 autoUpload: false,34 headers: { 'x-csrf-token': $window.csrfToken }35 });36 },37 getImportDataUploader: function () {38 return new FileUploader({39 url: 'api/import/lavagna',40 autoUpload: false,41 headers: { 'x-csrf-token': $window.csrfToken }42 });43 },44 // ----45 findAllLoginHandlers: function () {46 return $http.get('api/login/all').then(extractData);47 },48 findAllOauthProvidersInfo: function () {49 return $http.get('api/login/oauth/all').then(extractData);50 },51 findAllBaseLoginWithActivationStatus: function () {52 return $http.get('api/login/all-base-with-activation-status').then(extractData);53 },54 testSmtpConfig: function (configuration, to) {55 return $http.post('api/check-smtp/', configuration, {params: {to: to}});56 }57 };58 });...
LambdaTest’s Jest Testing Tutorial covers step-by-step guides around Jest with code examples to help you be proficient with the Jest framework. The Jest tutorial has chapters to help you learn right from the basics of Jest framework to code-based tutorials around testing react apps with Jest, perform snapshot testing, import ES modules and more.
|<p>it('check_object_of_Car', () => {</p><p>
expect(newCar()).toBeInstanceOf(Car);</p><p>
});</p>|
| :- |
Get 100 minutes of automation test minutes FREE!!