Best JavaScript code snippet using devicefarmer-stf
dashboard_migration.jest.ts
Source:dashboard_migration.jest.ts
...128 rows: [],129 };130 });131 it('should create proper grid', function() {132 model.rows = [createRow({ collapse: false, height: 8 }, [[6], [6]])];133 let dashboard = new DashboardModel(model);134 let panelGridPos = getGridPositions(dashboard);135 let expectedGrid = [{ x: 0, y: 0, w: 12, h: 8 }, { x: 12, y: 0, w: 12, h: 8 }];136 expect(panelGridPos).toEqual(expectedGrid);137 });138 it('should add special "row" panel if row is collapsed', function() {139 model.rows = [createRow({ collapse: true, height: 8 }, [[6], [6]]), createRow({ height: 8 }, [[12]])];140 let dashboard = new DashboardModel(model);141 let panelGridPos = getGridPositions(dashboard);142 let expectedGrid = [143 { x: 0, y: 0, w: 24, h: 8 }, // row144 { x: 0, y: 1, w: 24, h: 8 }, // row145 { x: 0, y: 2, w: 24, h: 8 },146 ];147 expect(panelGridPos).toEqual(expectedGrid);148 });149 it('should add special "row" panel if row has visible title', function() {150 model.rows = [151 createRow({ showTitle: true, title: 'Row', height: 8 }, [[6], [6]]),152 createRow({ height: 8 }, [[12]]),153 ];154 let dashboard = new DashboardModel(model);155 let panelGridPos = getGridPositions(dashboard);156 let expectedGrid = [157 { x: 0, y: 0, w: 24, h: 8 }, // row158 { x: 0, y: 1, w: 12, h: 8 },159 { x: 12, y: 1, w: 12, h: 8 },160 { x: 0, y: 9, w: 24, h: 8 }, // row161 { x: 0, y: 10, w: 24, h: 8 },162 ];163 expect(panelGridPos).toEqual(expectedGrid);164 });165 it('should not add "row" panel if row has not visible title or not collapsed', function() {166 model.rows = [167 createRow({ collapse: true, height: 8 }, [[12]]),168 createRow({ height: 8 }, [[12]]),169 createRow({ height: 8 }, [[12], [6], [6]]),170 createRow({ collapse: true, height: 8 }, [[12]]),171 ];172 let dashboard = new DashboardModel(model);173 let panelGridPos = getGridPositions(dashboard);174 let expectedGrid = [175 { x: 0, y: 0, w: 24, h: 8 }, // row176 { x: 0, y: 1, w: 24, h: 8 }, // row177 { x: 0, y: 2, w: 24, h: 8 },178 { x: 0, y: 10, w: 24, h: 8 }, // row179 { x: 0, y: 11, w: 24, h: 8 },180 { x: 0, y: 19, w: 12, h: 8 },181 { x: 12, y: 19, w: 12, h: 8 },182 { x: 0, y: 27, w: 24, h: 8 }, // row183 ];184 expect(panelGridPos).toEqual(expectedGrid);185 });186 it('should add all rows if even one collapsed or titled row is present', function() {187 model.rows = [createRow({ collapse: true, height: 8 }, [[6], [6]]), createRow({ height: 8 }, [[12]])];188 let dashboard = new DashboardModel(model);189 let panelGridPos = getGridPositions(dashboard);190 let expectedGrid = [191 { x: 0, y: 0, w: 24, h: 8 }, // row192 { x: 0, y: 1, w: 24, h: 8 }, // row193 { x: 0, y: 2, w: 24, h: 8 },194 ];195 expect(panelGridPos).toEqual(expectedGrid);196 });197 it('should properly place panels with fixed height', function() {198 model.rows = [199 createRow({ height: 6 }, [[6], [6, 3], [6, 3]]),200 createRow({ height: 6 }, [[4], [4], [4, 3], [4, 3]]),201 ];202 let dashboard = new DashboardModel(model);203 let panelGridPos = getGridPositions(dashboard);204 let expectedGrid = [205 { x: 0, y: 0, w: 12, h: 6 },206 { x: 12, y: 0, w: 12, h: 3 },207 { x: 12, y: 3, w: 12, h: 3 },208 { x: 0, y: 6, w: 8, h: 6 },209 { x: 8, y: 6, w: 8, h: 6 },210 { x: 16, y: 6, w: 8, h: 3 },211 { x: 16, y: 9, w: 8, h: 3 },212 ];213 expect(panelGridPos).toEqual(expectedGrid);214 });215 it('should place panel to the right side of panel having bigger height', function() {216 model.rows = [createRow({ height: 6 }, [[4], [2, 3], [4, 6], [2, 3], [2, 3]])];217 let dashboard = new DashboardModel(model);218 let panelGridPos = getGridPositions(dashboard);219 let expectedGrid = [220 { x: 0, y: 0, w: 8, h: 6 },221 { x: 8, y: 0, w: 4, h: 3 },222 { x: 12, y: 0, w: 8, h: 6 },223 { x: 20, y: 0, w: 4, h: 3 },224 { x: 20, y: 3, w: 4, h: 3 },225 ];226 expect(panelGridPos).toEqual(expectedGrid);227 });228 it('should fill current row if it possible', function() {229 model.rows = [createRow({ height: 9 }, [[4], [2, 3], [4, 6], [2, 3], [2, 3], [8, 3]])];230 let dashboard = new DashboardModel(model);231 let panelGridPos = getGridPositions(dashboard);232 let expectedGrid = [233 { x: 0, y: 0, w: 8, h: 9 },234 { x: 8, y: 0, w: 4, h: 3 },235 { x: 12, y: 0, w: 8, h: 6 },236 { x: 20, y: 0, w: 4, h: 3 },237 { x: 20, y: 3, w: 4, h: 3 },238 { x: 8, y: 6, w: 16, h: 3 },239 ];240 expect(panelGridPos).toEqual(expectedGrid);241 });242 it('should fill current row if it possible (2)', function() {243 model.rows = [createRow({ height: 8 }, [[4], [2, 3], [4, 6], [2, 3], [2, 3], [8, 3]])];244 let dashboard = new DashboardModel(model);245 let panelGridPos = getGridPositions(dashboard);246 let expectedGrid = [247 { x: 0, y: 0, w: 8, h: 8 },248 { x: 8, y: 0, w: 4, h: 3 },249 { x: 12, y: 0, w: 8, h: 6 },250 { x: 20, y: 0, w: 4, h: 3 },251 { x: 20, y: 3, w: 4, h: 3 },252 { x: 8, y: 6, w: 16, h: 3 },253 ];254 expect(panelGridPos).toEqual(expectedGrid);255 });256 it('should fill current row if panel height more than row height', function() {257 model.rows = [createRow({ height: 6 }, [[4], [2, 3], [4, 8], [2, 3], [2, 3]])];258 let dashboard = new DashboardModel(model);259 let panelGridPos = getGridPositions(dashboard);260 let expectedGrid = [261 { x: 0, y: 0, w: 8, h: 6 },262 { x: 8, y: 0, w: 4, h: 3 },263 { x: 12, y: 0, w: 8, h: 8 },264 { x: 20, y: 0, w: 4, h: 3 },265 { x: 20, y: 3, w: 4, h: 3 },266 ];267 expect(panelGridPos).toEqual(expectedGrid);268 });269 it('should wrap panels to multiple rows', function() {270 model.rows = [createRow({ height: 6 }, [[6], [6], [12], [6], [3], [3]])];271 let dashboard = new DashboardModel(model);272 let panelGridPos = getGridPositions(dashboard);273 let expectedGrid = [274 { x: 0, y: 0, w: 12, h: 6 },275 { x: 12, y: 0, w: 12, h: 6 },276 { x: 0, y: 6, w: 24, h: 6 },277 { x: 0, y: 12, w: 12, h: 6 },278 { x: 12, y: 12, w: 6, h: 6 },279 { x: 18, y: 12, w: 6, h: 6 },280 ];281 expect(panelGridPos).toEqual(expectedGrid);282 });283 it('should add repeated row if repeat set', function() {284 model.rows = [285 createRow({ showTitle: true, title: 'Row', height: 8, repeat: 'server' }, [[6]]),286 createRow({ height: 8 }, [[12]]),287 ];288 let dashboard = new DashboardModel(model);289 let panelGridPos = getGridPositions(dashboard);290 let expectedGrid = [291 { x: 0, y: 0, w: 24, h: 8 },292 { x: 0, y: 1, w: 12, h: 8 },293 { x: 0, y: 9, w: 24, h: 8 },294 { x: 0, y: 10, w: 24, h: 8 },295 ];296 expect(panelGridPos).toEqual(expectedGrid);297 expect(dashboard.panels[0].repeat).toBe('server');298 expect(dashboard.panels[1].repeat).toBeUndefined();299 expect(dashboard.panels[2].repeat).toBeUndefined();300 expect(dashboard.panels[3].repeat).toBeUndefined();301 });302 it('should ignore repeated row', function() {303 model.rows = [304 createRow({ showTitle: true, title: 'Row1', height: 8, repeat: 'server' }, [[6]]),305 createRow(306 {307 showTitle: true,308 title: 'Row2',309 height: 8,310 repeatIteration: 12313,311 repeatRowId: 1,312 },313 [[6]]314 ),315 ];316 let dashboard = new DashboardModel(model);317 expect(dashboard.panels[0].repeat).toBe('server');318 expect(dashboard.panels.length).toBe(2);319 });320 it('minSpan should be twice', function() {321 model.rows = [createRow({ height: 8 }, [[6]])];322 model.rows[0].panels[0] = { minSpan: 12 };323 let dashboard = new DashboardModel(model);324 expect(dashboard.panels[0].minSpan).toBe(24);325 });326 it('should assign id', function() {327 model.rows = [createRow({ collapse: true, height: 8 }, [[6], [6]])];328 model.rows[0].panels[0] = {};329 let dashboard = new DashboardModel(model);330 expect(dashboard.panels[0].id).toBe(1);331 });332 });333});334function createRow(options, panelDescriptions: any[]) {335 const PANEL_HEIGHT_STEP = GRID_CELL_HEIGHT + GRID_CELL_VMARGIN;336 let { collapse, height, showTitle, title, repeat, repeatIteration } = options;337 height = height * PANEL_HEIGHT_STEP;338 let panels = [];339 _.each(panelDescriptions, panelDesc => {340 let panel = { span: panelDesc[0] };341 if (panelDesc.length > 1) {342 panel['height'] = panelDesc[1] * PANEL_HEIGHT_STEP;343 }344 panels.push(panel);345 });346 let row = {347 collapse,348 height,...
index.js
Source:index.js
...5window.onload = function () {6 let imgParent = document.querySelector("#map-img");78 // for (let i = 0; i < numRows; i++) {9 imgParent.append(createRow([7]));10 imgParent.append(createRow([5, 6, 7, 8]));11 imgParent.append(createRow([6, 7, 8, 9, 10, 11, 12]));12 imgParent.append(createRow([6, 7, 8, 9, 10, 11]));13 imgParent.append(createRow([6, 7, 8, 9, 10, 11]));14 imgParent.append(createRow([8, 9, 10, 11]));15 imgParent.append(createRow([7, 8, 9, 10]));16 imgParent.append(createRow([7, 8, 9, 10, 11, 12]));17 imgParent.append(createRow([6, 7, 8, 9, 10, 11, 12, 25, 26, 27]));18 imgParent.append(createRow([5, 6, 7, 8, 9, 10, 11, 12, 24, 25, 26, 27, 28]));19 imgParent.append(20 createRow([21 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 20, 23, 24, 25, 26, 27,22 28,23 ])24 );25 imgParent.append(26 createRow([27 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 20, 21, 22, 23,28 24, 25, 26,29 ])30 );31 imgParent.append(32 createRow([33 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23,34 24, 25, 26,35 ])36 );37 imgParent.append(38 createRow([39 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 24, 25, 26,40 ])41 );42 imgParent.append(43 createRow([44 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,45 23, 24, 25,46 ])47 );48 imgParent.append(49 createRow([50 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 24,51 ])52 );53 imgParent.append(54 createRow([55 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25,56 ])57 );5859 imgParent.append(60 createRow([2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18])61 );62 imgParent.append(63 createRow([5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18])64 );65 imgParent.append(createRow([4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]));6667 imgParent.append(createRow([5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]));68 imgParent.append(createRow([5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]));69 imgParent.append(createRow([5, 6, 7, 8, 9, 10, 11, 12, 13, 14]));70 imgParent.append(createRow([5, 6, 7, 8, 9, 10, 11, 12, 13]));71 imgParent.append(createRow([6, 7, 8, 9, 10, 11, 12]));72 imgParent.append(createRow([6, 7, 8, 9, 10, 11, 12]));73 imgParent.append(createRow([6, 7, 8, 9, 10, 11, 12]));74 imgParent.append(createRow([7, 8, 9, 10, 11]));75 imgParent.append(createRow([7, 8, 9, 10, 11]));76 imgParent.append(createRow([8, 9, 10, 11]));77 imgParent.append(createRow([8, 9, 10]));78 imgParent.append(createRow([9]));79 // imgParent.append(createRow([0, 3, 9]));8081 // }82};8384function createRow(arr) {85 let dotRow = document.createElement("div");86 dotRow.classList.add("dot-row");8788 for (let i = 0; i < numCols; i++) {89 dotRow.append(createDot(arr.findIndex((el) => el == i) != -1));90 }9192 return dotRow;93}9495function createDot(isBlue = false) {96 let dot = document.createElement("div");97 dot.classList.add("dot");98 if (isBlue) dot.classList.add("dot-primary");
...
auto-population.js
Source:auto-population.js
1function CreateRow(label, value) {2 var p = document.createElement('p');3 var b = document.createElement('b');4 p.appendChild(b);5 b.appendChild(document.createTextNode(label));6 p.appendChild(document.createTextNode(value));7 document.getElementById('contactinfo').appendChild(p);8}9function SetElqContent(){ 10 if (this.GetElqContentPersonalizationValue){11 CreateRow(': ', GetElqContentPersonalizationValue('C_EmailAddress'));12 CreateRow(': ', GetElqContentPersonalizationValue('C_FirstName'));13 CreateRow(': ', GetElqContentPersonalizationValue('C_LastName'));14 CreateRow(': ', GetElqContentPersonalizationValue('C_Job_Title1'));15 CreateRow(': ', GetElqContentPersonalizationValue('C_Company'));16 CreateRow(': ', GetElqContentPersonalizationValue('C_BusPhone'));17 CreateRow(': ', GetElqContentPersonalizationValue('C_Address1'));18 CreateRow(': ', GetElqContentPersonalizationValue('C_City'));19 CreateRow(': ', GetElqContentPersonalizationValue('C_State_Prov'));20 CreateRow(': ', GetElqContentPersonalizationValue('C_Country'));21 CreateRow(': ', GetElqContentPersonalizationValue('C_Zip_Postal'));22 CreateRow(': ', GetElqContentPersonalizationValue('C_TwitterID1'));23 CreateRow(': ', GetElqContentPersonalizationValue('C_Title'));24 CreateRow(': ', GetElqContentPersonalizationValue('C_Topic_of_Interest1'));25 CreateRow(': ', GetElqContentPersonalizationValue('C_Product_Interest_Area1'));26 CreateRow(': ', GetElqContentPersonalizationValue('C_Lead_Source___Most_Recent1'));27 CreateRow(': ', GetElqContentPersonalizationValue('C_Lead_Source___Original1'));28 CreateRow(': ', GetElqContentPersonalizationValue('C_EmailAddressDomain'));29 CreateRow(': ', GetElqContentPersonalizationValue('M_Instance_BU1'));30 CreateRow(': ', GetElqContentPersonalizationValue('C_MobilePhone'));31 CreateRow(': ', GetElqContentPersonalizationValue('C_Company_Size1'));32 } else {33 CreateRow('Personalization functions not found','');34 }...
Using AI Code Generation
1var createRow = require('devicefarmer-stf').createRow;2var row = createRow('test');3console.log(row);4var createRow = require('devicefarmer-stf').createRow;5var row = createRow('test');6console.log(row);7{ id: 'test', type: 'device', time: 2018-02-07T19:52:30.639Z }8{ id: 'test', type: 'device', time: 2018-02-07T19:52:30.639Z }9{ id: 'test', type: 'device', time: 2018-02-07T19:52:30.639Z }10{ id: 'test', type: 'device', time: 2018-02-07T19:52:30.639Z }11{ id: 'test', type: 'device', time: 2018-02-07T19:52:30.639Z }12{ id: 'test', type: 'device', time: 2018-02-07T19:52:30.639Z }13{ id: 'test', type: 'device', time: 2018-02-07T19:52:30.639Z }14{ id: 'test', type: 'device', time: 2018-02-07T19:52:30.639Z }15{ id: 'test', type: 'device', time: 2018-02-07T19:52:30.639Z }16{ id: 'test', type: 'device', time: 2018-02-07T19:52:30.639Z }17{ id: 'test', type: 'device', time: 2018-02-07T19:52:30.639Z }
Using AI Code Generation
1var df = require('devicefarmer-stf-client');2var row = client.createRow();3row.add('test', 'test');4row.add('test2', 'test2');5client.pushRow(row);6var df = require('devicefarmer-stf-client');7var row = client.createRow();8row.add('test', 'test');9row.add('test2', 'test2');10client.pushRow(row);11var df = require('devicefarmer-stf-client');12var row = client.createRow();13row.add('test', 'test');14row.add('test2', 'test2');15client.pushRow(row);16var df = require('devicefarmer-stf-client');17var row = client.createRow();18row.add('test', 'test');19row.add('test2', 'test2');20client.pushRow(row);21var df = require('devicefarmer-stf-client');22var row = client.createRow();23row.add('test', 'test');24row.add('test2', 'test2');25client.pushRow(row);26var df = require('devicefarmer-stf-client');27var row = client.createRow();28row.add('test', 'test');29row.add('test2', 'test2');30client.pushRow(row);31var df = require('devicefarmer-stf-client');32var row = client.createRow();33row.add('test', 'test');34row.add('test2', 'test2');35client.pushRow(row);
Using AI Code Generation
1var createRow = require('devicefarmer-stf-provider').createRow;2var row = createRow();3row.add('test', 'test');4row.add('test2', 'test2');5console.log(row);6{ test: 'test', test2: 'test2' }7The MIT License (MIT)8Copyright (c) 2015 DeviceFarmer
Using AI Code Generation
1var devicefarm = require('devicefarmer-stf-service');2var path = require('path');3var appPath = path.join(__dirname, 'app.apk');4var devicefarm = new devicefarm({5});6devicefarm.createRow(function(err, data) {7 if (err) {8 console.log('Error: ' + err);9 } else {10 console.log('Success: ' + data);11 }12});
Using AI Code Generation
1var createRow = require('devicefarmer-stf').createRow2var row = createRow('table name', 'row name', 'column name', 'column value')3console.log(row)4var deleteRow = require('devicefarmer-stf').deleteRow5var row = deleteRow('table name', 'row name', 'column name')6console.log(row)7var getRow = require('devicefarmer-stf').getRow8var row = getRow('table name', 'row name', 'column name')9console.log(row)10var updateRow = require('devicefarmer-stf').updateRow11var row = updateRow('table name', 'row name', 'column name', 'column value')12console.log(row)13var createTable = require('devicefarmer-stf').createTable14var table = createTable('table name')15console.log(table)16var deleteTable = require('devicefarmer-stf').deleteTable17var table = deleteTable('table name')18console.log(table)19var getTable = require('devicefarmer-stf').getTable20var table = getTable('table name')21console.log(table)22var updateTable = require('devicefarmer-stf').updateTable23var table = updateTable('table name')24console.log(table)25var createColumn = require('devicefarmer-stf').createColumn26var column = createColumn('table name', 'column name', 'column type')27console.log(column)
Using AI Code Generation
1var appium = require('devicefarmer-stf-appium');2var devicefarm = require('devicefarmer-devicefarm');3var fs = require('fs');4var path = require('path');5var config = require('./config.json');6var test = require('./test.json');7var testId = test.id;8var row = appium.createRow(testId);9appium.updateRow(row, 'testStarted');10appium.updateRow(row, 'testEnded');11appium.updateRow(row, 'stepExecuted');12appium.updateRow(row, 'stepFailed');13appium.updateRow(row, 'stepPassed');14appium.updateRow(row, 'stepSkipped');15appium.updateRow(row, 'stepRetried');16appium.updateRow(row, 'stepRetriedPassed');17appium.updateRow(row, 'stepRetriedFailed');
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!!