How to use makeDevice method in wpt

Best JavaScript code snippet using wpt

ParsePushAdapter.spec.js

Source:ParsePushAdapter.spec.js Github

copy

Full Screen

...96 deviceToken: undefined97 }98 ];99 var deviceMap = ParsePushAdapter.classifyInstallations(installations, validPushTypes);100 expect(deviceMap['android']).toEqual([makeDevice('androidToken', 'android')]);101 expect(deviceMap['ios']).toEqual([makeDevice('iosToken', 'ios')]);102 expect(deviceMap['osx']).toEqual([makeDevice('osxToken', 'osx')]);103 expect(deviceMap['tvos']).toEqual([makeDevice('tvosToken', 'tvos')]);104 expect(deviceMap['win']).toBe(undefined);105 done();106 });107 it('can send push notifications', (done) => {108 var parsePushAdapter = new ParsePushAdapter();109 // Mock senders110 var androidSender = {111 send: jasmine.createSpy('send')112 };113 var iosSender = {114 send: jasmine.createSpy('send')115 };116 var osxSender = {117 send: jasmine.createSpy('send')118 }119 var senderMap = {120 osx: osxSender,121 ios: iosSender,122 android: androidSender123 };124 parsePushAdapter.senderMap = senderMap;125 // Mock installations126 var installations = [127 {128 deviceType: 'android',129 deviceToken: 'androidToken'130 },131 {132 deviceType: 'ios',133 deviceToken: 'iosToken'134 },135 {136 deviceType: 'osx',137 deviceToken: 'osxToken'138 },139 {140 deviceType: 'win',141 deviceToken: 'winToken'142 },143 {144 deviceType: 'android',145 deviceToken: undefined146 }147 ];148 var data = {};149 parsePushAdapter.send(data, installations);150 // Check android sender151 expect(androidSender.send).toHaveBeenCalled();152 var args = androidSender.send.calls.first().args;153 expect(args[0]).toEqual(data);154 expect(args[1]).toEqual([155 makeDevice('androidToken', 'android')156 ]);157 // Check ios sender158 expect(iosSender.send).toHaveBeenCalled();159 args = iosSender.send.calls.first().args;160 expect(args[0]).toEqual(data);161 expect(args[1]).toEqual([162 makeDevice('iosToken', 'ios'),163 ]);164 // Check osx sender165 expect(osxSender.send).toHaveBeenCalled();166 args = osxSender.send.calls.first().args;167 expect(args[0]).toEqual(data);168 expect(args[1]).toEqual([169 makeDevice('osxToken', 'osx')170 ]);171 done();172 });173 it('can send push notifications by pushType and failback by deviceType', (done) => {174 var parsePushAdapter = new ParsePushAdapter();175 // Mock senders176 var androidSender = {177 send: jasmine.createSpy('send')178 };179 var iosSender = {180 send: jasmine.createSpy('send')181 };182 var senderMap = {183 ios: iosSender,184 android: androidSender185 };186 parsePushAdapter.senderMap = senderMap;187 // Mock installations188 var installations = [189 {190 deviceType: 'android',191 deviceToken: 'androidToken'192 },193 {194 deviceType: 'android',195 pushType: 'gcm',196 deviceToken: 'androidToken'197 },198 {199 deviceType: 'android',200 pushType: 'ppns',201 deviceToken: 'androidToken'202 },203 {204 deviceType: 'android',205 pushType: 'none',206 deviceToken: 'androidToken'207 },208 {209 deviceType: 'ios',210 deviceToken: 'iosToken'211 },212 {213 deviceType: 'ios',214 pushType: 'ios',215 deviceToken: 'iosToken'216 },217 {218 deviceType: 'win',219 deviceToken: 'winToken'220 },221 {222 deviceType: 'win',223 deviceToken: 'winToken'224 },225 {226 deviceType: 'android',227 deviceToken: undefined228 }229 ];230 var data = {};231 parsePushAdapter.send(data, installations);232 // Check android sender233 expect(androidSender.send).toHaveBeenCalled();234 var args = androidSender.send.calls.first().args;235 expect(args[0]).toEqual(data);236 expect(args[1]).toEqual([237 makeDevice('androidToken', 'android'),238 makeDevice('androidToken', 'android'),239 makeDevice('androidToken', 'android'),240 makeDevice('androidToken', 'android')241 ]);242 // Check ios sender243 expect(iosSender.send).toHaveBeenCalled();244 args = iosSender.send.calls.first().args;245 expect(args[0]).toEqual(data);246 expect(args[1]).toEqual([247 makeDevice('iosToken', 'ios'),248 makeDevice('iosToken', 'ios')249 ]);250 done();251 });252 it('reports properly results', (done) => {253 var pushConfig = {254 android: {255 senderId: 'senderId',256 apiKey: 'apiKey'257 },258 ios: [259 {260 cert: new Buffer('testCert'),261 key: new Buffer('testKey'),262 production: false,263 topic: 'iosbundleId'264 }265 ],266 osx: [267 {268 cert: 'cert.cer',269 key: 'key.pem',270 production: false,271 topic: 'osxbundleId'272 }273 ]274 };275 var installations = [276 {277 deviceType: 'android',278 deviceToken: 'androidToken'279 },280 {281 deviceType: 'ios',282 deviceToken: '0d72a1baa92a2febd9a254cbd6584f750c70b2350af5fc9052d1d12584b738e6',283 appIdentifier: 'iosbundleId'284 },285 {286 deviceType: 'ios',287 deviceToken: 'ff3943ed0b2090c47e5d6f07d8f202a10427941d7897fda5a6b18c6d9fd07d48',288 appIdentifier: 'iosbundleId'289 },290 {291 deviceType: 'osx',292 deviceToken: '5cda62a8d88eb48d9111a6c436f2e326a053eb0cd72dfc3a0893089342602235',293 appIdentifier: 'osxbundleId'294 },295 {296 deviceType: 'tvos',297 deviceToken: '3e72a1baa92a2febd9a254cbd6584f750c70b2350af5fc9052d1d12584b738e6',298 appIdentifier: 'iosbundleId' // ios and tvos share the same bundleid299 },300 {301 deviceType: 'win',302 deviceToken: 'winToken'303 },304 {305 deviceType: 'android',306 deviceToken: undefined307 }308 ];309 var parsePushAdapter = new ParsePushAdapter(pushConfig);310 parsePushAdapter.send({ data: { alert: 'some' } }, installations).then((results) => {311 expect(Array.isArray(results)).toBe(true);312 // 2x iOS, 1x android, 1x osx, 1x tvos313 expect(results.length).toBe(5);314 results.forEach((result) => {315 expect(typeof result.device).toBe('object');316 if (!result.device) {317 fail('result should have device');318 return;319 }320 const device = result.device;321 expect(typeof device.deviceType).toBe('string');322 expect(typeof device.deviceToken).toBe('string');323 if (device.deviceType === 'ios' || device.deviceType === 'osx') {324 expect(result.transmitted).toBe(true);325 } else {326 expect(result.transmitted).toBe(false);327 }328 })329 done();330 }).catch((err) => {331 fail('Should not fail');332 done();333 })334 });335 it('reports properly failures when all transmissions have failed', (done) => {336 var pushConfig = {337 ios: [338 {339 cert: 'cert.cer',340 key: 'key.pem',341 production: false,342 shouldFailTransmissions: true,343 bundleId: 'iosbundleId'344 }345 ]346 };347 var installations = [348 {349 deviceType: 'ios',350 deviceToken: '0d72a1baa92a2febd9a254cbd6584f750c70b2350af5fc9052d1d12584b738e6',351 appIdentifier: 'iosbundleId'352 }353 ];354 var parsePushAdapter = new ParsePushAdapter(pushConfig);355 parsePushAdapter.send({data: {alert: 'some'}}, installations).then((results) => {356 expect(Array.isArray(results)).toBe(true);357 // 2x iOS, 1x android, 1x osx, 1x tvos358 expect(results.length).toBe(1);359 const result = results[0];360 expect(typeof result.device).toBe('object');361 if (!result.device) {362 fail('result should have device');363 return;364 }365 const device = result.device;366 expect(typeof device.deviceType).toBe('string');367 expect(typeof device.deviceToken).toBe('string');368 expect(result.transmitted).toBe(false);369 expect(typeof result.response.error).toBe('string');370 done();371 }).catch((err) => {372 fail('Should not fail');373 done();374 })375 });376 // Xited till we can retry on other connections377 it('reports properly select connection', (done) => {378 var pushConfig = {379 ios: [380 {381 cert: 'cert.cer',382 key: 'key.pem',383 production: false,384 shouldFailTransmissions: true,385 bundleId: 'iosbundleId'386 },387 {388 cert: 'cert.cer',389 key: 'key.pem',390 production: false,391 bundleId: 'iosbundleId'392 }393 ]394 };395 var installations = [396 {397 deviceType: 'ios',398 deviceToken: '0d72a1baa92a2febd9a254cbd6584f750c70b2350af5fc9052d1d12584b738e6',399 appIdentifier: 'iosbundleId'400 }401 ];402 var parsePushAdapter = new ParsePushAdapter(pushConfig);403 parsePushAdapter.send({data: {alert: 'some'}}, installations).then((results) => {404 expect(Array.isArray(results)).toBe(true);405 // 2x iOS, 1x android, 1x osx, 1x tvos406 expect(results.length).toBe(1);407 const result = results[0];408 expect(typeof result.device).toBe('object');409 if (!result.device) {410 fail('result should have device');411 return;412 }413 const device = result.device;414 expect(typeof device.deviceType).toBe('string');415 expect(typeof device.deviceToken).toBe('string');416 expect(result.transmitted).toBe(true);417 done();418 }).catch((err) => {419 fail('Should not fail');420 done();421 })422 });423 it('properly marks not transmitter when sender is missing', (done) => {424 var pushConfig = {425 android: {426 senderId: 'senderId',427 apiKey: 'apiKey'428 }429 };430 var installations = [{431 deviceType: 'ios',432 deviceToken: '0d72a1baa92a2febd9a254cbd6584f750c70b2350af5fc9052d1d12584b738e6',433 appIdentifier: 'invalidiosbundleId'434 },435 {436 deviceType: 'ios',437 deviceToken: 'ff3943ed0b2090c47e5d6f07d8f202a10427941d7897fda5a6b18c6d9fd07d48',438 appIdentifier: 'invalidiosbundleId'439 }]440 var parsePushAdapter = new ParsePushAdapter(pushConfig);441 parsePushAdapter.send({data: {alert: 'some'}}, installations).then((results) => {442 expect(results.length).toBe(2);443 results.forEach((result) => {444 expect(result.transmitted).toBe(false);445 expect(typeof result.device).toBe('object');446 expect(typeof result.device.deviceType).toBe('string');447 expect(typeof result.device.deviceToken).toBe('string');448 expect(result.response.error.indexOf('Can not find sender for push type ios, ')).toBe(0);449 });450 done();451 });452 });453 it('random string throws with size <=0', () => {454 expect(() => randomString(0)).toThrow();455 });456 function makeDevice(deviceToken, deviceType, appIdentifier) {457 return {458 deviceToken: deviceToken,459 deviceType: deviceType,460 appIdentifier: appIdentifier461 };462 }...

Full Screen

Full Screen

platform.ts

Source:platform.ts Github

copy

Full Screen

...163 */164 discoverDevices() {165 if (this.config.autoCreateAccessories && this.spa && this.spa.accurateConfigReadFromSpa) {166 this.log.info('Autocreating accessories...');167 if (this.spa!.getIsLightOn(1) != undefined) this.makeDevice({name: 'Spa Lights 1', deviceType: 'Lights 1'});168 if (this.spa!.getIsLightOn(2) != undefined) this.makeDevice({name: 'Spa Lights 2', deviceType: 'Lights 2'});169 for (let pump = 1; pump <=6; pump++) {170 if (this.spa!.getPumpSpeedRange(pump) != 0) this.makeDevice({name: 'Spa Pump '+pump, deviceType: 'Pump '+pump});171 }172 if (this.spa!.getPumpSpeedRange(0) != 0) this.makeDevice({name: 'Spa Circulation Pump', deviceType: 'Circulation Pump'});173 this.makeDevice({name: 'Spa Temperature Sensor', deviceType: 'Temperature Sensor'});174 this.makeDevice({name: 'Spa Thermostat', deviceType: 'Thermostat'});175 this.makeDevice({name: 'Spa Flow', deviceType: 'Water Flow Problem Sensor'});176 this.makeDevice({name: 'Hold Spa', deviceType: 'Hold Switch'});177 this.makeDevice({name: 'Spa Settings', deviceType: 'Spa Settings'});178 this.makeDevice({name: 'Spa Panel', deviceType: 'Spa Panel'});179 this.makeDevice({name: 'Spa Heat Mode Ready', deviceType: 'Spa Heat Mode Ready'});180 if (this.spa!.getBlowerSpeedRange() != 0) this.makeDevice({name: 'Spa Blower', deviceType: 'Blower'});181 if (this.spa!.getIsMisterOn() != undefined) this.makeDevice({name: 'Spa Mister', deviceType: 'Mister'});182 if (this.spa!.getIsAuxOn(1) != undefined) this.makeDevice({name: 'Spa Aux 1', deviceType: 'Aux 1'});183 if (this.spa!.getIsAuxOn(2) != undefined) this.makeDevice({name: 'Spa Aux 2', deviceType: 'Aux 2'});184 }185 for (const device of this.devices) {186 if (!device.deviceType) {187 this.log.warn('Device Type Missing')188 } else {189 this.makeDevice(device);190 }191 }192 }193 /**194 * Accessories must only be registered once, previously created accessories195 * must not be registered again to prevent "duplicate UUID" errors.196 */197 private makeDevice(device: any) {198 // generate a unique id for the accessory this should be generated from199 // something globally unique, but constant, for example, the device serial200 // number or MAC address201 const uuid = this.api.hap.uuid.generate(device.deviceType);202 // check that the device has not already been registered by checking the203 // cached devices we stored in the `configureAccessory` method above204 if (!this.accessories.find(accessory => accessory.UUID === uuid)) {205 this.log.info('Registering new accessory:', device.name, 'of type', device.deviceType);206 // create a new accessory207 const accessory = new this.api.platformAccessory(device.name, uuid);208 // store a copy of the device object in the `accessory.context`209 // the `context` property can be used to store any data about the accessory you may need210 accessory.context.device = device;211 this.makeAccessory(accessory);...

Full Screen

Full Screen

Abstract2.ts

Source:Abstract2.ts Github

copy

Full Screen

...18 console.log("I'm repairer and I can repair only laptops")19 }20}21interface IAbstractFactory {22 makeDevice()23 makeRepairman()24}25class PhoneWorkshop implements IAbstractFactory {26 makeDevice(){27 return new Phone()28 }29 makeRepairman() {30 return new PhoneRepairman()31 }32}33class LaptopWorkshop implements IAbstractFactory {34 makeDevice(){35 return new Laptop()36 }37 makeRepairman() {38 return new LaptopRepairman()39 }40}41let abstractFactory = new PhoneWorkshop()42let device = abstractFactory.makeDevice()43let expert = abstractFactory.makeRepairman()...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var device = wptools.makeDevice('iPhone 6');3wptools.makeDevice('iPhone 6', function(err, device) {4 if (err) throw err;5 console.log(device);6});7var device = wptools.makeDevice('iPhone 6', function(err, device) {8 if (err) throw err;9 console.log(device);10});11wptools.makeDevice('iPhone 6', function(err, device) {12 if (err) throw err;13 console.log(device);14});15var device = wptools.makeDevice('iPhone 6', function(err, device) {16 if (err) throw err;17 console.log(device);18});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var device = wpt.makeDevice('iPhone 6');3var options = {4 'script': 'document.getElementById("foo").innerHTML="bar";',5 'script': 'document.getElementById("foo").innerHTML="bar";',6 'script': 'document.getElementById("foo").innerHTML="bar";',7 'script': 'document.getElementById("foo").innerHTML="bar";',8 'script': 'document.getElementById("foo").innerHTML="bar";',

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var device = wptools.makeDevice({ deviceName: 'iPhone 6' });3var wptools = require('wptools');4var device = wptools.makeDevice({ deviceName: 'iPhone 6' });5var wptools = require('wptools');6var device = wptools.makeDevice({ deviceName: 'iPhone 6' });7var wptools = require('wptools');8var device = wptools.makeDevice({ deviceName: 'iPhone 6' });9var wptools = require('wptools');10var device = wptools.makeDevice({ deviceName: 'iPhone 6' });11var wptools = require('wptools');12var device = wptools.makeDevice({ deviceName: 'iPhone 6' });13var wptools = require('wptools');14var device = wptools.makeDevice({ deviceName: 'iPhone 6' });15var wptools = require('wptools');16var device = wptools.makeDevice({ deviceName: 'iPhone 6' });17var wptools = require('wptools');18var device = wptools.makeDevice({ deviceName: 'iPhone 6' });19var wptools = require('w

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var device = wptools.makeDevice();3device.makeDevice('iPhone 5');4var wptools = require('wptools');5var device = wptools.makeDevice();6var request = wptools.makeRequest();7device.makeDevice('iPhone 5');8 if (err) {9 console.log(err);10 } else {11 console.log(data);12 }13});14var wptools = require('wptools');15var device = wptools.makeDevice();16var request = wptools.makeRequest();17device.makeDevice('iPhone 5');18device.setDeviceProperty('screenWidth', 600);19device.setDeviceProperty('screenHeight', 800);20device.setDeviceProperty('screenOrientation', 'portrait');21 if (err) {22 console.log(err);23 } else {24 console.log(data);25 }26});27var wptools = require('wptools');28var device = wptools.makeDevice();29var request = wptools.makeRequest();30device.makeDevice('iPhone 5');31device.setDeviceProperty('screenWidth', 600);32device.setDeviceProperty('screenHeight', 800);33device.setDeviceProperty('screenOrientation', 'portrait');34request.setBasicAuth('username', 'password');35request.setPageLoadTimeout(30000);36request.setResourceTimeout(10000);37request.setWaitFor(3000);38request.setWaitForElement('input[type="submit"]');39request.setWaitForSelector('input[type="submit"]');40request.setWaitForNetworkIdle(true);41 if (err) {42 console.log(err);43 } else {44 console.log(data);45 }46});

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