Best JavaScript code snippet using wpt
TestViewModel.ts
Source:TestViewModel.ts
1import TestNode = require('../Models/TestNode');2import TestEdge = require('../Models/TestEdge');34var WEIGHT_RANGE = { Low: 12, High: 50 };56class TestViewModel extends Fayde.MVVM.ViewModelBase {7 AddNodeCommand: Fayde.MVVM.RelayCommand;8 Nodes = new Fayde.Collections.ObservableCollection<TestNode>();9 Edges = new Fayde.Collections.ObservableCollection<TestEdge>();1011 private _Repulsion = 300.0;12 get Repulsion (): number {13 return this._Repulsion;14 }1516 set Repulsion (value: number) {17 this._Repulsion = value;18 this.OnPropertyChanged("Repulsion");19 }2021 private _SpringTension = 0.009;22 get SpringTension (): number {23 return this._SpringTension;24 }2526 set SpringTension (value: number) {27 this._SpringTension = value;28 this.OnPropertyChanged("SpringTension");29 }3031 constructor () {32 super();33 this.AddNodeCommand = new Fayde.MVVM.RelayCommand(() => this.AddNode_Execute);34 this.Load();35 }3637 Load () {38 var nodes = this.Nodes;39 var edges = this.Edges;4041 var florida = this.AddState("FL");42 florida.Area = 69898;43 var georgia = this.AddState("GA", florida);44 georgia.Area = 6549845 var sc = this.AddState("SC", georgia);46 sc.Area = 32020;47 var alabama = this.AddState("AL", florida, georgia);48 alabama.Area = 51480;49 var tennessee = this.AddState("TN", georgia, alabama);50 tennessee.Area = 42143;51 var nc = this.AddState("NC", sc, tennessee, georgia);52 nc.Area = 53819;53 var mississippi = this.AddState("MS", alabama, tennessee);54 mississippi.Area = 46055;55 var virginia = this.AddState("VA", nc, tennessee);56 virginia.Area = 53179;57 var kentucky = this.AddState("KY", tennessee, virginia);58 kentucky.Area = 40409;59 var wv = this.AddState("WV", kentucky, virginia);60 wv.Area = 24230;61 var maryland = this.AddState("MD", wv, virginia);62 maryland.Area = 12407;63 var delaware = this.AddState("DE", maryland);64 delaware.Area = 2489;65 var nj = this.AddState("NJ", delaware);66 nj.Area = 8721;67 var penn = this.AddState("PA", wv, maryland, delaware, nj);68 penn.Area = 44825;69 var ny = this.AddState("NY", penn, nj);70 ny.Area = 54556;71 var conn = this.AddState("CT", ny);72 conn.Area = 5543;73 var rhode = this.AddState("RI", conn);74 rhode.Area = 1545;75 var mass = this.AddState("MA", ny, conn, rhode);76 mass.Area = 10555;77 var vermont = this.AddState("VT", ny, mass);78 vermont.Area = 9614;79 var nh = this.AddState("NH", mass, vermont);80 nh.Area = 9350;81 var maine = this.AddState("ME", nh);82 maine.Area = 36148;83 var ohio = this.AddState("OH", penn, wv, kentucky);84 ohio.Area = 42774;85 var michigan = this.AddState("MI", ohio);86 michigan.Area = 82277;87 var indiana = this.AddState("IN", michigan, ohio, kentucky);88 indiana.Area = 35385;89 var illinois = this.AddState("IL", kentucky, indiana);90 illinois.Area = 57914;91 var wisconsin = this.AddState("WI", michigan, illinois);92 wisconsin.Area = 59425;93 var minnesota = this.AddState("MN", wisconsin);94 minnesota.Area = 97790;95 var iowa = this.AddState("IA", minnesota, wisconsin, illinois);96 iowa.Area = 56272;97 var missouri = this.AddState("MO", iowa, illinois, kentucky, tennessee);98 missouri.Area = 65755;99 var arkansas = this.AddState("AR", missouri, tennessee, mississippi);100 arkansas.Area = 52419;101 var louisiana = this.AddState("LA", arkansas, mississippi);102 louisiana.Area = 48430;103 var texas = this.AddState("TX", louisiana, arkansas);104 texas.Area = 268581;105 var oklahoma = this.AddState("OK", texas, arkansas, missouri);106 oklahoma.Area = 69704;107 var kansas = this.AddState("KS", oklahoma, missouri);108 kansas.Area = 86939;109 var nebraska = this.AddState("NE", kansas, missouri, iowa);110 nebraska.Area = 77354;111 var sd = this.AddState("SD", nebraska, iowa, minnesota);112 sd.Area = 77116;113 var nd = this.AddState("ND", sd, minnesota);114 nd.Area = 70700;115 var montana = this.AddState("MT", nd, sd);116 montana.Area = 163696;117 var wyoming = this.AddState("WY", montana, sd, nebraska);118 wyoming.Area = 97818;119 var colorado = this.AddState("CO", wyoming, nebraska, kansas, oklahoma);120 colorado.Area = 104094;121 var nm = this.AddState("NM", colorado, oklahoma, texas);122 nm.Area = 121589;123 var arizona = this.AddState("AZ", nm);124 arizona.Area = 113998;125 var utah = this.AddState("UT", wyoming, arizona, colorado);126 utah.Area = 83570;127 var idaho = this.AddState("ID", montana, wyoming, utah);128 idaho.Area = 84899;129 var washington = this.AddState("WA", idaho);130 washington.Area = 71300;131 var oregon = this.AddState("OR", washington, idaho);132 oregon.Area = 98381;133 var nevada = this.AddState("NV", oregon, idaho, utah, arizona);134 nevada.Area = 110561;135 var california = this.AddState("CA", oregon, nevada, arizona);136 california.Area = 147042;137138 this.DistributeStateWeights(WEIGHT_RANGE.Low, WEIGHT_RANGE.High);139 }140141 private AddNode_Execute () {142 var newNode = new TestNode("");143 this.Nodes.Add(newNode);144145 var newEdges: TestEdge[] = [];146 var randomCount = randomInt(1, 4);147 for (var i = 0; i < randomCount; i++) {148 var existingNode = this.Nodes[randomInt(0, 3)];149 if (newEdges.some(te => te.Source.UniqueID === existingNode.UniqueID || te.Sink.UniqueID === existingNode.UniqueID)) {150 i--;151 continue;152 }153 if (randomInt(0, 2) == 1)154 newEdges.push(newNode.Connect(existingNode));155 else156 newEdges.push(existingNode.Connect(newNode));157 }158159 this.Edges.AddRange(newEdges);160 }161162 private AddState (abbreviation: string, ...connections: TestNode[]): TestNode {163 var node = new TestNode(abbreviation);164 this.Nodes.Add(node);165 if (!connections)166 return node;167 var len = connections.length;168 for (var i = 0; i < len; i++) {169 this.Edges.Add(node.Connect(connections[i]));170 }171 return node;172 }173174 private DistributeStateWeights (low: number, high: number) {175 var nodes = this.Nodes;176 var enumerator = nodes.getEnumerator();177 var totalArea = 0.0;178 var minArea = Number.POSITIVE_INFINITY;179 var maxArea = Number.NEGATIVE_INFINITY;180 while (enumerator.moveNext()) {181 minArea = Math.min(minArea, enumerator.current.Area);182 maxArea = Math.max(maxArea, enumerator.current.Area);183 totalArea += enumerator.current.Area;184 }185186 enumerator = nodes.getEnumerator();187 while (enumerator.moveNext()) {188 var normalized = (enumerator.current.Area - minArea) / (maxArea - minArea);189 enumerator.current.Weight = normalized * (high - low) + low;190 }191 }192}193194function randomInt(low: number, high: number): number {195 return Math.floor(Math.random() * (high - low) + low);196}197
...
states.js
Source:states.js
1/* globals angular */2var states = angular.module("states", ['ui.router']);3states.config(function ($stateProvider, $state) {4 "use strict";5 function addState(name, url, templateUrl, initialChildState) {6 var stateDefinition = {7 url: url,8 views: {9 main: {10 templateUrl: templateUrl11 }12 }13 };14 if (typeof(initialChildState) === 'function') {15 stateDefinition.onEnter = function () {16 $state.go(initialChildState);17 };18 }19 $stateProvider.state(name, stateDefinition);20 }21 addState("home", "/home", "home/home.html", "home.changeGroups");22 addState("home.changeGroups", "/changeGroups", "home/changeGroups.html");23 addState("home.deploymentGroups", "/deploymentGroups", "home/deploymentGroups.html");24 addState("home.recentDeployments", "/recentDeployments", "home/recentDeployments.html");25 addState("home.scheduledDeployments", "/scheduledDeployments", "home/scheduledDeployments.html");26 addState("home.research", "/research", "home/research.html");27 addState("configure", "/configure", "configure/configure.html", "configure.tableEditor");28 addState("configure.useIndicatorEditor", "/useIndicatorEditor", "configure/useIndicatorEditor.html");29 addState("configure.cxSubscriberServicesEditor", "/cxSubscriberServicesEditor", "configure/cxSubscriberServicesEditor.html");30 addState("configure.regulatoryMappingsEditor", "/regulatoryMappingsEditor", "configure/regulatoryMappingsEditor.html");31 addState("configure.regulatoryMappingsValidator", "/regulatoryMappingsValidator", "configure/regulatoryMappingsValidator.html");32 addState("configure.tableEditor", "/tableEditor", "configure/tableEditor.html");33 addState("configure.iceberg", "/iceberg", "configure/iceberg/iceberg.html");34 addState("configure.iceberg.tableEditor", "/tableEditor", "configure/iceberg/tableEditor.html");35 addState("configure.iceberg.pdbEditor", "/pdbEditor", "configure/iceberg/pdbEditor.html");36 addState("configure.iceberg.codeDomainEditor", "/codeDomainEditor", "configure/iceberg/codeDomainEditor.html");37 addState("configure.iceberg.lqaNavigator", "/lqaNavigator", "configure/iceberg/lqaNavigator.html");38 addState("configure.iceberg.lqatrNavigator", "/lqatrNavigator", "configure/iceberg/lqatrNavigator.html");39 addState("manage", "/manage", "manage/manage.html", "manage.userAccounts");40 addState("manage.applications", "/applications", "manage/applications.html");41 addState("manage.customers", "/customers", "manage/customers.html");42 addState("manage.customerSites", "/customerSites", "manage/customerSites.html");43 addState("manage.databaseSites", "/databaseSites", "manage/databaseSites.html");44 addState("manage.environments", "/environments", "manage/environments.html");45 addState("manage.permissions", "/permissions", "manage/permissions.html");46 addState("manage.securityGroups", "/securityGroups", "manage/securityGroups.html");47 addState("manage.servers", "/servers", "manage/servers.html");48 addState("manage.tableMetadata", "/tableMetadata", "manage/tableMetadata.html");49 addState("manage.userAccounts", "/userAccounts", "manage/userAccounts.html");50 addState("tools", "/tools", "tools/tools.html", "tools.applicationLog");51 addState("tools.applicationLog", "/applicationLog", "tools/applicationLog.html");52 addState("tools.changeLoggingLevels", "/changeLoggingLevels", "tools/changeLoggingLevels.html");53 addState("tools.encryptionTool", "/encryptionTool", "tools/encryptionTool.html");54 addState("tools.refreshCache", "/refreshCache", "tools/refreshCache.html");55 addState("tools.refreshGoldMaster", "/refreshGoldMaster", "tools/refreshGoldMaster.html");56 addState("tools.systemMonitor", "/systemMonitor", "tools/systemMonitor.html");...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3});4var wpt = require('webpagetest');5var wpt = new WebPageTest('www.webpagetest.org');6});7var wpt = require('webpagetest');8var wpt = new WebPageTest('www.webpagetest.org');9});10var wpt = require('webpagetest');11var wpt = new WebPageTest('www.webpagetest.org');12});13var wpt = require('webpagetest');14var wpt = new WebPageTest('www.webpagetest.org');15});16var wpt = require('webpagetest');17var wpt = new WebPageTest('www.webpagetest.org');
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.0b1f2c3d4e5f6g7h8i9j0k1l2m3n4o5p');3 if (err) {4 console.log('Error: ' + err);5 } else {6 console.log(data);7 }8});9var wpt = require('webpagetest');10var wpt = new WebPageTest('www.webpagetest.org', 'A.0b1f2c3d4e5f6g7h8i9j0k1l2m3n4o5p');11 if (err) {12 console.log('Error: ' + err);13 } else {14 console.log(data);15 }16});17var wpt = require('webpagetest');18var wpt = new WebPageTest('www.webpagetest.org', 'A.0b1f2c3d4e5f6g7h8i9j0k1l2m3n4o5p');19 if (err) {20 console.log('Error: ' + err);21 } else {22 console.log(data);23 }24});25var wpt = require('webpagetest');26var wpt = new WebPageTest('www.webpagetest.org', 'A.0b1f2c3d4e5f6g7h8i9j0k1l2m3n4o5p');27 if (err) {28 console.log('Error: ' + err);29 } else {30 console.log(data);31 }
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.0b1f2c3d4e5f6g7h8i9j0k1l2m3n4o5p');3 if (err) {4 console.log('Error: ' + err);5 } else {6 console.log(data);7 }8});9var wpt = require('webpagetest');10var wpt = new WebPageTest('www.webpagetest.org', 'A.0b1f2c3d4e5f6g7h8i9j0k1l2m3n4o5p');11 if (err) {12 console.log('Error: ' + err);13 } else {14 console.log(data);15 }16});17var wpt = require('webpagetest');18var wpt = new WebPageTest('www.webpagetest.org', 'A.0b1f2c3d4e5f6g7h8i9j0k1l2m3n4o5p');19 if (err) {20 console.log('Error: ' + err);21 } else {22 console.log(data);23 }24});25var wpt = require('webpagetest');26var wpt = new WebPageTest('www.webpagetest.org', 'A.0b1f2c3d4e5f6g7h8i9j0k1l2m3n4o5p');27 if (err) {28 console.log('Error: ' + err);29 } else {30 console.log(data);31 }
Using AI Code Generation
1wpt.addState('test', function() {2 console.log('Hello World!');3});4wpt.removeState('test');5var state = wpt.getState('test');6console.log(state);7var states = wpt.getStates();8console.log(states);9var allStates = wpt.getAllStates();10console.log(allStates);11var statesByGroup = wpt.getStatesByGroup('testGroup');12console.log(statesByGroup);13var allStatesByGroup = wpt.getAllStatesByGroup();14console.log(allStatesByGroup);15var hasState = wpt.hasState('test');16console.log(hasState);17var hasStates = wpt.hasStates();18console.log(hasStates);19var hasStatesByGroup = wpt.hasStatesByGroup('testGroup');20console.log(hasStatesByGroup);21var hasAllStatesByGroup = wpt.hasAllStatesByGroup();22console.log(hasAllStatesByGroup);23wpt.updateState('test', function() {24 console.log('Hello World!');25});26wpt.updateStates({27 test: function() {28 console.log('Hello World!');29 },30 test2: function() {31 console.log('Hello World!');32 }33});34wpt.updateAllStates({35 test: function() {36 console.log('Hello World!');37 },38 test2: function() {39 console.log('Hello World!');40 }41});42wpt.updateStatesByGroup('testGroup', {43 test: function() {44 console.log('Hello World!');45 },46 test2: function() {47 console.log('Hello World!');48 }49});
Using AI Code Generation
1var wpt = require('wpt.js');2var wptObj = new wpt('your_api_key');3wptObj.addState('your_test_id', 'state_name', 'state_notes', function(err, data) {4 if (!err) {5 console.log(data);6 }7});8Wpt.prototype.addState = function(testId, stateName, stateNotes, callback) {9 var url = this.apiRoot + 'testState.php';10 var data = {11 };12 this._request(url, data, callback);13};
Using AI Code Generation
1wpt.addState('test', function() {2 console.log('Hello World!');3});4wpt.removeState('test');5var state = wpt.getState('test');6console.log(state);7var states = wpt.getStates();8console.log(states);9var allStates = wpt.getAllStates();10console.log(allStates);11var statesByGroup = wpt.getStatesByGroup('testGroup');12console.log(statesByGroup);13var allStatesByGroup = wpt.getAllStatesByGroup();14console.log(allStatesByGroup);15var hasState = wpt.hasState('test');16console.log(hasState);17var hasStates = wpt.hasStates();18console.log(hasStates);19var hasStatesByGroup = wpt.hasStatesByGroup('testGroup');20console.log(hasStatesByGroup);21var hasAllStatesByGroup = wpt.hasAllStatesByGroup();22console.log(hasAllStatesByGroup);23wpt.updateState('test', function() {24 console.log('Hello World!');25});26wpt.updateStates({27 test: function() {28 console.log('Hello World!');29 },30 test2: function() {31 console.log('Hello World!');32 }33});34wpt.updateAllStates({35 test: function() {36 console.log('Hello World!');37 },38 test2: function() {39 console.log('Hello World!');40 }41});42wpt.updateStatesByGroup('testGroup', {43 test: function() {44 console.log('Hello World!');45 },46 test2: function() {47 console.log('Hello World!');48 }49});
Using AI Code Generation
1var wpt = require('wpt.js');2var wptObj = new wpt('your_api_key');3wptObj.addState('your_test_id', 'state_name', 'state_notes', function(err, data) {4 if (!err) {5 console.log(data);6 }7});8Wpt.prototype.addState = function(testId, stateName, stateNotes, callback) {9 var url = this.apiRoot + 'testState.php';10 var data = {11 };12 this._request(url, data, callback);13};
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!!