How to use beacon2 method in wpt

Best JavaScript code snippet using wpt

BeaconsClientV1Fixture.ts

Source:BeaconsClientV1Fixture.ts Github

copy

Full Screen

1const _ = require('lodash');2const async = require('async');3let assert = require('chai').assert;4import { FilterParams } from 'pip-services3-commons-node';5import { PagingParams } from 'pip-services3-commons-node';6import { BeaconV1 } from 'pip-services-beacons-node';7import { BeaconTypeV1 } from 'pip-services-beacons-node';8import { IBeaconsClientV1 } from '../../src/version1/IBeaconsClientV1';9const BEACON1: BeaconV1 = {10 id: '1',11 udi: '00001',12 type: BeaconTypeV1.AltBeacon,13 site_id: '1',14 label: 'TestBeacon1',15 center: { type: 'Point', coordinates: [ 0, 0 ] },16 radius: 5017};18const BEACON2: BeaconV1 = {19 id: '2',20 udi: '00002',21 type: BeaconTypeV1.iBeacon,22 site_id: '1',23 label: 'TestBeacon2',24 center: { type: 'Point', coordinates: [ 2, 2 ] },25 radius: 7026};27export class BeaconsClientV1Fixture {28 private _client: IBeaconsClientV1;29 public constructor(client: IBeaconsClientV1) {30 assert.isNotNull(client);31 this._client = client;32 }33 public testCrudOperations(done) {34 let beacon1: BeaconV1;35 async.series([36 // Create the first beacon37 (callback) => {38 this._client.createBeacon(39 null,40 BEACON1,41 (err, beacon) => {42 assert.isNull(err);43 assert.isObject(beacon);44 assert.equal(BEACON1.udi, beacon.udi);45 assert.equal(BEACON1.site_id, beacon.site_id);46 assert.equal(BEACON1.type, beacon.type);47 assert.equal(BEACON1.label, beacon.label);48 assert.isNotNull(beacon.center);49 callback();50 }51 );52 },53 // Create the second beacon54 (callback) => {55 this._client.createBeacon(56 null,57 BEACON2,58 (err, beacon) => {59 assert.isNull(err);60 assert.isObject(beacon);61 assert.equal(BEACON2.udi, beacon.udi);62 assert.equal(BEACON2.site_id, beacon.site_id);63 assert.equal(BEACON2.type, beacon.type);64 assert.equal(BEACON2.label, beacon.label);65 assert.isNotNull(beacon.center);66 callback();67 }68 );69 },70 // Get all beacons71 (callback) => {72 this._client.getBeacons(73 null,74 new FilterParams(),75 new PagingParams(),76 (err, page) => {77 assert.isNull(err);78 assert.isObject(page);79 assert.lengthOf(page.data, 2);80 beacon1 = page.data[0];81 callback();82 }83 )84 },85 // Update the beacon86 (callback) => {87 beacon1.label = 'ABC';88 this._client.updateBeacon(89 null,90 beacon1,91 (err, beacon) => {92 assert.isNull(err);93 assert.isObject(beacon);94 assert.equal(beacon1.id, beacon.id);95 assert.equal('ABC', beacon.label);96 callback();97 }98 )99 },100 // Get beacon by udi101 (callback) => {102 this._client.getBeaconByUdi(103 null, 104 beacon1.udi,105 (err, beacon) => {106 assert.isNull(err);107 assert.isObject(beacon);108 assert.equal(beacon1.id, beacon.id);109 callback();110 }111 )112 },113 // Delete the beacon114 (callback) => {115 this._client.deleteBeaconById(116 null,117 beacon1.id,118 (err, beacon) => {119 assert.isNull(err);120 assert.isObject(beacon);121 assert.equal(beacon1.id, beacon.id);122 callback();123 }124 )125 },126 // Try to get deleted beacon127 (callback) => {128 this._client.getBeaconById(129 null,130 beacon1.id,131 (err, beacon) => {132 assert.isNull(err);133 assert.isNull(beacon || null);134 callback();135 }136 )137 }138 ], done);139 }140 public testCalculatePosition(done) {141 async.series([142 // Create the first beacon143 (callback) => {144 this._client.createBeacon(145 null,146 BEACON1,147 (err, beacon) => {148 assert.isNull(err);149 assert.isObject(beacon);150 assert.equal(BEACON1.udi, beacon.udi);151 assert.equal(BEACON1.site_id, beacon.site_id);152 assert.equal(BEACON1.type, beacon.type);153 assert.equal(BEACON1.label, beacon.label);154 assert.isNotNull(beacon.center);155 callback();156 }157 );158 },159 // Create the second beacon160 (callback) => {161 this._client.createBeacon(162 null,163 BEACON2,164 (err, beacon) => {165 assert.isNull(err);166 assert.isObject(beacon);167 assert.equal(BEACON2.udi, beacon.udi);168 assert.equal(BEACON2.site_id, beacon.site_id);169 assert.equal(BEACON2.type, beacon.type);170 assert.equal(BEACON2.label, beacon.label);171 assert.isNotNull(beacon.center);172 callback();173 }174 );175 },176 // Calculate position for one beacon177 (callback) => {178 this._client.calculatePosition(179 null, '1', ['00001'],180 (err, position) => {181 assert.isNull(err);182 assert.isObject(position);183 assert.equal('Point', position.type);184 assert.lengthOf(position.coordinates, 2);185 assert.equal(0, position.coordinates[0]);186 assert.equal(0, position.coordinates[1]);187 callback();188 }189 )190 }191 ], done);192 }...

Full Screen

Full Screen

BeaconsRoutesV1.test.ts

Source:BeaconsRoutesV1.test.ts Github

copy

Full Screen

1const assert = require('chai').assert;2import { DataPage } from 'pip-services3-commons-nodex';3import { Descriptor } from 'pip-services3-commons-nodex';4import { BeaconV1 } from '../../../src/clients/version1/BeaconV1';5import { BeaconsMemoryClientV1 } from '../../../src/clients/version1/BeaconsMemoryClientV1';6import { TestUsers } from '../../fixtures/TestUsers';7import { TestReferences } from '../../fixtures/TestReferences';8import { TestRestClient } from '../../fixtures/TestRestClient';9let BEACON1: BeaconV1 = {10 id: '1',11 udi: '000001',12 site_id: '1',13 label: 'TestBeacon1',14 center: { type: 'Point', coordinates: [0, 0] },15 radius: 5016};17let BEACON2: BeaconV1 = {18 id: '2',19 udi: '000002',20 site_id: '1',21 label: 'TestBeacon2',22 center: { type: 'Point', coordinates: [2, 2] },23 radius: 7024};25let BEACON3: BeaconV1 = {26 id: '3',27 udi: '000003',28 site_id: '2',29 label: 'TestBeacon3',30 center: { type: 'Point', coordinates: [10, 10] },31 radius: 5032};33suite('BeaconsOperationsV1', () => {34 let references: TestReferences;35 let rest: TestRestClient;36 setup(async () => {37 rest = new TestRestClient();38 references = new TestReferences();39 references.put(new Descriptor('beacons', 'client', 'memory', 'default', '1.0'), new BeaconsMemoryClientV1());40 await references.open(null);41 });42 teardown(async () => {43 await references.close(null);44 });45 test('should perform beacon operations', async () => {46 let beacon1, beacon2, beacon3: BeaconV1;47 // Create one beacon48 let beacon = await rest.postAsUser(49 TestUsers.AdminUserSessionId,50 '/api/v1/sites/' + BEACON1.site_id + '/beacons',51 BEACON1,52 );53 assert.isObject(beacon);54 assert.equal(beacon.site_id, BEACON1.site_id);55 assert.equal(beacon.udi, BEACON1.udi);56 assert.equal(beacon.label, BEACON1.label);57 assert.isNotNull(beacon.center);58 beacon1 = beacon;59 // Create another beacon60 beacon = await rest.postAsUser(61 TestUsers.AdminUserSessionId,62 '/api/v1/sites/' + BEACON2.site_id + '/beacons',63 BEACON264 );65 assert.isObject(beacon);66 assert.equal(beacon.site_id, BEACON2.site_id);67 assert.equal(beacon.udi, BEACON2.udi);68 assert.equal(beacon.label, BEACON2.label);69 assert.isNotNull(beacon.center);70 beacon2 = beacon;71 // Create yet another beacon72 beacon = await rest.postAsUser(73 TestUsers.AdminUserSessionId,74 '/api/v1/sites/' + BEACON3.site_id + '/beacons',75 BEACON376 );77 assert.isObject(beacon);78 assert.equal(beacon.site_id, BEACON3.site_id);79 assert.equal(beacon.udi, BEACON3.udi);80 assert.equal(beacon.label, BEACON3.label);81 assert.isNotNull(beacon.center);82 beacon3 = beacon;83 // Get all beacons84 let page: DataPage<BeaconV1> = await rest.getAsUser(85 TestUsers.AdminUserSessionId,86 '/api/v1/sites/' + BEACON1.site_id + '/beacons'87 );88 89 assert.isObject(page);90 assert.lengthOf(page.data, 2);91 // Calculate positions92 let position = await rest.postAsUser(93 TestUsers.AdminUserSessionId,94 '/api/v1/sites/' + BEACON1.site_id + '/beacons/calculate_position',95 {96 site_id: BEACON1.site_id,97 udis: [BEACON1.udi]98 }99 );100 assert.isObject(position);101 assert.equal(position.type, 'Point');102 // Validate beacon udi103 let result = await rest.postAsUser(104 TestUsers.AdminUserSessionId,105 '/api/v1/sites/' + beacon1.site_id + '/beacons/validate_udi?udi=' + beacon1.udi,106 {},107 );108 assert.equal(result, beacon1.id);109 // Update the beacon110 beacon1.label = 'ABC';111 beacon = await rest.putAsUser(112 TestUsers.AdminUserSessionId,113 '/api/v1/sites/' + beacon1.site_id + '/beacons/' + beacon1.id,114 beacon1115 );116 assert.isObject(beacon);117 assert.equal(beacon.label, 'ABC');118 // Delete beacon119 beacon = await rest.delAsUser(120 TestUsers.AdminUserSessionId,121 '/api/v1/sites/' + beacon1.site_id + '/beacons/' + beacon1.id122 );123 assert.equal(beacon.id, beacon1.id);124 // Try to get delete beacon125 result = await rest.getAsUser(126 TestUsers.AdminUserSessionId,127 '/api/v1/sites/' + beacon1.site_id + '/beacons/' + beacon1.id128 );129 assert.isNull(result);130 });...

Full Screen

Full Screen

beacon-constructor.js

Source:beacon-constructor.js Github

copy

Full Screen

1const test = require('ava');2const { ethers, upgrades } = require('hardhat');3test.before(async t => {4 t.context.WithConstructor = await ethers.getContractFactory('WithConstructor');5});6test('new beacon - do not redeploy with same args', async t => {7 const { WithConstructor } = t.context;8 const beacon1 = await upgrades.deployBeacon(WithConstructor, { constructorArgs: [17] });9 const implementation1 = await upgrades.beacon.getImplementationAddress(beacon1.address);10 const proxy1 = await upgrades.deployBeaconProxy(beacon1, WithConstructor);11 t.is((await proxy1.value()).toNumber(), 17);12 const beacon2 = await upgrades.deployBeacon(WithConstructor, { constructorArgs: [17] });13 const implementation2 = await upgrades.beacon.getImplementationAddress(beacon2.address);14 const proxy2 = await upgrades.deployBeaconProxy(beacon2, WithConstructor);15 t.is((await proxy2.value()).toNumber(), 17);16 t.not(beacon1.address, beacon2.address);17 const reloadedProxy1 = WithConstructor.attach(proxy1.address);18 t.is((await reloadedProxy1.value()).toNumber(), 17);19 t.is(implementation1, implementation2);20});21test('new beacon - redeploy with different args', async t => {22 const { WithConstructor } = t.context;23 const beacon1 = await upgrades.deployBeacon(WithConstructor, { constructorArgs: [17] });24 const implementation1 = await upgrades.beacon.getImplementationAddress(beacon1.address);25 const proxy1 = await upgrades.deployBeaconProxy(beacon1, WithConstructor);26 t.is((await proxy1.value()).toNumber(), 17);27 const beacon2 = await upgrades.deployBeacon(WithConstructor, { constructorArgs: [42] });28 const implementation2 = await upgrades.beacon.getImplementationAddress(beacon2.address);29 const proxy2 = await upgrades.deployBeaconProxy(beacon2, WithConstructor);30 t.is((await proxy2.value()).toNumber(), 42);31 t.not(beacon1.address, beacon2.address);32 const reloadedProxy1 = WithConstructor.attach(proxy1.address);33 t.is((await reloadedProxy1.value()).toNumber(), 17);34 t.not(implementation1, implementation2);35});36test('upgrade - do not redeploy with same args', async t => {37 const { WithConstructor } = t.context;38 const beacon1 = await upgrades.deployBeacon(WithConstructor, { constructorArgs: [17] });39 const implementation1 = await upgrades.beacon.getImplementationAddress(beacon1.address);40 const proxy1 = await upgrades.deployBeaconProxy(beacon1, WithConstructor);41 t.is((await proxy1.value()).toNumber(), 17);42 const beacon2 = await upgrades.upgradeBeacon(beacon1, WithConstructor, { constructorArgs: [17] });43 const implementation2 = await upgrades.beacon.getImplementationAddress(beacon2.address);44 const proxy2 = await upgrades.deployBeaconProxy(beacon2, WithConstructor);45 t.is((await proxy2.value()).toNumber(), 17);46 t.is(beacon1.address, beacon2.address);47 const reloadedProxy1 = WithConstructor.attach(proxy1.address);48 t.is((await reloadedProxy1.value()).toNumber(), 17);49 t.is(implementation1, implementation2);50});51test('upgrade - redeploy with different args', async t => {52 const { WithConstructor } = t.context;53 const beacon1 = await upgrades.deployBeacon(WithConstructor, { constructorArgs: [17] });54 const implementation1 = await upgrades.beacon.getImplementationAddress(beacon1.address);55 const proxy1 = await upgrades.deployBeaconProxy(beacon1, WithConstructor);56 t.is((await proxy1.value()).toNumber(), 17);57 const beacon2 = await upgrades.upgradeBeacon(beacon1, WithConstructor, { constructorArgs: [42] });58 const implementation2 = await upgrades.beacon.getImplementationAddress(beacon2.address);59 const proxy2 = await upgrades.deployBeaconProxy(beacon2, WithConstructor);60 t.is((await proxy2.value()).toNumber(), 42);61 t.is(beacon1.address, beacon2.address);62 const reloadedProxy1 = WithConstructor.attach(proxy1.address);63 t.is((await reloadedProxy1.value()).toNumber(), 42);64 t.not(implementation1, implementation2);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var webPageTest = new wpt('www.webpagetest.org');3}, function (err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) {4 console.log('Error: ' + err);5 } else {6 console.log(data);7 }8});9var wpt = require('wpt');10var wpt = new WebPageTest('www.webpagetest.org');11 if (err) {12 console.log('Error: ' + err);13 } else {14 console.log(data);15 }16});17var wpt = require('wpt');18var wpt = new WebPageTest('www.webpagetest.org');19 if (err) {20 console.log('Error: ' + err);21 } else {22 console.log(data);23 }24});25var wpt = require('wpt');26var wpt = new WebPageTest('www.webpagetest.org');27wpt.getLocations(function (err, data) {28 if (err) {29 console.log('Error: ' + err);30 } else {31 console.log(data);32 }33});34var wpt = require('wpt');35var wpt = new WebPageTest('www.webpagetest.org');36wpt.getTesters(function (err, data) {37 if (err) {38 console.log('Error: ' + err);39 } else {40 console.log(data);41 }42});43var wpt = require('wpt');44var wpt = new WebPageTest('www.webpagetest.org');45wpt.getTesters(function (err, data) {46 if (err) {

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful