Best JavaScript code snippet using cucumber-gherkin
eosapi.js
Source:eosapi.js
...7 lower_bound: "",8 upper_bound: "",9 limit: 10010 }11 return eosApi.getTableRows(params)12}13export const apiGetProfitsRows = (eosApi, account) => {14 let params = {15 json: true,16 code: "huskeyrecord",17 scope: "huskeyrecord",18 table: "profits",19 lower_bound: account,20 upper_bound: account,21 limit: 122 }23 return eosApi.getTableRows(params)24}25export const apiGetDelBandwidthRows = (eosApi, account, limit) => {26 let params = {27 json: true,28 code: "eosio",29 scope: account,30 table: "delband",31 limit: limit,32 lower_bound: 0,33 uppper_bound: -134 }35 return eosApi.getTableRows(params)36}37export const apiGetRexfundsRows = (eosApi, account) => {38 let params = {39 json: true,40 code: "eosio",41 scope: account,42 table: "refunds",43 limit: 10,44 lower_bound: 0,45 uppper_bound: -146 }47 return eosApi.getTableRows(params)48}49export const apiGetRexOrderRows = (eosApi, account, limit) => {50 let params = {51 json: true,52 code: "eosio",53 scope: "eosio",54 table: "rexbal",55 lower_bound: account,56 upper_bound: null,57 index_position: 1,58 key_type: "i64",59 limit: 160 }61 return eosApi.getTableRows(params)62}63export const apiGetRexPoolRows = (eosApi) => {64 let params = {65 json: true,66 code: "eosio",67 scope: "eosio",68 table: "rexpool",69 table_key: "",70 lower_bound: "",71 upper_bound: "",72 limit: 173 }74 return eosApi.getTableRows(params)75}76export const apiGetRexfundRows = (eosApi, account) => {77 let params = {78 json: true,79 code: "eosio",80 scope: "eosio",81 table: "rexfund",82 table_key: "",83 lower_bound: account,84 upper_bound: "",85 limit: 186 }87 return eosApi.getTableRows(params)88}89export const apiGetNamebidsRows = (eosApi) => {90 let params = {91 json: true,92 code: "eosio",93 scope: "eosio",94 table: "namebids",95 table_key: null,96 lower_bound: null,97 upper_bound: null,98 key_type: "i64",99 index_position: 2,100 limit: 50101 }102 return eosApi.getTableRows(params)103}104export const apiSearchBidRows = (newname, eosApi) => {105 let params = {106 json: true,107 code: "eosio",108 scope: "eosio",109 table: "namebids",110 table_key: null,111 upper_bound: newname,112 lower_bound: newname,113 key_type: "i64",114 index_position: 1,115 limit: 1116 }117 return eosApi.getTableRows(params)118}119export const apiGetBidSuccessRows = (eosApi) => {120 let params = {121 json: true,122 code: bidnameContract,123 scope: bidnameContract,124 table: "bidsuccess",125 table_key: null,126 lower_bound: null,127 upper_bound: null,128 key_type: "i64",129 index_position: 2,130 limit: 50131 }132 return eosApi.getTableRows(params)133}134export const apiGetBidOrderRows = (scope,eosApi) => {135 let params = {136 json: true,137 code: bidnameContract,138 scope: scope,139 table: "bidorders",140 table_key: null,141 lower_bound: null,142 upper_bound: null,143 key_type: "i64",144 index_position: 2,145 limit: 50146 }147 return eosApi.getTableRows(params)148}149export const apiGetNewBidnameRows = (scope, eosApi) => {150 let params = {151 json: true,152 code: newBidnameContract,153 scope: scope,154 table: "namebids",155 table_key: null,156 upper_bound: null,157 lower_bound: null,158 key_type: "i64",159 index_position: 2,160 limit: 100161 }162 return eosApi.getTableRows(params)163}164export const apiSearchNewBidnameRows = (newname, scope, eosApi) => {165 let params = {166 json: true,167 code: newBidnameContract,168 scope: scope,169 table: "namebids",170 table_key: null,171 upper_bound: newname,172 lower_bound: newname,173 key_type: "i64",174 index_position: 1,175 limit: 1176 }177 return eosApi.getTableRows(params)178}179export const apiGetNewBidRewardsRows = (newname, eosApi) => {180 let params = {181 json: true,182 code: newBidnameContract,183 scope: newname,184 table: "bidrewards",185 table_key: null,186 lower_bound: null,187 upper_bound: null,188 key_type: "i64",189 index_position: 2,190 limit: 200191 }192 return eosApi.getTableRows(params)193}194export const apiGetNewBidSuccessRows = (eosApi) => {195 let params = {196 json: true,197 code: newBidnameContract,198 scope: newBidnameContract,199 table: "bidsuccess",200 table_key: null,201 lower_bound: null,202 upper_bound: null,203 key_type: "i64",204 index_position: 2,205 limit: 50206 }207 return eosApi.getTableRows(params)208}209export const apiGetNewBidOrderRows = (scope, eosApi) => {210 let params = {211 json: true,212 code: newBidnameContract,213 scope: scope,214 table: "bidorders",215 table_key: null,216 lower_bound: null,217 upper_bound: null,218 key_type: "i64",219 index_position: 2,220 limit: 50221 }222 return eosApi.getTableRows(params)223}224export const apiGetNewBidNameInfoRows = (eosApi) => {225 let params = {226 json: true,227 code: newBidnameContract,228 scope: newBidnameContract,229 table: "nameinfos",230 table_key: null,231 lower_bound: null,232 upper_bound: null,233 limit: 50234 }235 return eosApi.getTableRows(params)236}237/*export const apiGetYASSalesRows = (eosApi) => {238 let params = {239 json: true,240 code: newBidnameContract,241 scope: newBidnameContract,242 table: "bidname11",243 table_key: null,244 upper_bound: null,245 lower_bound: null,246 key_type: "i64",247 index_position: 2,248 limit: 100249 }250 return eosApi.getTableRows(params)251}252export const apiGetIBTSalesRows = (eosApi) => {253 let params = {254 json: true,255 code: newBidnameContract,256 scope: newBidnameContract,257 table: "bidname22",258 table_key: null,259 upper_bound: null,260 lower_bound: null,261 key_type: "i64",262 index_position: 2,263 limit: 100264 }265 return eosApi.getTableRows(params)266}267export const apiSearchIBTSalesRows = (newname, eosApi) => {268 let params = {269 json: true,270 code: newBidnameContract,271 scope: newBidnameContract,272 table: "bidname22",273 table_key: null,274 upper_bound: newname,275 lower_bound: newname,276 key_type: "i64",277 index_position: 1,278 limit: 1279 }280 return eosApi.getTableRows(params)281}282export const apiSearchYASSalesRows = (newname, eosApi) => {283 let params = {284 json: true,285 code: newBidnameContract,286 scope: newBidnameContract,287 table: "bidname11",288 table_key: null,289 upper_bound: newname,290 lower_bound: newname,291 key_type: "i64",292 index_position: 1,293 limit: 1294 }295 return eosApi.getTableRows(params)296}297export const apiGetNamedexRewardsRows = (newname, eosApi) => {298 let params = {299 json: true,300 code: newBidnameContract,301 scope: newname,302 table: "bidrewards",303 table_key: null,304 lower_bound: null,305 upper_bound: null,306 key_type: "i64",307 index_position: 2,308 limit: 200309 }310 return eosApi.getTableRows(params)311}*/312export const apiGetBidsTopRows = (eosApi) => {313 let params = {314 json: true,315 code: bidnameContract,316 scope: bidnameContract,317 table: "namebids1",318 table_key: null,319 upper_bound: null,320 lower_bound: null,321 key_type: "i64",322 index_position: 2,323 limit: 100324 }325 return eosApi.getTableRows(params)326}327export const apiSearchBidTopRows = (newname, eosApi) => {328 let params = {329 json: true,330 code: bidnameContract,331 scope: bidnameContract,332 table: "namebids1",333 table_key: null,334 upper_bound: newname,335 lower_bound: newname,336 key_type: "i64",337 index_position: 1,338 limit: 1339 }340 return eosApi.getTableRows(params)341}342export const apiGetBidsBetRows = (eosApi) => {343 let params = {344 json: true,345 code: bidnameContract,346 scope: bidnameContract,347 table: "namebids2",348 table_key: null,349 upper_bound: null,350 lower_bound: null,351 key_type: "i64",352 index_position: 2,353 limit: 500354 }355 return eosApi.getTableRows(params)356}357export const apiSearchBidBetRows = (newname, eosApi) => {358 let params = {359 json: true,360 code: bidnameContract,361 scope: bidnameContract,362 table: "namebids2",363 table_key: null,364 upper_bound: newname,365 lower_bound: newname,366 key_type: "i64",367 index_position: 1,368 limit: 1369 }370 return eosApi.getTableRows(params)371}372export const apiGetBidrewardsRows = (newname, eosApi) => {373 let params = {374 json: true,375 code: bidnameContract,376 scope: newname,377 table: "bidrewards",378 table_key: null,379 lower_bound: null,380 upper_bound: null,381 key_type: "i64",382 index_position: 2,383 limit: 200384 }385 return eosApi.getTableRows(params)386}387export const apiGetSalePriceRows = (eosApi) => {388 let params = {389 json: true,390 code: bidnameContract,391 scope: bidnameContract,392 table: "saleprices",393 table_key: null,394 lower_bound: null,395 upper_bound: null,396 key_type: "i64",397 index_position: 1,398 limit: 100399 }400 return eosApi.getTableRows(params)401}402export const apiDelegatebw = (api, authorization, data) => {403 let action = {404 account: "eosio",405 name: "delegatebw",406 authorization: [authorization],407 data: {408 from: data.from,409 receiver: data.receiver,410 stake_cpu_quantity: data.stake_cpu_quantity,411 stake_net_quantity: data.stake_net_quantity,412 transfer: false413 }414 }...
wax-unit.test.js
Source:wax-unit.test.js
...61 entry_time: '2022-03-25T22:28:58',62 },63 ],64 });65 const entries = await getTableRows(66 myContract.account,67 `entries`,68 myContract.account69 );70 expect(entries.length).toEqual(2);71 expect(entries[0].id).toEqual(1);72 expect(entries[0].entry_time).toEqual('2022-02-24T22:27:57');73 });74 it('should init table data from json file', async () => {75 await myContract.loadTableFromFile('entries', 'tests/entries.json');76 const entries = await getTableRows(77 myContract.account,78 `entries`,79 'loadfile1111'80 );81 expect(entries.length).toEqual(3);82 expect(entries[0].id).toEqual(1);83 expect(entries[0].entry_time).toEqual('2022-02-24T22:26:56');84 });85 it('should call addentry action', async () => {86 await myContract.call(87 'addentry',88 [89 {90 actor: myContract.account,91 permission: 'active',92 },93 ],94 {95 id: 3,96 }97 );98 const entries = await getTableRows(99 myContract.account,100 `entries`,101 myContract.account102 );103 expect(entries.length).toEqual(3);104 expect(entries[2].id).toEqual(3);105 });106 it('can read table data', async () => {107 const balances = await getTableRows(108 'eosio.token',109 `accounts`,110 'mycontract11'111 );112 expect(balances.length).toEqual(1);113 expect(balances[0].balance).toEqual('200.00000000 WAX');114 });115 describe('addTime', () => {116 it('standard path', async () => {117 const entriesInitial = await getTableRows(118 'mycontract11',119 `entries`,120 'mycontract11'121 );122 const id = 4;123 // add new entry124 const res = await genericAction(125 'mycontract11',126 'addentry',127 {128 id,129 },130 [131 {132 actor: 'mycontract11',133 permission: 'active',134 },135 ]136 );137 let entries = await getTableRows(138 'mycontract11',139 `entries`,140 'mycontract11'141 );142 expect(entries.length).toBe(entriesInitial.length + 1);143 expect(entries[entriesInitial.length].id).toBe(id);144 await expect(145 genericAction(146 'mycontract11',147 'expireentry',148 {149 id,150 expiry_seconds: 600,151 },152 [153 {154 actor: 'mycontract11',155 permission: 'active',156 },157 ]158 )159 ).rejects.toThrow('Entry not expired yet');160 await addTime(601, res.processed.block_time);161 await genericAction(162 'mycontract11',163 'expireentry',164 {165 id,166 expiry_seconds: 600,167 },168 [169 {170 actor: 'mycontract11',171 permission: 'active',172 },173 ]174 );175 entries = await getTableRows('mycontract11', `entries`, 'mycontract11');176 expect(entries.length).toBe(entriesInitial.length);177 });178 it('can add multiple times', async () => {179 const entriesInitial = await getTableRows(180 'mycontract11',181 `entries`,182 'mycontract11'183 );184 const id = 5;185 // add new entry186 const res = await genericAction(187 'mycontract11',188 'addentry',189 {190 id,191 },192 [193 {194 actor: 'mycontract11',195 permission: 'active',196 },197 ]198 );199 let entries = await getTableRows(200 'mycontract11',201 `entries`,202 'mycontract11'203 );204 expect(entries.length).toBe(entriesInitial.length + 1);205 expect(entries[entriesInitial.length].id).toBe(id);206 await expect(207 genericAction(208 'mycontract11',209 'expireentry',210 {211 id,212 expiry_seconds: 600,213 },214 [215 {216 actor: 'mycontract11',217 permission: 'active',218 },219 ]220 )221 ).rejects.toThrow('Entry not expired yet');222 await addTime(300, res.processed.block_time);223 await expect(224 genericAction(225 'mycontract11',226 'expireentry',227 {228 id,229 expiry_seconds: 600,230 },231 [232 {233 actor: 'mycontract11',234 permission: 'active',235 },236 ]237 )238 ).rejects.toThrow('Entry not expired yet');239 await addTime(301);240 await genericAction(241 'mycontract11',242 'expireentry',243 {244 id,245 expiry_seconds: 600,246 },247 [248 {249 actor: 'mycontract11',250 permission: 'active',251 },252 ]253 );254 entries = await getTableRows('mycontract11', `entries`, 'mycontract11');255 expect(entries.length).toBe(entriesInitial.length);256 });257 it('can add far into the future', async () => {258 const entriesInitial = await getTableRows(259 'mycontract11',260 `entries`,261 'mycontract11'262 );263 const id = 6;264 // add new entry265 const res = await genericAction(266 'mycontract11',267 'addentry',268 {269 id,270 },271 [272 {273 actor: 'mycontract11',274 permission: 'active',275 },276 ]277 );278 let entries = await getTableRows(279 'mycontract11',280 `entries`,281 'mycontract11'282 );283 expect(entries.length).toBe(entriesInitial.length + 1);284 expect(entries[entriesInitial.length].id).toBe(id);285 await expect(286 genericAction(287 'mycontract11',288 'expireentry',289 {290 id,291 expiry_seconds: 600,292 },293 [294 {295 actor: 'mycontract11',296 permission: 'active',297 },298 ]299 )300 ).rejects.toThrow('Entry not expired yet');301 await addTime(600001, res.processed.block_time);302 await genericAction(303 'mycontract11',304 'expireentry',305 {306 id,307 expiry_seconds: 600,308 },309 [310 {311 actor: 'mycontract11',312 permission: 'active',313 },314 ]315 );316 entries = await getTableRows('mycontract11', `entries`, 'mycontract11');317 expect(entries.length).toBe(entriesInitial.length);318 });319 });...
script.js
Source:script.js
1//Title constructor function that creates a Title object2function Title(t1) 3{ 4 this.mytitle = t1;5}6Title.prototype.getName = function () 7{ 8return (this.mytitle);9}10var socialMedia = {11 facebook : 'http://facebook.com',12 twitter: 'http://twitter.com',13 flickr: 'http://flickr.com',14 youtube: 'http://youtube.com'15};16window.onload = function () {17 var dropDown = document.getElementsByClassName('dropDownTextArea');18 for (var i = 0; i < dropDown.length; i++) {19 dropDown[i].style.display = 'none';20 }21 document.getElementById('button').disabled = true;22 document.getElementById('button').style.backgroundColor = 'gray';23 document.getElementById('button').style.color = 'white';24 document.getElementById('button').style.border = '1px solid gray';25 var getTableRows = document.getElementById('myTable').getElementsByTagName('tr');26 for (var rowObject = 0; rowObject < getTableRows.length; rowObject++) {27 for (var columnNumber = 0; columnNumber < getTableRows[rowObject].cells.length; columnNumber++){28 if(columnNumber == 8){29 getTableRows[rowObject].cells[8].style.visibility='hidden';30 }31 }32 }33}34function toggle(getImage) {35 var imageId = getImage.id.slice(5);//136 imageId = imageId-1;37 var dropDown = document.getElementsByClassName('dropDownTextArea');//338 39 for (var ddNumber = 0; ddNumber < dropDown.length; ddNumber++) {// 0 to 240 if (ddNumber == imageId) {41 if (dropDown[ddNumber].style.display == 'none') {42 dropDown[ddNumber].style.display = 'contents';43 } else {44 dropDown[ddNumber].style.display = 'none';45 }46 }47 }48}49function addRow() {50 // Getting tbody of the table 51 var tableRef = document.getElementById('myTable').getElementsByTagName('tbody')[0];52 // Adding row in tbody 53 var count = tableRef.rows.length;54 count = count - 1;55 var newRow = tableRef.insertRow(count);56 count = count-1;57 var newCell;58 var newText;59 newCell = newRow.insertCell(0);60 // newText = document.createTextNode('Student '+ count);61 // newCell.appendChild(newText);62 var addCheckbox = document.createElement('input');63 addCheckbox.type = 'checkbox';64 addCheckbox.id = count.toString();65 newCell.appendChild(addCheckbox);66 addCheckbox.onclick = function () {67 getCheckBoxValue();68 }69 newText = document.createElement("br");70 newCell.appendChild(newText);71 newText = document.createElement("br");72 newCell.appendChild(newText);73 var addImage = document.createElement('img');74 addImage.src = 'down.png';75 addImage.id= 'img'+ count.toString();76 addImage.style.display = 'block';77 addImage.style.width = '25px';78 newCell.appendChild(addImage);79 addImage.onclick = function () {80 toggle(addImage.this);81 }82 newCell = newRow.insertCell(1);83 newText = document.createTextNode('Student '+ count);84 newCell.appendChild(newText);85 86 newCell = newRow.insertCell(2);87 newText = document.createTextNode('Teacher '+ count);88 newCell.appendChild(newText);89 newCell = newRow.insertCell(3);90 newText = document.createTextNode('Approved');91 newCell.appendChild(newText);92 newCell = newRow.insertCell(4);93 newText = document.createTextNode('Fall');94 newCell.appendChild(newText);95 newCell = newRow.insertCell(5);96 newText = document.createTextNode('TA');97 newCell.appendChild(newText);98 newCell = newRow.insertCell(6);99 var num = Math.floor(Math.random() * 90000);100 newText = document.createTextNode(num.toString());101 newCell.appendChild(newText);102 newCell = newRow.insertCell(7);103 num = Math.floor(Math.random() * 100);104 newText = document.createTextNode(num.toString() + "%" );105 newCell.appendChild(newText);106 newCell = newRow.insertCell(8);107 newText = document.createTextNode('');108 newCell.appendChild(newText);109 newCell.style.visibility='hidden';110}111function getCheckBoxValue(){112 var getTableRows = document.getElementById('myTable').getElementsByTagName('tr');113 var getCheckBox = document.getElementById('myTable').getElementsByTagName('input');114 getTableRows[0].cells[getTableRows[0].cells.length - 1].style.visibility = 'visible';115 var getCheckBox1 = document.getElementById('myTable').getElementsByTagName('input');116 for (var checkBoxNumber1 = 0; checkBoxNumber1 < getCheckBox1.length; checkBoxNumber1++) {117 if(!getCheckBox1[checkBoxNumber1].checked){118 getTableRows[0].cells[getTableRows[0].cells.length - 1].style.visibility = 'hidden';119 document.getElementById('button').disabled = true;120 document.getElementById('button').style.backgroundColor = 'gray';121 document.getElementById('button').style.color = 'white';122 document.getElementById('button').style.border = '1px solid gray';123 }124 }125 126 for (var checkBoxNumber = 0; checkBoxNumber < getCheckBox.length; checkBoxNumber++) {127 if (getCheckBox[checkBoxNumber].checked) {128 129 getCheckBox[checkBoxNumber].parentElement.parentElement.style.backgroundColor = "orange";130 document.getElementById('button').disabled = false;131 document.getElementById('button').style.backgroundColor = 'orange';132 document.getElementById('button').style.border = '1px solid orange';133 var getTableRows = document.getElementById('myTable').getElementsByTagName('tr');134 getTableRows[0].cells[8].style.visibility='visible';135 var getRow = getCheckBox[checkBoxNumber].parentNode.parentNode;136 getRow.cells[getRow.cells.length - 1].style.visibility = 'visible';137 // document.getElementById('button').style.backgroundColor = 'orange';138 139 if (!document.getElementById('delete' + checkBoxNumber)) {140 var createBtn = document.createElement('button');141 var createBtnName = document.createTextNode('Delete');142 createBtn.id = 'delete' + checkBoxNumber;143 createBtn.appendChild(createBtnName);144 145 getRow.cells[getRow.cells.length - 1].style.visibility = 'visible';146 getRow.cells[getRow.cells.length - 1].appendChild(createBtn);147 createBtn.onclick = function () {148 removeRow(this);149 }150 }151 152 }153 else{154 getCheckBox[checkBoxNumber].parentElement.parentElement.style.backgroundColor = "white";155 var getRow = getCheckBox[checkBoxNumber].parentNode.parentNode;156 getRow.cells[getRow.cells.length - 1].style.visibility = 'hidden';157 if (document.getElementById('delete' + checkBoxNumber)) {158 document.getElementById('delete' + checkBoxNumber).remove();159 }160 }161 } 162}163function removeRow(getRow) {164 getRow.parentNode.parentNode.remove();165 var getTableRows = document.getElementById('myTable').getElementsByTagName('tr');166 var getCheckBox1 = document.getElementById('myTable').getElementsByTagName('input');167 for (var checkBoxNumber1 = 0; checkBoxNumber1 < getCheckBox1.length; checkBoxNumber1++) {168 if(!getCheckBox1[checkBoxNumber1].checked){169 getTableRows[0].cells[getTableRows[0].cells.length - 1].style.visibility = 'hidden';170 document.getElementById('button').disabled = true;171 document.getElementById('button').style.backgroundColor = 'gray';172 document.getElementById('button').style.color = 'white';173 document.getElementById('button').style.border = '1px solid gray';174 }175 }...
api.js
Source:api.js
...9// const historyeos = () => ScatterJS.scatter.eos(config.history, Eos, { expireInSeconds: 60 });10const currentEOSAccount = () => ScatterJS.scatter.identity && ScatterJS.scatter.identity.accounts.find(x => x.blockchain === 'eos');11const API = {12 async getPlayerAsync({ accountName }) {13 const { rows } = await eos().getTableRows({14 json: true,15 code: 'chainbankeos',16 scope: accountName,17 table: 'player',18 limit: 1024,19 });20 return rows;21 },22 async getRemainAmountAsync({ accountName }) {23 const { rows } = await eos().getTableRows({24 json: true,25 code: 'chainbankeos',26 scope: accountName,27 table: 'global',28 limit: 1024,29 });30 return rows[0].remainamount;31 },32 async getCCCAsync() {33 const { rows } = await eos().getTableRows({34 json: true,35 code: 'chainbankeos',36 scope: 'CCC',37 table: 'stat',38 limit: 1024,39 });40 return rows[0];41 },42 async getPoolAsync(){43 const { rows } = await eos().getTableRows({44 json: true,45 code: 'chainbankeos',46 scope: 'chainbankeos',47 table: 'dividend',48 limit: 1024,49 });50 return rows[0];51 },52 async getMyCCCAsync(eosaccount = currentEOSAccount()){53 const { rows } = await eos().getTableRows({54 json: true,55 code: 'chainbankeos',56 scope: eosaccount.name,57 table: 'accounts',58 limit: 1024,59 });60 return rows[0];61 },62 async getMyInfoAsync(eosaccount = currentEOSAccount()){63 const { rows } = await eos().getTableRows({64 json: true,65 code: 'chainbankeos',66 scope: eosaccount.name,67 table: 'playerinfo',68 limit: 1024,69 });70 return rows[0];71 },72 async getBuyBackAsync(){73 const { rows } = await eos().getTableRows({74 json: true,75 code: 'chainbankeos',76 scope: 'chainbankeos',77 table: 'buybackqueue',78 limit: 1024,79 });80 return rows;81 },82 async getCollectionAsync(){83 const { rows } = await eos().getTableRows({84 json: true,85 code: 'chainbankeos',86 scope: 'chainbankeos',87 table: 'collection',88 limit: 1024,89 });90 return rows;91 },92 async getEOSAsync() {93 const { rows } = await eos().getTableRows({94 json: true,95 code: 'eosio.token',96 scope: 'chainbankeos',97 table: 'accounts',98 limit: 1024,99 });100 return rows[0];101 },102 async getBalancesByContract({ tokenContract = 'eosio.token', accountName, symbol }) {103 return eos().getCurrencyBalance(tokenContract, accountName, symbol);104 },105 install(Vue) {106 Object.defineProperties(Vue.prototype, {107 $API: {108 get() {109 return API;110 },111 },112 });113 },114 getmyself(){115 return currentEOSAccount().name;116 },117 connectScatterAsync() {118 // alert("scatter connecting...");119 return ScatterJS.scatter.connect(config.appScatterName, { initTimeout: 2000 });120 },121 loginScatterAsync() {122 // alert("scatter logging...");123 const requiredFields = { accounts: [config.network] };124 return ScatterJS.scatter.getIdentity(requiredFields);125 },126 logoutScatterAsync() {127 return ScatterJS.scatter.forgetIdentity();128 },129 transferEOSAsync({130 from = currentEOSAccount(),131 to,132 memo = '',133 amount = 0,134 }) {135 return eos().transfer(136 from.name,137 to,138 PriceFormatter.formatPrice(amount),139 memo, {140 authorization: [`${from.name}@${from.authority}`],141 },142 );143 },144 async transferTokenAsync({145 from = currentEOSAccount(),146 to,147 memo = '',148 amount = 0,149 tokenContract = 'eosio.token',150 }) {151 const contract = await eos().contract(tokenContract);152 return contract.transfer(153 from.name,154 to,155 amount,156 memo, {157 authorization: [`${from.name}@${from.authority}`],158 },159 );160 },161 async SellCoinAsync(162 amount = '',163 memo = '',164 from = currentEOSAccount(),165 ){166 const contract = await eos().contract('chainbankeos');167 await contract.pushorder(168 from.name,169 PriceFormatter.formatPrice(amount),170 memo,171 {172 authorization: [`${from.name}@${from.authority}`],173 },174 );175 },176 async ExchangeCoinAsync(177 memo = '',178 from = currentEOSAccount(),179 ){180 const contract = await eos().contract('chainbankeos');181 await contract.exchange(182 memo,183 {184 authorization: [`${from.name}@${from.authority}`],185 },186 );187 },188 async ExchangeCoinDownAsync(189 id = 0,190 goalid = 0,191 from = currentEOSAccount(),192 ){193 const contract = await eos().contract('chainbankeos');194 await contract.exchangedown(195 id,196 goalid,197 {198 authorization: [`${from.name}@${from.authority}`],199 },200 );201 },202 async CollClaimAsync(203 type = 0,204 from = currentEOSAccount(),205 ){206 type += 1;207 const contract = await eos().contract('chainbankeos');208 await contract.collclaim(209 from.name,210 type,211 {212 authorization: [`${from.name}@${from.authority}`],213 },214 );215 },216 async BuyBackAsync(217 amount = 0,218 from = currentEOSAccount(),219 ){220 const contract = await eos().contract('chainbankeos');221 await contract.joinbuybackq(222 from.name,223 PriceFormatter.formatPriceToCCC(amount),224 {225 authorization: [`${from.name}@${from.authority}`],226 },227 );228 },229 async getCoinsAsync({ accountName }) {230 var rows = [];231 for(var i = 0; i < 20; i ++ ){232 console.log(i);233 const onerow = await eos().getTableRows({234 json: true,235 code: 'chainbankeos',236 scope: accountName,237 table: 'coin',238 limit: 65536,239 lower_bound: i*1000,240 upper_bound: i*1000+999,241 });242 // console.log(onerow.rows);243 // merge.244 rows = rows.concat(onerow.rows);245 console.log(rows.length);246 }247 return rows;248 },249 async getPlayersAsync({ accountName }) {250 const { rows } = await eos().getTableRows({251 json: true,252 code: 'chainbankeos',253 scope: accountName,254 table: 'player',255 limit: 1024,256 });257 return rows;258 },259 async getTransactionsAsync({ accountName }) {260 const { rows } = await eos().getTableRows({261 json: true,262 code: 'chainbankeos',263 scope: accountName,264 table: 'order',265 limit: 1024,266 });267 console.log(await eos().getTableRows({268 json: true,269 code: 'chainbankeos',270 scope: 'chainbankeos',271 table: 'player',272 limit: 1024,273 }));274 return rows;275 },276};277export default API;...
test_queries.mjs
Source:test_queries.mjs
...7 // // ALL TABLES IN DB8 // res = await _.getTables;9 // log(res.map((cols) => cols["Tables_in_wp-final"]));10 // // ALL wp_posts TABLE ROWS11 // res = await _.getTableRows("wp_posts");12 // log(res)13 // // ALL 25 PRODUCTS DETAILS14 // res = await _.getTableRows("wp_posts");15 // log(16 // res17 // .filter((row) => row.post_type === "product")18 // // .length19 // );20 // // ALL 25 PRODUCTS IDS21 // res = await _.getTableRowsByCols("wp_posts", ["post_type", "ID"]);22 // res23 // .filter((row) => row.post_type === "product")24 // .map((row) => row.ID)25 // .forEach((id) => {26 // log(id);27 // });28 // // ALL 25 PRODUCTS TITLES29 // res = await _.getTableRows("wp_posts");30 // res31 // .filter((row) => row.post_type === "product")32 // .map((row) => row.post_title)33 // .reverse()34 // .forEach((title) => {35 // log(title);36 // });37 // res = await _.getTableRows("wp_posts");38 // res39 // .filter((row) => row.post_type === "attachment")40 // .map((row) => Object.entries(row));41 // // SAVE wp_posts TO JSON FILE42 // res = await _.getTableRows("wp_posts");43 // log(res);44 // saveToJsonFile(res, "./wp_posts.json");45 // // SAVE wp_postmeta TO JSON FILE46 // res = await _.getTableRows("wp_postmeta");47 // log(res);48 // saveToJsonFile(res, "./wp_postmeta.json");49 // res = await _.getTableRows("wp_postmeta");50 // log(res.filter((row) => row.post_id === 127));51 // res = await _.getTableRows("wp_postmeta");52 // log(res.filter((row) => row.meta_id === 3842));53 // // GET GALLERY OF A PRODUCT BY ID54 // res = await _.getImagesIdsOfProductByProductId(2602);55 // // returns 3 arrays that differs only on pk56 // const imagesIdsStr = res[0].meta_value;57 // res = await _.getImagesUrlsOfProduct(imagesIdsStr);58 // log(res.map((row) => row.guid));59 // res = await _.getAllProducts;60 // log(res.map((product) => rowDataPacketToObj(product)));61 // res = await _.getTableRows("wp_postmeta");62 // log(res)63 // res = await _.getRowsOfProduct(1367);64 // res.forEach((r) => log(r));65 // log(res.length)66 // const res1 = await _.test01;67 // const res2 = await _.test02;68 // log(res1.length);69 // log(res2.length);70 // log("====================================================");71 // res1.forEach((r) => log(r));72 // for (let i = 0; i < 10; i++)73 // log("====================================================");74 // res2.forEach((r) => log(r));75 // res = await _.test04;...
AggregionUtility.js
Source:AggregionUtility.js
...26 async getRequestsLog() {27 return await this.tables.getTable('reqslog');28 }29 async getProviderByName(name) {30 let data = await this.bc.getTableRows(this.contractAccount, 'providers', 'default', name);31 let scoped = data.rows.map(r => { r.scope = 'default'; return r; });32 return scoped[0];33 }34 async isProviderExists(name) {35 let p = await this.getProviderByName(name);36 return typeof p != 'undefined';37 }38 async getService(provider, service) {39 let data = await this.bc.getTableRows(this.contractAccount, 'services', provider, service);40 let scoped = data.rows.map(r => { r.scope = provider; return r; });41 return scoped[0];42 }43 async getScript(owner, script, version) {44 const hash = crypto.createHash('sha256').update(owner + script + version).digest('hex');45 const result = await this.bc.getTableRowsByIndex(this.contractAccount, 'scripts', 'default', 2, 'sha256', hash, hash);46 return result.rows[0];47 }48 async getScriptByHash(hash) {49 return await this.tables.getTableByIndex('scripts', 3, 'sha256', hash);50 }51 async isTrusted(truster, trustee) {52 const result = await this.bc.getTableRows(this.contractAccount, 'trustedprov', truster, trustee);53 const item = result.rows[0];54 return typeof item != 'undefined' && item.trust === 1;55 }56 async isScriptApprovedBy(provider, hash) {57 const script = await this.getScriptByHash(hash);58 const result = await this.bc.getTableRows(this.contractAccount, 'approves', provider, script.id);59 check.assert.lessOrEqual(result.rows.length, 1);60 const item = result.rows[0];61 return typeof item != 'undefined' && item.approved === 1;62 }63 async isScriptAccessGrantedTo(grantee, hash) {64 const script = await this.getScriptByHash(hash);65 if (script.length === 0) {66 return undefined;67 }68 const result = await this.bc.getTableRows(this.contractAccount, 'scriptaccess', grantee, script.id);69 check.assert.lessOrEqual(result.rows.length, 1);70 if (result.rows.length === 0) {71 return undefined;72 }73 const item = result.rows[0];74 return item.granted === 1;75 }76 async isScriptAllowedWithinEnclave(enclaveOwner, hash, grantee) {77 const script = await this.getScriptByHash(hash);78 if (script.length === 0) {79 return undefined;80 }81 const result = await this.bc.getTableRows(this.contractAccount, 'encscraccess', enclaveOwner, script.id);82 check.assert.lessOrEqual(result.rows.length, 1);83 if (result.rows.length === 0) {84 return undefined;85 }86 const item = result.rows[0];87 const permission = item.permissions.find(p => { return p.key === grantee; });88 if (!permission) {89 return undefined;90 }91 return permission.value === 1;92 }93};...
index.js
Source:index.js
...4function amountToQuantity(amount) {5 return sprintf('%.04f %s', amount, symbol);6}7function getTableRowById(eos, table, key, id, func) {8 eos.getTableRows({json:true, scope: key, code: contract_name, table: table, limit:1, lower_bound: id, upper_bound: id+1})9 .then(res => {10 func(res);11 });12}13function getTableRows(eos, table, key, func) {14 eos.getTableRows({json:true, scope: key, code: contract_name, table: table, limit:1000})15 .then(res => {16 func(res);17 });18}19module.exports = {20 send: function(eos, sender, to, quantity, memo, func) {21 eos.contract(contract_name).then(contract => {22 contract.send({23 from: sender,24 to: to,25 quantity: amountToQuantity(quantity),26 memo: memo27 },28 {29 authorization: [{30 'actor': sender,31 'permission': 'active'32 }]33 });34 func();35 });36 },37 createsurvey: function(eos, survey_id, issuer, date_start, date_end, category, question, age, gender, answer1, image1, answer2, image2, answer3, image3, answer4, image4, func) {38 eos.contract(contract_name).then(contract => {39 contract.createsurvey({40 survey_id: survey_id,41 issuer: issuer,42 date_start: date_start,43 date_end: date_end,44 category: category ? category : 0,45 question: question,46 age: age ? age : 0,47 gender: gender ? gender : 0,48 answer1: answer1,49 image1: image1,50 answer2: answer2,51 image2: image2,52 answer3: answer3,53 image3: image3,54 answer4: answer4,55 image4: image4,56 },57 {58 authorization: [{59 'actor': issuer,60 'permission': 'active'61 }]62 });63 func();64 });65 },66 submitsurvey: function(eos, voter, survey_id, answer_id, func) {67 eos.contract(contract_name).then(contract => {68 contract.submitsurvey({69 voter: voter,70 survey_id: survey_id,71 answer_id: answer_id72 },73 {74 authorization: [{75 'actor': voter,76 'permission': 'active'77 }]78 });79 func();80 });81 },82 getBalance: function(eos, account, func) {83 getTableRows(eos, 'accounts', account, func);84 },85 getTransactions: function(eos, account, func) {86 getTableRows(eos, 'transactions', account, func);87 },88 getSurvey: function(eos, survey_id, func) {89 getTableRows(eos, 'surveys', survey_id, func);90 },91 getSurveyresBySurveyId: function(eos, survey_id, func) {92 getTableRows(eos, 'surveyress', survey_id, func);93 },94 getSurveyresByUser: function(eos, account, func) {95 getTableRows(eos, 'surveyress', account, func);96 },97 getSurveyAnswer: function(eos, survey_id, func) {98 getTableRows(eos, 'surveyanss', survey_id, func);99 },100 getSurveyChart: function(eos, survey_id, func) {101 getTableRows(eos, 'surveycharts', survey_id, func);102 }...
SumTable.js
Source:SumTable.js
1function sumTable() {2 let getTableRows = document.querySelectorAll('table tbody tr td'); 3 let getSumField = document.querySelector('#sum'); // table tbody tr:nth-child(5)4 let sum = 0;5 for (let i = 0; i < getTableRows.length - 1; i++) {6 if (parseInt(getTableRows[i].textContent)) {7 sum += Number(getTableRows[i].textContent);8 }9 }10 getSumField.textContent = sum;...
Using AI Code Generation
1const {getGherkinDocument} = require('cucumber-gherkin');2const {getTableRows} = require('cucumber-gherkin');3const gherkinDocument = getGherkinDocument('4');5const tableRows = getTableRows(gherkinDocument.feature.children[0].steps[0].dataTable);6console.log(tableRows);7const {getGherkinDocument} = require('cucumber-gherkin');8const {getTableRows} = require('cucumber-gherkin');9const gherkinDocument = getGherkinDocument('10');11const tableRows = getTableRows(gherkinDocument.feature.children[0].steps[0].dataTable);12console.log(tableRows);13const {getGherkinDocument} = require('cucumber-gherkin');14const {getTableRows} = require('cucumber-gherkin');15const gherkinDocument = getGherkinDocument('16');17const tableRows = getTableRows(gherkinDocument.feature.children[0].steps[0].dataTable);18console.log(tableRows);19I have a problem with my code. I want to get the value of the first column of the table. I tried to use the getTableRows() method but it didn’t work. I also tried the following code:20const {getGherkinDocument} = require('cucumber-gherkin');21const {getTableRows} = require('cucumber-gherkin');22const gherkinDocument = getGherkinDocument('23');
Using AI Code Generation
1var gherkin = require('cucumber-gherkin');2var fs = require('fs');3var featureFile = fs.readFileSync('./test.feature', 'utf8');4var feature = gherkin.parse(featureFile);5var rows = gherkin.getRows(feature);6console.log(rows);7[ { 'Given I have a feature file': '' },8 { 'When I parse it': '' },9 { 'Then I get the rows': '' } ]10var rows = gherkin.getRows(feature);11var rowObjects = [];12for (var i = 0; i < rows.length; i++) {13 var row = rows[i];14 var rowObject = {};15 rowObject[row] = '';16 rowObjects.push(rowObject);17}18console.log(rowObjects);19[ { 'Given I have a feature file': '' },20 { 'When I parse it': '' },21 { 'Then I get the rows': '' } ]22[ { 'Given I have a feature file': '' },23 { 'When I parse it': '' },24 { 'Then I get the rows': '' } ]25var rows = gherkin.getRows(feature);26var rowObjects = [];27for (var i = 0; i < rows.length; i++) {28 var row = rows[i];29 var rowObject = {};30 rowObject[row] = '';31 rowObjects.push(rowObject);32}33console.log(rowObjects);34[ { 'Given I have a feature file': '' },35 { 'When I parse it': '' },36 { 'Then I get the rows': '' } ]37[ { 'Given I have a feature file': '' },38 { 'When I parse it':
Using AI Code Generation
1var gherkin = require('cucumber-gherkin');2var parser = new gherkin.Parser();3var fs = require('fs');4var path = require('path');5var featureFile = 'test.feature';6var feature = fs.readFileSync(path.join(__dirname, featureFile), 'utf8');7var featureObject = parser.parse(feature);8var scenario = featureObject.feature.children[0].scenario;9var tableRows = scenario.steps[0].argument.rows;10console.log(tableRows[0].cells[1]);11console.log(tableRows[1].cells[1]);12console.log(tableRows[2].cells[1]);13console.log(tableRows[3].cells[1]);14console.log(tableRows[4].cells[1]);15console.log(tableRows[5].cells[1]);16console.log(tableRows[6].cells[1]);17console.log(tableRows[7].cells[1]);18console.log(tableRows[8].cells[1]);19console.log(tableRows[9].cells[1]);20console.log(tableRows[10].cells[1]);21console.log(tableRows[11].cells[1]);22console.log(tableRows[12].cells[1]);23console.log(tableRows[13].cells[1]);24console.log(tableRows[14].cells[1]);25console.log(tableRows[15].cells
Using AI Code Generation
1var gherkin = require('cucumber-gherkin');2var options = {3};4var gherkinDocument = gherkin.fromPaths(options.featurePaths);5var scenarios = gherkinDocument.feature.children.filter(function (child) {6 return child.scenario;7});8var scenario = scenarios.filter(function (scenario) {9 return gherkin.matchesTags(scenario, options.tagExpression);10});11console.log(scenario);12[ { type: 'Scenario',13 location: { line: 2, column: 1 },14 steps: [ [Object], [Object] ] } ]
Using AI Code Generation
1var gherkin = require('gherkin');2var parser = new gherkin.Parser();3var fs = require('fs');4var feature = fs.readFileSync('test.feature').toString();5var parsed = parser.parse(feature);6var tableRows = parsed.feature.children[0].scenario.steps[0].argument.rows;7console.log(tableRows);8var table = gherkin.formatterHelpers.formatTable(tableRows);9console.log(table);10var table = gherkin.formatterHelpers.formatTable(tableRows, function(row){11 return row.cells;12});13console.log(table);14var table = gherkin.formatterHelpers.formatTable(tableRows, function(row){15 return row.cells.map(function(cell){16 return cell.value;17 });18});19console.log(table);20var table = gherkin.formatterHelpers.formatTable(tableRows, function(row){21 return row.cells.map(function(cell){22 return cell.value;23 }).join(' ');24});25console.log(table);26var table = gherkin.formatterHelpers.formatTable(tableRows, function(row){27 return row.cells.map(function(cell){28 return cell.value;29 }).join(' ');30}, function(row){31 return row.type === 'PyString';32});33console.log(table);34[ { type: 'TableRow',35 location: { line: 5, column: 1 },36 cells: [ [Object] ] },37 { type: 'TableRow',38 location: { line: 6, column: 1 },39 cells: [ [Object], [Object] ] },40 { type: 'TableRow',41 location: { line: 7, column: 1 },42 cells: [ [Object], [Object] ] },43 { type: 'TableRow',44 location: { line: 8, column: 1 },45 cells: [ [Object], [Object] ] },46 { type: 'TableRow',47 location: { line: 9, column: 1 },48 cells: [ [Object], [Object] ] } ]
Using AI Code Generation
1var gherkin = require("cucumber-gherkin");2gherkin.getTableRows("test.feature", "Scenario: Test", function(err, rows) {3 console.log(rows);4});5[ { 'First Name': 'John', 'Last Name': 'Doe' },6 { 'First Name': 'Jane', 'Last Name': 'Doe' } ]7Related posts: How to execute a shell command from a node.js application? How to execute a shell command from a node.js application? I have a requirement to execute a shell command from a node.js application. I have tried the following code to execute the command. var exec = require('child_process').exec, child; child = exec('ls -lart', function (error, stdout, stderr) { console.log('stdout: ' + stdout); console.log('stderr: ' + stderr); if (error !== null) { console.log('exec error: ' + error); } }); But the code is not working. I am getting the following error. exec error: Error: Command failed: ls -lart /bin/sh: ls -lart: command not found Any idea how to execute a shell command from a node.js application? How to execute a shell command from a node.js application? I have a requirement to execute a shell command from a node.js application. I have tried the following code to execute the command. var exec = require('child_process').exec, child; child = exec('ls -lart', function (error, stdout, stderr) { console.log('stdout: ' + stdout); console.log('stderr: ' + stderr); if (error !== null) { console.log('exec error: ' + error); } }); But the code is not working. I am getting the following error. exec error: Error: Command failed: ls -lart /bin/sh: ls -lart: command not found Any idea how to execute a shell command from a node.js application? How to execute a shell command from a node.js application? I have a requirement to
Using AI Code Generation
1var gherkin = require('cucumber-gherkin');2gherkin.getTableRows('path to feature file', 'table name', 'table header', function (err, rows) {3 console.log(rows);4});5var gherkin = require('cucumber-gherkin');6gherkin.getTableRows('path to feature file', 'table name', 'table header', function (err, rows) {7 console.log(rows);8});9gherkin.getTableRows('path to feature file', 'table name', 'table header', function (err, rows) {10 console.log(rows);11});12var gherkin = require('cucumber-gherkin');13gherkin.getTableRows('path to feature file', 'table name', 'table header', function (err, rows) {14 console.log(rows);15});16gherkin.getTableRows('path to feature file', 'table name', 'table header', function (err, rows) {17 console.log(rows);18});19var gherkin = require('cucumber-gherkin');20gherkin.getTableRows('path to feature file', 'table name', 'table header', function (err, rows) {21 console.log(rows);22});23gherkin.getTableRows('path to feature file', 'table name', 'table header', function (err, rows) {
Using AI Code Generation
1var Cucumber = require('cucumber');2var Gherkin = require('gherkin');3var fs = require('fs');4var file = fs.readFileSync('./features/test.feature', 'utf8');5var parser = new Gherkin.Parser();6var feature = parser.parse(file);7var featureElements = feature.children;8var scenario = featureElements[0];9var steps = scenario.steps;10var step = steps[0];11var table = step.table;12var rows = Cucumber.Gherkin.Table.Rows(table);13console.log(rows);14console.log(rows[0]);15console.log(rows[0][0]);16console.log(rows[0][1]);17console.log(rows[1]);18console.log(rows[1][0]);19console.log(rows[1][1]);
LambdaTest offers a detailed Cucumber testing tutorial, explaining its features, importance, best practices, and more to help you get started with running your automation testing scripts.
Here are the detailed Cucumber testing chapters to help you get started:
Get 100 minutes of automation test minutes FREE!!