Best JavaScript code snippet using wpt
signaling.test.js
Source:signaling.test.js
1import { jest } from '@jest/globals';2import * as Path from 'path';3import { setup, teardown } from 'jest-dev-server';4import { Signaling, WebSocketSignaling } from "../public/js/signaling";5import { MockSignaling, reset } from "./mocksignaling";6import { waitFor, sleep, serverExeName } from "./testutils";7const portNumber = 8081;8jest.setTimeout(10000);9describe.each([10 { mode: "mock" },11 { mode: "http" },12 { mode: "websocket" },13])('signaling test in public mode', ({ mode }) => {14 let signaling1;15 let signaling2;16 const connectionId1 = "12345";17 const connectionId2 = "67890";18 const testsdp = "test sdp";19 const testcandidate = "test candidate";20 beforeAll(async () => {21 if (mode == "mock") {22 reset(false);23 signaling1 = new MockSignaling();24 signaling2 = new MockSignaling();25 } else {26 const path = Path.resolve(`../bin~/${serverExeName()}`);27 let cmd = `${path} -p ${portNumber}`;28 if (mode == "websocket") {29 cmd += " -w";30 }31 await setup({ command: cmd, port: portNumber, usedPortAction: 'error' });32 if (mode == "http") {33 signaling1 = new Signaling();34 signaling2 = new Signaling();35 }36 if (mode == "websocket") {37 signaling1 = new WebSocketSignaling();38 signaling2 = new WebSocketSignaling();39 }40 }41 await signaling1.start();42 await signaling2.start();43 });44 afterAll(async () => {45 await signaling1.stop();46 await signaling2.stop();47 signaling1 = null;48 signaling2 = null;49 if (mode == "mock") {50 return;51 }52 await teardown();53 // work around for linux, waitng kill server process54 await sleep(1000);55 });56 test(`onConnect using ${mode}`, async () => {57 const signaling1Spy = jest.spyOn(signaling1, 'dispatchEvent');58 let connectRes;59 let disconnectRes;60 signaling1.addEventListener('connect', (e) => connectRes = e.detail);61 signaling1.addEventListener('disconnect', (e) => disconnectRes = e.detail);62 await signaling1.createConnection(connectionId1);63 await waitFor(() => connectRes != null);64 expect(connectRes.connectionId).toBe(connectionId1);65 expect(connectRes.polite).toBe(true);66 await signaling1.deleteConnection(connectionId1);67 await waitFor(() => disconnectRes != null);68 expect(disconnectRes.connectionId).toBe(connectionId1);69 const disconnectCalledCount = signaling1Spy.mock.calls.map(x => x[0].type).filter(x => x == "disconnect").length;70 expect(disconnectCalledCount).toBe(1);71 signaling1Spy.mockRestore();72 });73 test(`onOffer using ${mode}`, async () => {74 let connectRes1;75 let disconnectRes1;76 signaling1.addEventListener('connect', (e) => connectRes1 = e.detail);77 signaling1.addEventListener('disconnect', (e) => disconnectRes1 = e.detail);78 let connectRes2;79 let disconnectRes2;80 let offerRes2;81 signaling2.addEventListener('connect', (e) => connectRes2 = e.detail);82 signaling2.addEventListener('disconnect', (e) => disconnectRes2 = e.detail);83 signaling2.addEventListener('offer', (e) => offerRes2 = e.detail);84 await signaling1.createConnection(connectionId1);85 await signaling2.createConnection(connectionId2);86 await waitFor(() => connectRes1 != null && connectRes2 != null);87 expect(connectRes1.connectionId).toBe(connectionId1);88 expect(connectRes2.connectionId).toBe(connectionId2);89 await signaling1.sendOffer(connectionId1, testsdp);90 await waitFor(() => offerRes2 != null);91 expect(offerRes2.connectionId).toBe(connectionId1);92 expect(offerRes2.polite).toBe(false);93 await signaling1.deleteConnection(connectionId1);94 await waitFor(() => disconnectRes1 != null);95 expect(disconnectRes1.connectionId).toBe(connectionId1);96 await signaling2.deleteConnection(connectionId2);97 await waitFor(() => disconnectRes2 != null);98 expect(disconnectRes2.connectionId).toBe(connectionId2);99 });100 test(`onAnswer using ${mode}`, async () => {101 let connectRes1;102 let disconnectRes1;103 let answerRes1;104 signaling1.addEventListener('connect', (e) => connectRes1 = e.detail);105 signaling1.addEventListener('disconnect', (e) => disconnectRes1 = e.detail);106 signaling1.addEventListener('answer', (e) => answerRes1 = e.detail);107 let connectRes2;108 let disconnectRes2;109 let offerRes2;110 signaling2.addEventListener('connect', (e) => connectRes2 = e.detail);111 signaling2.addEventListener('disconnect', (e) => disconnectRes2 = e.detail);112 signaling2.addEventListener('offer', (e) => offerRes2 = e.detail);113 await signaling1.createConnection(connectionId1);114 await signaling2.createConnection(connectionId2);115 await waitFor(() => connectRes1 != null && connectRes2 != null);116 await signaling1.sendOffer(connectionId1, testsdp);117 await waitFor(() => offerRes2 != null);118 expect(offerRes2.connectionId).toBe(connectionId1);119 expect(offerRes2.sdp).toBe(testsdp);120 signaling2.sendAnswer(connectionId1, testsdp);121 await waitFor(() => answerRes1 != null);122 expect(answerRes1.connectionId).toBe(connectionId1);123 expect(answerRes1.sdp).toBe(testsdp);124 await signaling1.deleteConnection(connectionId1);125 await waitFor(() => disconnectRes1 != null);126 await signaling2.deleteConnection(connectionId2);127 await waitFor(() => disconnectRes2 != null);128 });129 test(`onCandidate using ${mode}`, async () => {130 let connectRes1;131 let disconnectRes1;132 let answerRes1;133 let candidateRes1;134 signaling1.addEventListener('connect', (e) => connectRes1 = e.detail);135 signaling1.addEventListener('disconnect', (e) => disconnectRes1 = e.detail);136 signaling1.addEventListener('answer', (e) => answerRes1 = e.detail);137 signaling1.addEventListener('candidate', (e) => candidateRes1 = e.detail);138 let connectRes2;139 let disconnectRes2;140 let offerRes2;141 let candidateRes2;142 signaling2.addEventListener('connect', (e) => connectRes2 = e.detail);143 signaling2.addEventListener('disconnect', (e) => disconnectRes2 = e.detail);144 signaling2.addEventListener('offer', (e) => offerRes2 = e.detail);145 signaling2.addEventListener('candidate', (e) => candidateRes2 = e.detail);146 await signaling1.createConnection(connectionId1);147 await signaling2.createConnection(connectionId2);148 await waitFor(() => connectRes1 != null && connectRes2 != null);149 await signaling1.sendOffer(connectionId1, testsdp);150 await waitFor(() => offerRes2 != null);151 expect(offerRes2.connectionId).toBe(connectionId1);152 expect(offerRes2.sdp).toBe(testsdp);153 signaling2.sendAnswer(connectionId1, testsdp);154 await waitFor(() => answerRes1 != null);155 expect(answerRes1.connectionId).toBe(connectionId1);156 expect(answerRes1.sdp).toBe(testsdp);157 await signaling2.sendCandidate(connectionId1, testcandidate, 1, 1);158 await waitFor(() => candidateRes1 != null);159 expect(candidateRes1.connectionId).toBe(connectionId1);160 expect(candidateRes1.candidate).toBe(testcandidate);161 expect(candidateRes1.sdpMid).toBe(1);162 expect(candidateRes1.sdpMLineIndex).toBe(1);163 await signaling1.sendCandidate(connectionId1, testcandidate, 1, 1);164 await waitFor(() => candidateRes2 != null);165 expect(candidateRes2.connectionId).toBe(connectionId1);166 expect(candidateRes2.candidate).toBe(testcandidate);167 expect(candidateRes2.sdpMid).toBe(1);168 expect(candidateRes2.sdpMLineIndex).toBe(1);169 await signaling1.deleteConnection(connectionId1);170 await waitFor(() => disconnectRes1 != null);171 await signaling2.deleteConnection(connectionId2);172 await waitFor(() => disconnectRes2 != null);173 });174});175describe.each([176 { mode: "mock" },177 { mode: "http" },178 { mode: "websocket" },179])('signaling test in private mode', ({ mode }) => {180 let signaling1;181 let signaling2;182 const connectionId = "12345";183 const testsdp = "test sdp";184 const testcandidate = "test candidate";185 beforeAll(async () => {186 if (mode == "mock") {187 reset(true);188 signaling1 = new MockSignaling();189 signaling2 = new MockSignaling();190 return;191 }192 const path = Path.resolve(`../bin~/${serverExeName()}`);193 let cmd = `${path} -p ${portNumber} -m private`;194 if (mode == "websocket") {195 cmd += " -w";196 }197 await setup({ command: cmd, port: portNumber, usedPortAction: 'error' });198 if (mode == "http") {199 signaling1 = new Signaling();200 signaling2 = new Signaling();201 }202 if (mode == "websocket") {203 signaling1 = new WebSocketSignaling();204 signaling2 = new WebSocketSignaling();205 }206 await signaling1.start();207 await signaling2.start();208 });209 afterAll(async () => {210 await signaling1.stop();211 await signaling2.stop();212 signaling1 = null;213 signaling2 = null;214 if (mode == "mock") {215 return;216 }217 await teardown();218 // work around for linux, waitng kill server process219 await sleep(1000);220 });221 test(`onConnect using ${mode}`, async () => {222 let connectRes1;223 let disconnectRes1;224 signaling1.addEventListener('connect', (e) => connectRes1 = e.detail);225 signaling1.addEventListener('disconnect', (e) => disconnectRes1 = e.detail);226 let connectRes2;227 let disconnectRes2;228 signaling2.addEventListener('connect', (e) => connectRes2 = e.detail);229 signaling2.addEventListener('disconnect', (e) => disconnectRes2 = e.detail);230 await signaling1.createConnection(connectionId);231 await waitFor(() => connectRes1 != null);232 expect(connectRes1.connectionId).toBe(connectionId);233 expect(connectRes1.polite).toBe(false);234 await signaling2.createConnection(connectionId);235 await waitFor(() => connectRes2 != null);236 expect(connectRes2.connectionId).toBe(connectionId);237 expect(connectRes2.polite).toBe(true);238 await sleep(signaling1.interval * 2);239 await signaling1.deleteConnection(connectionId);240 await waitFor(() => disconnectRes1 != null && disconnectRes2 != null);241 expect(disconnectRes1.connectionId).toBe(connectionId);242 expect(disconnectRes2.connectionId).toBe(connectionId);243 disconnectRes2 = null;244 await signaling2.deleteConnection(connectionId);245 await waitFor(() => disconnectRes2 != null);246 });247 test(`onOffer using ${mode}`, async () => {248 let connectRes1;249 let disconnectRes1;250 signaling1.addEventListener('connect', (e) => connectRes1 = e.detail);251 signaling1.addEventListener('disconnect', (e) => disconnectRes1 = e.detail);252 let connectRes2;253 let disconnectRes2;254 let offerRes2;255 signaling2.addEventListener('connect', (e) => connectRes2 = e.detail);256 signaling2.addEventListener('disconnect', (e) => disconnectRes2 = e.detail);257 signaling2.addEventListener('offer', (e) => offerRes2 = e.detail);258 await signaling1.createConnection(connectionId);259 await waitFor(() => connectRes1 != null);260 expect(connectRes1.connectionId).toBe(connectionId);261 signaling1.sendOffer(connectionId, testsdp);262 await sleep(signaling1.interval * 2);263 // Do not receive offer other signaling if not connected same sendoffer connectionId in private mode264 expect(offerRes2).toBeUndefined();265 await signaling2.createConnection(connectionId);266 await waitFor(() => connectRes2 != null);267 expect(connectRes2.connectionId).toBe(connectionId);268 await signaling1.sendOffer(connectionId, testsdp);269 await waitFor(() => offerRes2 != null);270 expect(offerRes2.connectionId).toBe(connectionId);271 expect(offerRes2.polite).toBe(true);272 await signaling1.deleteConnection(connectionId);273 await waitFor(() => disconnectRes1 != null && disconnectRes2 != null);274 expect(disconnectRes1.connectionId).toBe(connectionId);275 expect(disconnectRes2.connectionId).toBe(connectionId);276 disconnectRes2 = null;277 await signaling2.deleteConnection(connectionId);278 await waitFor(() => disconnectRes2 != null);279 });280 test(`onAnswer using ${mode}`, async () => {281 let connectRes1;282 let disconnectRes1;283 let answerRes1;284 signaling1.addEventListener('connect', (e) => connectRes1 = e.detail);285 signaling1.addEventListener('disconnect', (e) => disconnectRes1 = e.detail);286 signaling1.addEventListener('answer', (e) => answerRes1 = e.detail);287 let connectRes2;288 let disconnectRes2;289 let offerRes2;290 signaling2.addEventListener('connect', (e) => connectRes2 = e.detail);291 signaling2.addEventListener('disconnect', (e) => disconnectRes2 = e.detail);292 signaling2.addEventListener('offer', (e) => offerRes2 = e.detail);293 await signaling1.createConnection(connectionId);294 await signaling2.createConnection(connectionId);295 await waitFor(() => connectRes1 != null && connectRes2 != null);296 await signaling1.sendOffer(connectionId, testsdp);297 await waitFor(() => offerRes2 != null);298 expect(offerRes2.connectionId).toBe(connectionId);299 expect(offerRes2.sdp).toBe(testsdp);300 await signaling2.sendAnswer(connectionId, testsdp);301 await waitFor(() => answerRes1 != null);302 expect(answerRes1.connectionId).toBe(connectionId);303 expect(answerRes1.sdp).toBe(testsdp);304 await signaling1.deleteConnection(connectionId);305 await waitFor(() => disconnectRes1 != null && disconnectRes2 != null);306 expect(disconnectRes1.connectionId).toBe(connectionId);307 expect(disconnectRes2.connectionId).toBe(connectionId);308 disconnectRes2 = null;309 await signaling2.deleteConnection(connectionId);310 await waitFor(() => disconnectRes2 != null);311 });312 test(`onCandidate using ${mode}`, async () => {313 let connectRes1;314 let disconnectRes1;315 let answerRes1;316 let candidateRes1;317 signaling1.addEventListener('connect', (e) => connectRes1 = e.detail);318 signaling1.addEventListener('disconnect', (e) => disconnectRes1 = e.detail);319 signaling1.addEventListener('answer', (e) => answerRes1 = e.detail);320 signaling1.addEventListener('candidate', (e) => candidateRes1 = e.detail);321 let connectRes2;322 let disconnectRes2;323 let offerRes2;324 let candidateRes2;325 signaling2.addEventListener('connect', (e) => connectRes2 = e.detail);326 signaling2.addEventListener('disconnect', (e) => disconnectRes2 = e.detail);327 signaling2.addEventListener('offer', (e) => offerRes2 = e.detail);328 signaling2.addEventListener('candidate', (e) => candidateRes2 = e.detail);329 await signaling1.createConnection(connectionId);330 await signaling2.createConnection(connectionId);331 await waitFor(() => connectRes1 != null && connectRes2 != null);332 await signaling1.sendOffer(connectionId, testsdp);333 await waitFor(() => offerRes2 != null);334 expect(offerRes2.connectionId).toBe(connectionId);335 expect(offerRes2.sdp).toBe(testsdp);336 await signaling2.sendAnswer(connectionId, testsdp);337 await waitFor(() => answerRes1 != null);338 expect(answerRes1.connectionId).toBe(connectionId);339 expect(answerRes1.sdp).toBe(testsdp);340 await signaling2.sendCandidate(connectionId, testcandidate, 1, 1);341 await waitFor(() => candidateRes1 != null);342 expect(candidateRes1.connectionId).toBe(connectionId);343 expect(candidateRes1.candidate).toBe(testcandidate);344 expect(candidateRes1.sdpMLineIndex).toBe(1);345 expect(candidateRes1.sdpMid).toBe(1);346 await signaling1.sendCandidate(connectionId, testcandidate, 1, 1);347 await waitFor(() => candidateRes2 != null);348 expect(candidateRes2.connectionId).toBe(connectionId);349 expect(candidateRes2.candidate).toBe(testcandidate);350 expect(candidateRes2.sdpMLineIndex).toBe(1);351 expect(candidateRes2.sdpMid).toBe(1);352 await signaling1.deleteConnection(connectionId);353 await waitFor(() => disconnectRes1 != null && disconnectRes2 != null);354 expect(disconnectRes1.connectionId).toBe(connectionId);355 expect(disconnectRes2.connectionId).toBe(connectionId);356 disconnectRes2 = null;357 await signaling2.deleteConnection(connectionId);358 await waitFor(() => disconnectRes2 != null);359 });360 test(`notReceiveOwnOfferAnswer using ${mode}`, async () => {361 let connectRes1;362 let disconnectRes1;363 let offerRes1;364 let answerRes1;365 signaling1.addEventListener('connect', (e) => connectRes1 = e.detail);366 signaling1.addEventListener('disconnect', (e) => disconnectRes1 = e.detail);367 let connectRes2;368 let disconnectRes2;369 let offerRes2;370 let answerRes2;371 signaling2.addEventListener('connect', (e) => connectRes2 = e.detail);372 signaling2.addEventListener('disconnect', (e) => disconnectRes2 = e.detail);373 await signaling1.createConnection(connectionId);374 await signaling2.createConnection(connectionId);375 await waitFor(() => connectRes1 != null && connectRes2 != null);376 signaling1.addEventListener('offer', (e) => offerRes1 = e.detail);377 signaling2.addEventListener('offer', (e) => offerRes2 = e.detail);378 await signaling1.sendOffer(connectionId, testsdp);379 await sleep(signaling1.interval * 2);380 expect(offerRes1).toBeUndefined();381 expect(offerRes2).not.toBeUndefined();382 expect(offerRes2.connectionId).toBe(connectionId);383 expect(offerRes2.sdp).toBe(testsdp);384 signaling1.addEventListener('answer', (e) => answerRes1 = e.detail);385 signaling2.addEventListener('answer', (e) => answerRes2 = e.detail);386 await signaling2.sendAnswer(connectionId, testsdp);387 await sleep(signaling2.interval * 2);388 expect(answerRes1).not.toBeUndefined();389 expect(answerRes1.connectionId).toBe(connectionId);390 expect(answerRes1.sdp).toBe(testsdp);391 expect(answerRes2).toBeUndefined();392 await signaling1.deleteConnection(connectionId);393 await waitFor(() => disconnectRes1 != null && disconnectRes2 != null);394 expect(disconnectRes1.connectionId).toBe(connectionId);395 expect(disconnectRes2.connectionId).toBe(connectionId);396 disconnectRes2 = null;397 await signaling2.deleteConnection(connectionId);398 await waitFor(() => disconnectRes2 != null);399 });...
TestSupplyChain.js
Source:TestSupplyChain.js
1const { before } = require("lodash");23const SupplyChain = artifacts.require("SupplyChain");4const truffleAssert = require('truffle-assertions');56var accounts;7var owner;89contract('SupplyChain', (accs) => {10 accounts = accs;11 owner = accounts[0];12});1314// Accounts15let acc_owner = accounts[0]; // Contract Owner account16let acc_farm_0 = accounts[1]; // Farm account17let acc_prod_0 = accounts[2]; // Producer account18let acc_insp_0 = accounts[3]; // Inspector account19let acc_dist_0 = accounts[4]; // Distributor account20let acc_cons_0 = accounts[5]; // Consumer account2122let instance = null;2324describe('Programmatic usage suite', function () {2526 describe('#index', function () {2728 it('can the Farmer plant a Grape', async function () {29 this.timeout(20000);3031 instance = await SupplyChain.deployed();32 await instance.addFarmer(acc_farm_0, { from: acc_owner });33 await instance.addProducer(acc_prod_0, { from: acc_owner });34 await instance.addInspector(acc_insp_0, { from: acc_owner });35 await instance.addDistributor(acc_dist_0, { from: acc_owner });36 await instance.addConsumer(acc_cons_0, { from: acc_owner });3738 let upc = 1;39 let ownerID = acc_farm_0;40 let originFarmerID = acc_farm_0;41 let originFarmName = "Aurora Farm";42 let originFarmInformation = "Bento Goncalves";43 let originFarmLatitude = "34.12345543";44 let originFarmLongitude = "34.12345543";45 let harvestNotes = "";46 let auditNotes = "";47 let itemState = 0;4849 // Plant a Grape50 let plant = await instance.grapePlantItem(upc,51 originFarmerID,52 originFarmName,53 originFarmInformation,54 originFarmLatitude,55 originFarmLongitude,56 { from: acc_farm_0 });5758 // Read the result from blockchain59 let res1 = await instance.fetchGrapeItemBufferOne.call(upc);60 let res2 = await instance.fetchGrapeItemBufferTwo.call(upc);61 // console.log(res1, 'result buffer 1');62 // console.log(res2, 'result buffer 2');6364 // Check results65 assert.equal(res1.upc, upc, 'Error: Invalid item UPC');66 assert.equal(res1.ownerID, ownerID, 'Error: Missing or Invalid ownerID');67 assert.equal(res1.originFarmerID, originFarmerID, 'Error: Missing or Invalid originFarmerID');68 assert.equal(res1.originFarmName, originFarmName, 'Error: Missing or Invalid originFarmName');69 assert.equal(res1.originFarmInformation, originFarmInformation, 'Error: Missing or Invalid originFarmInformation');70 assert.equal(res1.originFarmLatitude, originFarmLatitude, 'Error: Missing or Invalid originFarmLatitude');71 assert.equal(res1.originFarmLongitude, originFarmLongitude, 'Error: Missing or Invalid originFarmLongitude');72 assert.equal(res2.harvestNotes, harvestNotes, 'Error: Missing or Invalid harvestNotes');73 assert.equal(res2.auditNotes, auditNotes, 'Error: Missing or Invalid auditNotes');74 assert.equal(res2.itemState, itemState, 'Error: Invalid item State');75 truffleAssert.eventEmitted(plant, 'GrapePlanted');76 });777879 it('can the Farmer harvest a Grape', async function () {80 this.timeout(20000);81 let upc = 1;82 let ownerID = acc_farm_0;83 let originFarmerID = acc_farm_0;84 let harvestNotes = "bordo wine";85 let itemState = 1;86 let harvest = await instance.grapeHarvestItem(upc, harvestNotes, { from: acc_farm_0 });8788 // Read the result from blockchain89 let res1 = await instance.fetchGrapeItemBufferOne.call(upc);90 let res2 = await instance.fetchGrapeItemBufferTwo.call(upc);91 // console.log(res1, 'result buffer 1');92 // console.log(res2, 'result buffer 2');9394 assert.equal(res1.upc, upc, 'Error: Invalid item UPC');95 assert.equal(res1.ownerID, ownerID, 'Error: Missing or Invalid ownerID');96 assert.equal(res1.originFarmerID, originFarmerID, 'Error: Missing or Invalid originFarmerID');97 assert.equal(res2.harvestNotes, harvestNotes, 'Error: Missing or Invalid harvestNotes');98 assert.equal(res2.itemState, itemState, 'Error: Invalid item State');99 truffleAssert.eventEmitted(harvest, 'GrapeHarvested');100 });101102 it('can the Inspector audit a Grape', async function () {103 this.timeout(20000);104 let upc = 1;105 let ownerID = acc_farm_0;106 let originFarmerID = acc_farm_0;107 let auditNotes = "ISO9002 audit passed";108 let itemState = 2;109 let audited = await instance.grapeAuditItem(upc, auditNotes, { from: acc_insp_0 });110111 // Read the result from blockchain112 let res1 = await instance.fetchGrapeItemBufferOne.call(upc);113 let res2 = await instance.fetchGrapeItemBufferTwo.call(upc);114 // console.log(res1, 'result buffer 1');115 // console.log(res2, 'result buffer 2');116117 assert.equal(res1.upc, upc, 'Error: Invalid item UPC');118 assert.equal(res1.ownerID, ownerID, 'Error: Missing or Invalid ownerID');119 assert.equal(res1.originFarmerID, originFarmerID, 'Error: Missing or Invalid originFarmerID');120 assert.equal(res2.auditNotes, auditNotes, 'Error: Missing or Invalid auditNotes');121 assert.equal(res2.itemState, itemState, 'Error: Invalid item State');122 truffleAssert.eventEmitted(audited, 'GrapeAudited');123 });124125 it('can the Farm process a Grape', async function () {126 this.timeout(20000);127 let upc = 1;128 let ownerID = acc_farm_0;129 let originFarmerID = acc_farm_0;130 let itemState = 3;131 let processed = await instance.grapeProcessItem(upc, { from: acc_farm_0 });132133 // Read the result from blockchain134 let res1 = await instance.fetchGrapeItemBufferOne.call(upc);135 let res2 = await instance.fetchGrapeItemBufferTwo.call(upc);136 // console.log(res1, 'result buffer 1');137 // console.log(res2, 'result buffer 2');138139 assert.equal(res1.upc, upc, 'Error: Invalid item UPC');140 assert.equal(res1.ownerID, ownerID, 'Error: Missing or Invalid ownerID');141 assert.equal(res1.originFarmerID, originFarmerID, 'Error: Missing or Invalid originFarmerID');142 assert.equal(res2.itemState, itemState, 'Error: Invalid item State');143 truffleAssert.eventEmitted(processed, 'GrapeProcessed');144 });145146 it('can the Producer create a Juice', async function () {147 this.timeout(20000);148 let upc = 1;149 let productID = 1001;150 let ownerID = acc_prod_0;151 let itemState = 0;152 let created = await instance.juiceCreateItem(upc, productID, { from: acc_prod_0 });153154 // Read the result from blockchain155 let res1 = await instance.fetchJuiceItemBufferOne.call(upc);156 // console.log(res1, 'result buffer 1');157158 assert.equal(res1.upc, upc, 'Error: Invalid item UPC');159 assert.equal(res1.ownerID, ownerID, 'Error: Missing or Invalid ownerID');160 assert.equal(res1.productID, productID, 'Error: Missing or Invalid productID');161 assert.equal(res1.itemState, itemState, 'Error: Invalid item State');162 truffleAssert.eventEmitted(created, 'JuiceCreated');163 });164165 it('can the Producer blend a Juice', async function () {166 this.timeout(20000);167 let juiceUpc = 1;168 let grapeUpc = 1;169 let productID = 1001;170 let ownerID = acc_prod_0;171 let itemState = 1;172 let blended = await instance.juiceBlendItem(juiceUpc, grapeUpc, { from: acc_prod_0 });173174 // Read the result from blockchain175 let res1 = await instance.fetchJuiceItemBufferOne.call(juiceUpc);176 // console.log(res1, 'result buffer 1');177 // console.log(res1.grapes, 'grapes');178179 assert.equal(res1.upc, juiceUpc, 'Error: Invalid item UPC');180 assert.equal(res1.ownerID, ownerID, 'Error: Missing or Invalid ownerID');181 assert.equal(res1.productID, productID, 'Error: Missing or Invalid productID');182 assert.equal(res1.itemState, itemState, 'Error: Invalid item State');183 assert.equal(res1.grapes[0], grapeUpc, 'Error: Invalid item grapeUpc');184 truffleAssert.eventEmitted(blended, 'JuiceBlended');185 });186187 it('can the Producer produce a Juice', async function () {188 this.timeout(20000);189 let juiceUpc = 1;190 let productNotes = "Organic Grape Juice";191 let productPrice = 26;192 let ownerID = acc_prod_0;193 let itemState = 2;194 let produced = await instance.juiceProduceItem(juiceUpc, productNotes, productPrice, { from: acc_prod_0 });195196 // Read the result from blockchain197 let res1 = await instance.fetchJuiceItemBufferOne.call(juiceUpc);198 // console.log(res1, 'result buffer 1');199 // console.log(res1.grapes, 'grapes');200201 assert.equal(res1.upc, juiceUpc, 'Error: Invalid item UPC');202 assert.equal(res1.ownerID, ownerID, 'Error: Missing or Invalid ownerID');203 assert.equal(res1.productNotes, productNotes, 'Error: Missing or Invalid productNotes');204 assert.equal(res1.productPrice, productPrice, 'Error: Missing or Invalid productPrice');205 assert.equal(res1.itemState, itemState, 'Error: Invalid item State');206 truffleAssert.eventEmitted(produced, 'JuiceProduced');207 });208209 it('can the Inspector certify a Juice', async function () {210 this.timeout(20000);211 let juiceUpc = 1;212 let certifyNotes = "ISO9002 Certified";213 let ownerID = acc_prod_0;214 let itemState = 3;215 let certified = await instance.juiceCertifyItem(juiceUpc, certifyNotes, { from: acc_insp_0 });216217 // Read the result from blockchain218 let res1 = await instance.fetchJuiceItemBufferOne.call(juiceUpc);219 // console.log(res1, 'result buffer 1');220 // console.log(res1.grapes, 'grapes');221222 assert.equal(res1.upc, juiceUpc, 'Error: Invalid item UPC');223 assert.equal(res1.ownerID, ownerID, 'Error: Missing or Invalid ownerID');224 assert.equal(res1.certifyNotes, certifyNotes, 'Error: Missing or Invalid certifyNotes');225 assert.equal(res1.itemState, itemState, 'Error: Invalid item State');226 truffleAssert.eventEmitted(certified, 'JuiceCertified');227 });228229 it('can the Producer pack a Juice', async function () {230 this.timeout(20000);231 let juiceUpc = 1;232 let ownerID = acc_prod_0;233 let itemState = 4;234 let packed = await instance.juicePackItem(juiceUpc, { from: acc_prod_0 });235236 // Read the result from blockchain237 let res1 = await instance.fetchJuiceItemBufferOne.call(juiceUpc);238 // console.log(res1, 'result buffer 1');239 // console.log(res1.grapes, 'grapes');240241 assert.equal(res1.upc, juiceUpc, 'Error: Invalid item UPC');242 assert.equal(res1.ownerID, ownerID, 'Error: Missing or Invalid ownerID');243 assert.equal(res1.itemState, itemState, 'Error: Invalid item State');244 truffleAssert.eventEmitted(packed, 'JuicePacked');245 });246247 it('can the Distributor sell a Juice', async function () {248 this.timeout(20000);249 let juiceUpc = 1;250 let ownerID = acc_prod_0;251 let itemState = 5;252 let forsale = await instance.juiceSellItem(juiceUpc, { from: acc_dist_0 });253254 // Read the result from blockchain255 let res1 = await instance.fetchJuiceItemBufferOne.call(juiceUpc);256 // console.log(res1, 'result buffer 1');257 // console.log(res1.grapes, 'grapes');258259 assert.equal(res1.upc, juiceUpc, 'Error: Invalid item UPC');260 assert.equal(res1.ownerID, ownerID, 'Error: Missing or Invalid ownerID');261 assert.equal(res1.itemState, itemState, 'Error: Invalid item State');262 truffleAssert.eventEmitted(forsale, 'JuiceForSale');263 });264265 it('can the Consumer buy a Juice', async function () {266 this.timeout(20000);267 let juiceUpc = 1;268 let ownerID = acc_cons_0;269 let itemState = 6;270 let res1 = await instance.fetchJuiceItemBufferOne.call(juiceUpc);271 let purchased = await instance.juiceBuyItem(juiceUpc, { from: acc_cons_0, value: res1.productPrice });272273 // Read the result from blockchain274 res1 = await instance.fetchJuiceItemBufferOne.call(juiceUpc);275 // console.log(res1, 'result buffer 1');276 // console.log(res1.grapes, 'grapes');277278 assert.equal(res1.upc, juiceUpc, 'Error: Invalid item UPC');279 assert.equal(res1.ownerID, ownerID, 'Error: Missing or Invalid ownerID');280 assert.equal(res1.itemState, itemState, 'Error: Invalid item State');281 truffleAssert.eventEmitted(purchased, 'JuicePurchased');282 });283 });
...
gameofflavours.js
Source:gameofflavours.js
1$(document).ready(function() {2 var datatopost = {};34 $("#gotosecondscreen").click(function() {5 $(".step1").hide();6 $(".step2").show();7 });89 $("#gotothirdscreen").click(function() {10 $(".step2").hide();11 $(".step3").show();12 });1314 $("#gotofifthscreen").click(function() {15 $(".step4").hide();16 $(".step5").show();17 });1819 $("#gotosevenscreen").click(function() {20 $(".step6").hide();21 $(".step7").show();22 });2324 $("#gotoninethscreen").click(function() {25 $(".step8").hide();26 $(".step9").show();27 });282930 $("#gotolastscreen").click(function() {31 $(".step9").hide();32 $(".step10").show();33 });3435 $(".answer1").click(function() {36 datatopost.ans1 = $(this).attr("data-item");37 //Resturants ID Fetch38 res1 = $('#votRes1D').attr("data-item");39 res2 = $('#votRes2D').attr("data-item");40 max = 0;41 //Resturant 142 //Question 1 Fetch43 count = $('#res1_q1_count').attr("data-item");44 total = $('#res1_q1_total_count').attr("data-item");4546 //Question 1 calculation47 total++;48 (datatopost.ans1 == res1) && count++;49 max = count;5051 //Question 1 Result Assignment52 $('#res1_q1_per,#r1_q1_per').html(((count / total) * 100).toFixed(2));53 $('#res1_q1_count,#r1_q1_count').html(count);54 $('#res1_q1_total_count,#r1_q1_total_count').html(total);5556 //Resturant 257 //Question 1 Fetch58 count = $('#res2_q1_count').attr("data-item");59 total = $('#res2_q1_total_count').attr("data-item");6061 //Question 1 calculation62 total++;63 (datatopost.ans1 == res2) && count++;64 (count > max) && (max = count);6566 //Question 1 Result Assignment67 $('#res2_q1_per,#r2_q1_per').html(((count / total) * 100).toFixed(2));68 $('#res2_q1_count,#r2_q1_count').html(count);69 $('#res2_q1_total_count,#r2_q1_total_count').html(total);7071 //Question 1 Winner Result Assignment72 $('#max_q1_win').html('<span id="winner_count">' + max + '</span>/<span class="total_count">' + total + '</span> votes');737475 $(".step3").hide();76 $(".step4").show();77 });7879 $(".answer2").click(function() {80 datatopost.ans2 = $(this).attr("data-item");81 //Resturants ID Fetch82 res1 = $('#votRes1D').attr("data-item");83 res2 = $('#votRes2D').attr("data-item");84 max = 0;8586 //Resturant 187 //Question 2 Fetch88 count = $('#res1_q2_count').attr("data-item");89 total = $('#res1_q2_total_count').attr("data-item");9091 //Question 2 calculation92 total++;93 (datatopost.ans2 == res1) && count++;94 max = count;9596 //Question 2 Result Assignment97 $('#res1_q2_per,#r1_q2_per').html(((count / total) * 100).toFixed(2));98 $('#res1_q2_count,#r1_q2_count').html(count);99 $('#res1_q2_total_count,#r1_q2_total_count').html(total);100101 //Resturant 2102 //Question 2 Fetch103 count = $('#res2_q2_count').attr("data-item");104 total = $('#res2_q2_total_count').attr("data-item");105106 //Question 2 calculation107 total++;108 (datatopost.ans2 == res2) && count++;109 (count > max) && (max = count);110111 //Question 2 Result Assignment112 $('#res2_q2_per,#r2_q2_per').html(((count / total) * 100).toFixed(2));113 $('#res2_q2_count,#r2_q2_count').html(count);114 $('#res2_q2_total_count,#r2_q2_total_count').html(total);115116 //Question 2 Winner Result Assignment117 $('#max_q2_win').html('<span id="winner_count">' + max + '</span>/<span class="total_count">' + total + '</span> votes');118119 $(".step5").hide();120 $(".step6").show();121 });122123 $(".answer3").click(function() {124 datatopost.ans3 = $(this).attr("data-item");125 datatopost.votid = $("#vot_id").val();126 127 //Resturants ID Fetch128 res1 = $('#votRes1D').attr("data-item");129 res2 = $('#votRes2D').attr("data-item");130 max = 0;131132 //Resturant 1133 //Question 3 Fetch134 count = $('#res1_q3_count').attr("data-item");135 total = $('#res1_q3_total_count').attr("data-item");136137 //Question 3 calculation138 total++;139 (datatopost.ans3 == res1) && count++;140 max = count;141142 //Question 3 Result Assignment143 $('#res1_q3_per,#r1_q3_per').html(((count / total) * 100).toFixed(2));144 $('#res1_q3_count,#r1_q3_count').html(count);145 $('#res1_q3_total_count,#r1_q3_total_count').html(total);146147 //Resturant 2148 //Question 3 Fetch149 count = $('#res2_q3_count').attr("data-item");150 total = $('#res2_q3_total_count').attr("data-item");151152 //Question 3 calculation153 (datatopost.ans3 == res2) && count++;154 (count > max) && (max = count);155 total++;156157158 //Question 3 Result Assignment159 $('#res2_q3_per,#r2_q3_per').html(((count / total) * 100).toFixed(2));160 $('#res2_q3_count,#r2_q3_count').html(count);161 $('#res2_q3_total_count,#r2_q3_total_count').html(total);162163 //Question 3 Winner Result Assignment164 $('#max_q3_win').html('<span id="winner_count">' + max + '</span>/<span class="total_count">' + total + '</span> votes');165166 //Winner result fetch167 $res1_score = $('#res1_score').attr('data-item');168 $score_count = $('#res1_score').attr('data-total');169 $res2_score = $('#res2_score').attr('data-item');170 $score_count++;171 $res1_diff=0;172 $res2_diff=0;173 if (datatopost.ans1 == res1 && datatopost.ans2 == res1 && datatopost.ans3 == res1) {174 $res1_score++;175 datatopost.diff3=res1;176 datatopost.diff0=res2;177 } else if ((datatopost.ans1 == res1 && datatopost.ans2 == res1) || (datatopost.ans1 == res1 && datatopost.ans3 == res1)) {178 $res1_score++;179 datatopost.diff1=res2;180 datatopost.diff2=res1;181 } else if ((datatopost.ans1 == res2 && datatopost.ans2 == res2) || (datatopost.ans1 == res2 && datatopost.ans3 == res2)) {182 datatopost.diff1=res1;183 datatopost.diff2=res2;184 $res2_score++;185 186 } else {187 $res2_score++;188 datatopost.diff3=res2;189 datatopost.diff0=res1;190 }191 ($res1_score >= ($score_count / 2)) ? $('#res1_score').html("1"): $('#res1_score').html("0");192 ($res2_score >= ($score_count / 2)) ? $('#res2_score').html("1"): $('#res2_score').html("0");193 if ($res1_score == $res2_score) {194 $('#final_score').html('DRAW');195 } else if ($res1_score > $res2_score) {196 $('#final_score').html($('#res1_score').attr('data-name'));197 } else {198 $('#final_score').html($('#res2_score').attr('data-name'));199 }200201 $(".step7").hide();202 $(".step8").show();203 var diff=$res1_score-$res2_score;204 console.log("difference", diff);205 console.log($res1_score);206 console.log($res2_score);207 208 $.post("/wgs2020/main.php/polling", datatopost, function(e) {209 console.log(e);210 });211212 });213214
...
qm.js
Source:qm.js
1var expectThrow = require('./helper.js');2const Quiz = artifacts.require("Quiz");3contract("Quiz", async(accounts) => {4 var quiz;5 it("tests that two people can't register as quiz master", async () => {6 quiz = await Quiz.new({from: accounts[0]});7 let res1 = await quiz.register_quiz_master({from: accounts[0]});8 let res2 = quiz.register_quiz_master({from: accounts[1]});9 await expectThrow(res2);10 })11 it("tests that only quiz master can add questions", async () => {12 let res1 = quiz.add_question("Which is the greatest? - 1. 1 2. 2 3. 3 4. 4", 4, {from: accounts[1]});13 await expectThrow(res1);14 })15 it("tests for questions with valid answers", async () => {16 let res1 = quiz.add_question("Which is the greatest? - 1. 1 2. 2 3. 3 4. 4", 5, {from: accounts[0]});17 await expectThrow(res1);18 })19 it("tests that player can't register before start of registration", async () => {20 let res1 = quiz.register_player({from: accounts[1]});21 await expectThrow(res1);22 })23 it("tests that quiz master can't add questions after start of registration", async () => {24 let res4 = await quiz.add_question("Which is the greatest? - 1. 1 2. 2 3. 3 4. 4", 4, {from: accounts[0]});25 let res5 = await quiz.add_question("Which is the smallest? - 1. 1 2. 2 3. 3 4. 4", 1, {from: accounts[0]});26 let res6 = await quiz.add_question("Which is an even prime? - 1. 1 2. 2 3. 3 4. 4", 2, {from: accounts[0]});27 let res7 = await quiz.add_question("Which is an odd prime? - 1. 1 2. 2 3. 3 4. 4", 3, {from: accounts[0]});28 let res1 = await quiz.start_registration(10, 10, 40, {from: accounts[0]});29 let res2 = await quiz.register_player({from: accounts[1]});30 let res3 = quiz.add_question("Which is an even prime? - 1. 1 2. 2 3. 3 4. 4", 2, {from: accounts[0]});31 await expectThrow(res3);32 })33 it("tests that player can't pay arbitrary fee", async () => {34 let res1 = quiz.pay_reg_fee({from: accounts[1], value: 10e18});35 await expectThrow(res1);36 })37 it("tests that player can pay fee", async () => {38 let res1 = await quiz.pay_reg_fee({from: accounts[1], value: 16e18});39 })40 it("tests that quizmaster can't participate in quiz", async () => {41 let res1 = quiz.register_player({from: accounts[0]});42 await expectThrow(res1);43 })44 it("tests that players doesn't get question before quiz starts", async () => {45 let res1 = quiz.get_question({from: accounts[1]});46 await expectThrow(res1);47 })48 it("tests that players get question after quiz starts", async () => {49 var T = 10;50 while (T--) {51 await quiz.get_current_block();52 }53 let res1 = await quiz.get_question({from: accounts[1]});54 })55 it("tests that the player can submit an answer within question deadline", async () => {56 let res1 = await quiz.submit_answer(1, 4, {from: accounts[1]});57 })58 it("tests that an unregistered player cannot submit an answer", async () => {59 let res1 = quiz.submit_answer(1, 4, {from: accounts[3]});60 await expectThrow(res1);61 })62 it("tests that the player cannot submit an answer after question deadline", async () => {63 var T = 20;64 while (T--) {65 await quiz.get_current_block();66 }67 let res1 = quiz.submit_answer(2, 4, {from: accounts[1]});68 await expectThrow(res1); 69 })70 71 it("tests that the player cannot collect reward before quiz ends", async () => {72 let res1 = quiz.get_reward({from: accounts[1]});73 await expectThrow(res1); 74 })75 76 it("tests that the player and the quiz master can collect reward after quiz gets over", async () => {77 var T = 20;78 while (T--) {79 await quiz.get_current_block();80 }81 let res1 = await quiz.get_reward({from: accounts[1]});82 let res2 = await quiz.get_reward({from: accounts[0]});83 // await expectThrow(res1); 84 })85 it("tests that the player cannot collect reward twice", async () => {86 let res1 = quiz.get_reward({from: accounts[1]});87 await expectThrow(res1); 88 })...
Using AI Code Generation
1var res1 = require('wpt').res1;2var res2 = require('wpt').res2;3var res3 = require('wpt').res3;4var res4 = require('wpt').res4;5var res5 = require('wpt').res5;6var res6 = require('wpt').res6;7var res7 = require('wpt').res7;8var res8 = require('wpt').res8;9var res9 = require('wpt').res9;10var res10 = require('wpt').res10;11var res11 = require('wpt').res11;12var res12 = require('wpt').res12;13var res13 = require('wpt').res13;14var res14 = require('wpt').res14;15var res15 = require('wpt').res15;16var res16 = require('wpt').res16;17var res17 = require('wpt').res17;18var res18 = require('wpt').res18;19var res19 = require('wpt').res19;20var res20 = require('wpt').res20;21var res21 = require('wpt').res21;22var res22 = require('wpt').res22;
Using AI Code Generation
1const wpt = require('wpt');2const res1 = wpt.res1;3const res2 = wpt.res2;4const res3 = wpt.res3;5const res4 = wpt.res4;6const res5 = wpt.res5;7const res6 = wpt.res6;8const res7 = wpt.res7;9const res8 = wpt.res8;10const res9 = wpt.res9;11const res10 = wpt.res10;12const res11 = wpt.res11;13const res12 = wpt.res12;14const res13 = wpt.res13;15const res14 = wpt.res14;16const res15 = wpt.res15;17const res16 = wpt.res16;18const res17 = wpt.res17;19const res18 = wpt.res18;20const res19 = wpt.res19;21const res20 = wpt.res20;22const res21 = wpt.res21;23const res22 = wpt.res22;24const res23 = wpt.res23;25const res24 = wpt.res24;26const res25 = wpt.res25;27const res26 = wpt.res26;28const res27 = wpt.res27;29const res28 = wpt.res28;30const res29 = wpt.res29;31const res30 = wpt.res30;32const res31 = wpt.res31;33const res32 = wpt.res32;34const res33 = wpt.res33;35const res34 = wpt.res34;36const res35 = wpt.res35;37const res36 = wpt.res36;38const res37 = wpt.res37;39const res38 = wpt.res38;40const res39 = wpt.res39;41const res40 = wpt.res40;42const res41 = wpt.res41;43const res42 = wpt.res42;44const res43 = wpt.res43;45const res44 = wpt.res44;46const res45 = wpt.res45;47const res46 = wpt.res46;48const res47 = wpt.res47;49const res48 = wpt.res48;50const res49 = wpt.res49;51const res50 = wpt.res50;52const res51 = wpt.res51;53const res52 = wpt.res52;54const res53 = wpt.res53;55const res54 = wpt.res54;
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9{ [Error: getaddrinfo ENOTFOUND www.webpagetest.org www.webpagetest.org:80]10 port: 80 }11var WebPageTest = require('webpagetest');12var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 }18});19var WebPageTest = require('webpagetest');20var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');21 if (err) {22 console.log(err);23 } else {24 console.log(data);25 }26});27var WebPageTest = require('webpagetest');28var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');29 if (err) {30 console.log(err);31 } else {32 console.log(data);
Using AI Code Generation
1var wpt2 = require('./wpt2.js');2var res1 = wpt2.res1;3res1();4var res1 = function(){5 console.log("res1");6}7module.exports = {8}9var wpt2 = require('./wpt2.js');10var res1 = wpt2.res1;11var res2 = wpt2.res2;12res1();13res2();14var res1 = function(){15 console.log("res1");16}17var res2 = function(){18 console.log("res2");19}20module.exports = {21}22var wpt2 = require('./wpt2.js');23var res1 = wpt2.res1;24var res2 = wpt2.res2;25res1();26res2();27var res1 = function(){28 console.log("res1");29}30var res2 = function(){31 console.log("res2");32}33module.exports = {34}35var wpt2 = require('./wpt2.js');
Using AI Code Generation
1var wpt1 = require("./wpt1");2var res1 = wpt1.res1;3res1();4var res1 = function() {5 console.log("res1");6}7module.exports = {8}9var res1 = function() {10 console.log("res1");11}12module.exports = {13}14var res1 = function() {15 console.log("res1");16}17module.exports = {18}19var res1 = function() {20 console.log("res1");21}22module.exports = {23}24var res1 = function() {25 console.log("res1");26}27module.exports = {28}29var res1 = function() {30 console.log("res1");31}32module.exports = {33}34var res1 = function() {35 console.log("res1");36}37module.exports = {38}39var res1 = function() {40 console.log("res1");41}42module.exports = {43}44var res1 = function() {45 console.log("res1");46}47module.exports = {48}49var res1 = function() {50 console.log("res1");51}52module.exports = {53}54var res1 = function() {55 console.log("res1");56}57module.exports = {58}59var res1 = function() {60 console.log("res1");61}62module.exports = {63}64var res1 = function() {65 console.log("res1");66}67module.exports = {68}69var res1 = function() {
Using AI Code Generation
1var wpt1 = require('./wpt1.js');2var res1 = wpt1.res1;3res1();4module.exports.res1 = function() {5 console.log("res1");6};7module.exports.res2 = function() {8 console.log("res2");9};10module.exports.res3 = function() {11 console.log("res3");12};13module.exports.res4 = function() {14 console.log("res4");15};16module.exports.res5 = function() {17 console.log("res5");18};19module.exports.res6 = function() {20 console.log("res6");21};22module.exports.res7 = function() {23 console.log("res7");24};25module.exports.res8 = function() {26 console.log("res8");27};28module.exports.res9 = function() {29 console.log("res9");30};31module.exports.res10 = function() {32 console.log("res10");33};34module.exports.res11 = function() {35 console.log("res11");36};37module.exports.res12 = function() {38 console.log("res12");39};40module.exports.res13 = function() {41 console.log("res13");42};43module.exports.res14 = function() {44 console.log("res14");45};46module.exports.res15 = function() {47 console.log("res15");48};
Using AI Code Generation
1var wpt = require('wpt');2var res1 = wpt.res1;3res1('www.google.com', function(err, data) {4if(err) console.log(err);5else console.log(data);6});7var wpt = require('wpt');8var res2 = wpt.res2;9res2('www.google.com', function(err, data) {10if(err) console.log(err);11else console.log(data);12});13var wpt = require('wpt');14var res3 = wpt.res3;15res3('www.google.com', function(err, data) {16if(err) console.log(err);17else console.log(data);18});19var wpt = require('wpt');20var res4 = wpt.res4;21res4('www.google.com', function(err, data) {22if(err) console.log(err);23else console.log(data);24});25var wpt = require('wpt');26var res5 = wpt.res5;27res5('www.google.com', function(err, data) {28if(err) console.log(err);29else console.log(data);30});31var wpt = require('wpt');32var res6 = wpt.res6;33res6('www.google.com', function(err, data) {34if(err) console.log(err);35else console.log(data);36});37var wpt = require('wpt');38var res7 = wpt.res7;39res7('www.google.com', function(err, data) {40if(err) console.log(err);41else console.log(data);42});43var wpt = require('wpt');44var res8 = wpt.res8;45res8('www.google.com', function(err, data) {46if(err) console.log(err);47else console.log(data);48});
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new wpt('your api key');3 console.log(data);4});5 console.log(data);6});
Using AI Code Generation
1var wpt = require('wpt');2 console.log(data);3});4var wpt = require('wpt');5 console.log(data);6});7var wpt = require('wpt');8 console.log(data);9});10var wpt = require('wpt');11 console.log(data);12});13var wpt = require('wpt');14 console.log(data);15});16var wpt = require('wpt');17 console.log(data);18});19var wpt = require('wpt');20 console.log(data);21});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!