Best JavaScript code snippet using best
navigation_modify_test.js
Source:navigation_modify_test.js  
...28  suite('Marked Connection', function() {29    // TODO: Marked connection or cursor connection is already connected.30    suite('Marker on next', function() {31      setup(function() {32        Blockly.navigation.marker_.setLocation(33            Blockly.ASTNode.createConnectionNode(34                this.stack_block_1.nextConnection));35      });36      test('Cursor on workspace', function() {37        Blockly.navigation.cursor_.setLocation(38            Blockly.ASTNode.createWorkspaceNode(this.workspace,39                new Blockly.utils.Coordinate(0, 0)));40        chai.assert.isFalse(Blockly.navigation.modify());41      });42      test('Cursor on compatible connection', function() {43        Blockly.navigation.cursor_.setLocation(44            Blockly.ASTNode.createConnectionNode(45                this.stack_block_2.previousConnection));46        chai.assert.isTrue(Blockly.navigation.modify());47        chai.assert.equal(this.stack_block_1.getNextBlock().id, 'stack_block_2');48      });49      test('Cursor on incompatible connection', function() {50        Blockly.navigation.cursor_.setLocation(51            Blockly.ASTNode.createConnectionNode(52                this.stack_block_2.nextConnection));53        // Connect method will try to find a way to connect blocks with54        // incompatible types.55        chai.assert.isTrue(Blockly.navigation.modify());56        chai.assert.equal(this.stack_block_1.getNextBlock(), this.stack_block_2);57      });58      test('Cursor on really incompatible connection', function() {59        Blockly.navigation.cursor_.setLocation(60            Blockly.ASTNode.createConnectionNode(61                this.row_block_1.outputConnection));62        chai.assert.isFalse(Blockly.navigation.modify());63        chai.assert.isNull(this.stack_block_1.getNextBlock());64      });65      test('Cursor on block', function() {66        Blockly.navigation.cursor_.setLocation(67            Blockly.ASTNode.createBlockNode(68                this.stack_block_2));69        chai.assert.isTrue(Blockly.navigation.modify());70        chai.assert.equal(this.stack_block_1.getNextBlock().id, 'stack_block_2');71      });72    });73    suite('Marker on previous', function() {74      setup(function() {75        Blockly.navigation.marker_.setLocation(76            Blockly.ASTNode.createConnectionNode(77                this.stack_block_1.previousConnection));78      });79      test('Cursor on compatible connection', function() {80        Blockly.navigation.cursor_.setLocation(81            Blockly.ASTNode.createConnectionNode(82                this.stack_block_2.nextConnection));83        chai.assert.isTrue(Blockly.navigation.modify());84        chai.assert.equal(this.stack_block_1.getPreviousBlock().id, 'stack_block_2');85      });86      test('Cursor on incompatible connection', function() {87        Blockly.navigation.cursor_.setLocation(88            Blockly.ASTNode.createConnectionNode(89                this.stack_block_2.previousConnection));90        chai.assert.isFalse(Blockly.navigation.modify());91        chai.assert.isNull(this.stack_block_1.getPreviousBlock());92      });93      test('Cursor on really incompatible connection', function() {94        Blockly.navigation.cursor_.setLocation(95            Blockly.ASTNode.createConnectionNode(96                this.row_block_1.outputConnection));97        chai.assert.isFalse(Blockly.navigation.modify());98        chai.assert.isNull(this.stack_block_1.getNextBlock());99      });100      test('Cursor on block', function() {101        Blockly.navigation.cursor_.setLocation(102            Blockly.ASTNode.createBlockNode(103                this.stack_block_2));104        chai.assert.isTrue(Blockly.navigation.modify());105        chai.assert.equal(this.stack_block_1.getPreviousBlock().id, 'stack_block_2');106      });107      test('Cursor on incompatible block', function() {108        Blockly.navigation.cursor_.setLocation(109            Blockly.ASTNode.createBlockNode(110                this.row_block_1));111        chai.assert.isFalse(Blockly.navigation.modify());112        chai.assert.isNull(this.stack_block_1.getPreviousBlock());113      });114    });115    suite('Marker on value input', function() {116      setup(function() {117        Blockly.navigation.marker_.setLocation(118            Blockly.ASTNode.createConnectionNode(119                this.row_block_1.inputList[0].connection));120      });121      test('Cursor on compatible connection', function() {122        Blockly.navigation.cursor_.setLocation(123            Blockly.ASTNode.createConnectionNode(124                this.row_block_2.outputConnection));125        chai.assert.isTrue(Blockly.navigation.modify());126        chai.assert.equal(this.row_block_2.getParent().id, 'row_block_1');127      });128      test('Cursor on incompatible connection', function() {129        Blockly.navigation.cursor_.setLocation(130            Blockly.ASTNode.createConnectionNode(131                this.row_block_2.inputList[0].connection));132        // Connect method will try to find a way to connect blocks with133        // incompatible types.134        chai.assert.isTrue(Blockly.navigation.modify());135        chai.assert.equal(this.row_block_1.inputList[0].connection.targetBlock(),136            this.row_block_2);137      });138      test('Cursor on really incompatible connection', function() {139        Blockly.navigation.cursor_.setLocation(140            Blockly.ASTNode.createConnectionNode(141                this.stack_block_1.previousConnection));142        chai.assert.isFalse(Blockly.navigation.modify());143      });144      test('Cursor on block', function() {145        Blockly.navigation.cursor_.setLocation(146            Blockly.ASTNode.createBlockNode(147                this.row_block_2));148        chai.assert.isTrue(Blockly.navigation.modify());149        chai.assert.equal(this.row_block_2.getParent().id, 'row_block_1');150      });151    });152    suite('Statement input', function() {153      // TODO: fill this out.154    });155    suite('Marker on output', function() {156      setup(function() {157        Blockly.navigation.marker_.setLocation(158            Blockly.ASTNode.createConnectionNode(159                this.row_block_1.outputConnection));160      });161      test('Cursor on compatible connection', function() {162        Blockly.navigation.cursor_.setLocation(163            Blockly.ASTNode.createConnectionNode(164                this.row_block_2.inputList[0].connection));165        chai.assert.isTrue(Blockly.navigation.modify());166        chai.assert.equal(this.row_block_1.getParent().id, 'row_block_2');167      });168      test('Cursor on incompatible connection', function() {169        Blockly.navigation.cursor_.setLocation(170            Blockly.ASTNode.createConnectionNode(171                this.row_block_2.outputConnection));172        chai.assert.isFalse(Blockly.navigation.modify());173      });174      test('Cursor on really incompatible connection', function() {175        Blockly.navigation.cursor_.setLocation(176            Blockly.ASTNode.createConnectionNode(177                this.stack_block_1.previousConnection));178        chai.assert.isFalse(Blockly.navigation.modify());179      });180      test('Cursor on block', function() {181        Blockly.navigation.cursor_.setLocation(182            Blockly.ASTNode.createBlockNode(183                this.row_block_2));184        chai.assert.isTrue(Blockly.navigation.modify());185        chai.assert.equal(this.row_block_1.getParent().id, 'row_block_2');186      });187    });188  });189  suite('Marked Workspace', function() {190    setup(function() {191      Blockly.navigation.marker_.setLocation(192          Blockly.ASTNode.createWorkspaceNode(193              this.workspace, new Blockly.utils.Coordinate(100, 200)));194    });195    test('Cursor on row block', function() {196      Blockly.navigation.cursor_.setLocation(197          Blockly.ASTNode.createBlockNode(198              this.row_block_1));199      chai.assert.isTrue(Blockly.navigation.modify());200      var pos = this.row_block_1.getRelativeToSurfaceXY();201      chai.assert.equal(100, pos.x);202      chai.assert.equal(200, pos.y);203    });204    test('Cursor on output connection', function() {205      Blockly.navigation.cursor_.setLocation(206          Blockly.ASTNode.createConnectionNode(207              this.row_block_1.outputConnection));208      chai.assert.isTrue(Blockly.navigation.modify());209      var pos = this.row_block_1.getRelativeToSurfaceXY();210      chai.assert.equal(100, pos.x);211      chai.assert.equal(200, pos.y);212    });213    test('Cursor on previous connection', function() {214      Blockly.navigation.cursor_.setLocation(215          Blockly.ASTNode.createConnectionNode(216              this.stack_block_1.previousConnection));217      chai.assert.isTrue(Blockly.navigation.modify());218      var pos = this.stack_block_1.getRelativeToSurfaceXY();219      chai.assert.equal(100, pos.x);220      chai.assert.equal(200, pos.y);221    });222    test('Cursor on input connection', function() {223      Blockly.navigation.cursor_.setLocation(224          Blockly.ASTNode.createConnectionNode(225              this.row_block_1.inputList[0].connection));226      chai.assert.isFalse(Blockly.navigation.modify());227    });228    test('Cursor on next connection', function() {229      Blockly.navigation.cursor_.setLocation(230          Blockly.ASTNode.createConnectionNode(231              this.stack_block_1.nextConnection));232      chai.assert.isFalse(Blockly.navigation.modify());233    });234    test('Cursor on child block (row)', function() {235      this.row_block_1.inputList[0].connection.connect(236          this.row_block_2.outputConnection);237      Blockly.navigation.cursor_.setLocation(238          Blockly.ASTNode.createBlockNode(239              this.row_block_2));240      chai.assert.isTrue(Blockly.navigation.modify());241      chai.assert.isNull(this.row_block_2.getParent());242      var pos = this.row_block_2.getRelativeToSurfaceXY();243      chai.assert.equal(100, pos.x);244      chai.assert.equal(200, pos.y);245    });246    test('Cursor on child block (stack)', function() {247      this.stack_block_1.nextConnection.connect(248          this.stack_block_2.previousConnection);249      Blockly.navigation.cursor_.setLocation(250          Blockly.ASTNode.createBlockNode(251              this.stack_block_2));252      chai.assert.isTrue(Blockly.navigation.modify());253      chai.assert.isNull(this.stack_block_2.getParent());254      var pos = this.stack_block_2.getRelativeToSurfaceXY();255      chai.assert.equal(100, pos.x);256      chai.assert.equal(200, pos.y);257    });258    test('Cursor on workspace', function() {259      Blockly.navigation.cursor_.setLocation(260          Blockly.ASTNode.createWorkspaceNode(261              this.workspace, new Blockly.utils.Coordinate(100, 100)));262      chai.assert.isFalse(Blockly.navigation.modify());263    });264  });265  suite('Marked Block', function() {266    // TODO: Decide whether it ever makes sense to mark a block, and what to do267    // if so.  For now all of these attempted modifications will fail.268    suite('Marked any block', function() {269      // These tests are using a stack block, but do not depend on the type of270      // the block.271      setup(function() {272        Blockly.navigation.marker_.setLocation(273            Blockly.ASTNode.createBlockNode(274                this.stack_block_1));275      });276      test('Cursor on workspace', function() {277        Blockly.navigation.cursor_.setLocation(278            Blockly.ASTNode.createWorkspaceNode(279                this.workspace, new Blockly.utils.Coordinate(100, 100)));280        chai.assert.isFalse(Blockly.navigation.modify());281      });282    });283    suite('Marked stack block', function() {284      setup(function() {285        Blockly.navigation.marker_.setLocation(286            Blockly.ASTNode.createBlockNode(287                this.stack_block_1));288      });289      test('Cursor on row block', function() {290        Blockly.navigation.cursor_.setLocation(291            Blockly.ASTNode.createBlockNode(292                this.row_block_1));293        chai.assert.isFalse(Blockly.navigation.modify());294      });295      test('Cursor on stack block', function() {296        Blockly.navigation.cursor_.setLocation(297            Blockly.ASTNode.createBlockNode(298                this.stack_block_1));299        chai.assert.isFalse(Blockly.navigation.modify());300      });301      test('Cursor on next connection', function() {302        Blockly.navigation.cursor_.setLocation(303            Blockly.ASTNode.createConnectionNode(304                this.stack_block_2.nextConnection));305        chai.assert.isFalse(Blockly.navigation.modify());306      });307      test('Cursor on previous connection', function() {308        Blockly.navigation.cursor_.setLocation(309            Blockly.ASTNode.createConnectionNode(310                this.stack_block_2.previousConnection));311        chai.assert.isFalse(Blockly.navigation.modify());312      });313    });314    suite('Marked row block', function() {315      setup(function() {316        Blockly.navigation.marker_.setLocation(317            Blockly.ASTNode.createBlockNode(318                this.row_block_1));319      });320      test('Cursor on stack block', function() {321        Blockly.navigation.cursor_.setLocation(322            Blockly.ASTNode.createBlockNode(323                this.stack_block_1));324        chai.assert.isFalse(Blockly.navigation.modify());325      });326      test('Cursor on row block', function() {327        Blockly.navigation.cursor_.setLocation(328            Blockly.ASTNode.createBlockNode(329                this.row_block_1));330        chai.assert.isFalse(Blockly.navigation.modify());331      });332      test('Cursor on value input connection', function() {333        Blockly.navigation.cursor_.setLocation(334            Blockly.ASTNode.createConnectionNode(335                this.row_block_2.inputList[0].connection));336        chai.assert.isFalse(Blockly.navigation.modify());337      });338      test('Cursor on output connection', function() {339        Blockly.navigation.cursor_.setLocation(340            Blockly.ASTNode.createConnectionNode(341                this.row_block_2.outputConnection));342        chai.assert.isFalse(Blockly.navigation.modify());343      });344    });345  });...PSTNDemo.js
Source:PSTNDemo.js  
...60        this.box.add(cloudData);61        var link = new twaver.Link(cloudData, tw130);62        this.box.add(link);63        var cloudPSTN = new twaver.Node();64        cloudPSTN.setLocation(246, 209);65        cloudPSTN.setImage("cloud");66        cloudPSTN.setName("PSTN");67        cloudPSTN.setStyle('label.yoffset', -30);68        cloudPSTN.setStyle('label.color', '#000000');69        cloudPSTN.getAlarmState().propagateSeverity = twaver.AlarmSeverity.WARNING;70        this.box.add(cloudPSTN);71        var orlink = new twaver.Link(cloudPSTN, tw130);72        orlink.setStyle('link.type', 'orthogonal.H.V');73        this.box.add(orlink);74        var scrambler = new twaver.Node();75        scrambler.setLocation(175, 157);76        scrambler.setImage("router");77        scrambler.setName("Scrambler");78        this.box.add(scrambler);79        link = new twaver.Link(scrambler, cloudData);80        link.setStyle('link.flow', true);81        link.setStyle('link.flow.converse',true);82        link.setStyle('link.pattern', [5, 5]);83        link.setStyle('link.flow.color', 'red');84        link.setStyle('link.color', 'yellow');85        link.setStyle('vector.outline.color', '#FFFFFF');86        this.box.add(link);87        for (var i = 0; i < 7; i++) {88            node = new twaver.Node();89            if (i < 5) {90                node.setLocation(106, 95 + i * 12);91            } else {92                node.setLocation(106, 122 + i * 20);93            }94            node.setImage("router");95            this.box.add(node);96            if (i == 4) {97                node.setName("Encoder");98            }99            orlink = new twaver.Link(node, scrambler);100            orlink.setStyle('link.type', 'orthogonal.H.V');101            this.box.add(orlink);102        }103        var node = new twaver.Node();104        node.setImage("satellite_antenna");105        node.setLocation(31, 90);106        node.setName("Satellite Feed");107        this.box.add(node);108        node = new twaver.Node();109        node.setImage("antenna");110        node.setLocation(33, 183);111        node.setName("Off Air");112        this.box.add(node);113        node = new twaver.Node();114        node.setImage("msc");115        node.setLocation(33, 291);116        node.setName("Programming");117        this.box.add(node);118        var preAmp = new twaver.Node();119        preAmp.setImage("cartridge_system");120        preAmp.setLocation(191, 292);121        preAmp.setName("Pre-Amp");122        preAmp.setStyle('icons.names', ["att1", "att2", "att3"]);123        preAmp.setStyle('icons.colors', [null, "#00FF00", "#0000FF"]);124        this.box.add(preAmp);125        node = new twaver.Node();126        node.setLocation(105, 302);127        node.setImage("router");128        node.getAlarmState().setNewAlarmCount(twaver.AlarmSeverity.CRITICAL, 5);129        this.box.add(node);130        node.setName("V-OLT");131        link = new twaver.Link(node, preAmp);132        link.setStyle('icons.names', ["att2"]);133        this.box.add(link);134        var wdm = new twaver.Node();135        wdm.setName("WDM");136        wdm.setLocation(432, 146);137        wdm.setImage("wdm");138        this.box.add(wdm);139        orlink = new twaver.Link(preAmp, wdm);140        orlink.setStyle('link.type', 'orthogonal.H.V');141        orlink.setStyle('vector.outline.color', '#FF00FF');142        this.box.add(orlink);143        link = new twaver.Link(tw130, wdm);144        this.box.add(link);145        var test = new twaver.Node();146        test.setLocation(476, 161);147        test.setImage("testing");148        test.getAlarmState().setNewAlarmCount(twaver.AlarmSeverity.MAJOR, 1);149        this.box.add(test);150        link = new twaver.Link(test, wdm);151        this.box.add(link);152        wdm = new twaver.Node();153        wdm.setName("WDM");154        wdm.setLocation(516, 146);155        wdm.setImage("wdm");156        this.box.add(wdm);157        link = new twaver.Link(test, wdm);158        this.box.add(link);159        var ont = new twaver.Node();160        ont.setName("ONT");161        ont.setLocation(555, 196);162        ont.setImage("mainframe");163        this.box.add(ont);164        orlink = new twaver.Link(ont, wdm);165        orlink.setStyle('link.type', 'orthogonal.H.V');166        orlink.setStyle('icons.names', ["att2"]);167        this.box.add(orlink);168        var modem = new twaver.Node();169        modem.setImage("modem");170        modem.setLocation(560, 98);171        modem.setName("Modem");172        this.box.add(modem);173        var pc = new twaver.Node();174        pc.setName("PC");175        pc.setLocation(651, 64);176        this.box.add(pc);177        orlink = new twaver.Link(pc, modem);178        orlink.setStyle('link.type', 'orthogonal.H.V');179        this.box.add(orlink);180        var stb = new twaver.Node();181        stb.setImage("router2");182        stb.setName("STB");183        stb.setLocation(614, 122);184        this.box.add(stb);185        orlink = new twaver.Link(stb, modem);186        orlink.setStyle('link.type', 'orthogonal.H.V');187        this.box.add(orlink);188        var tv = new twaver.Node();189        tv.setImage("terminal");190        tv.setName("IPTV/SDV");191        tv.setLocation(666, 152);192        this.box.add(tv);193        var l = new twaver.Link(tv, stb);194        l.setStyle('link.type', 'orthogonal.H.V');195        this.box.add(l);196        var phone = new twaver.Node();197        phone.setImage("phone");198        phone.setLocation(648, 223);199        phone.setName("Phone");200        this.box.add(phone);201        orlink = new twaver.Link(phone, ont);202        orlink.setStyle('link.type', 'orthogonal.H.V');203        this.box.add(orlink);204        pc = new twaver.Node();205        pc.setName("PC");206        pc.setLocation(648, 266);207        this.box.add(pc);208        orlink = new twaver.Link(pc, ont);209        orlink.setStyle('link.type', 'orthogonal.H.V');210        this.box.add(orlink);211        stb = new twaver.Node();212        stb.setImage("router2");213        stb.setName("STB");214        stb.setLocation(609, 324);215        this.box.add(stb);216        orlink = new twaver.Link(stb, ont);217        orlink.setStyle('link.type', 'orthogonal.H.V');218        this.box.add(orlink);219        tv = new twaver.Node();220        tv.setImage("terminal");221        tv.setName("IPTV/SDV");222        tv.setLocation(641, 357);223        this.box.add(tv);224        l = new twaver.Link(tv, stb);225        l.setStyle('link.type', 'orthogonal.H.V');226        this.box.add(l);227    }...map.js
Source:map.js  
...47	}48	initMap(currentLat, currentLng); // init gmap49	let loop = false;50	let at = currentLat + ',' + currentLng;51	return new setLocation(currentLat, currentLng, currentAlt);52}53let myTravels = [54	new setLocation('40.079', '-75.160', 'Philly!'),55	new setLocation('40.7834', '-73.9662', 'NYC'),56	new setLocation('42.3188', '-71.0846', 'Boston'),57	new setLocation('26.1412', '-80.1464', 'Fort Lauderdale'),58	new setLocation('28.4788', '-81.342', 'Orlando'),59	new setLocation('30.2782', '-81.4045', 'Jacksonville'),60	new setLocation('25.7617', '-80.1918', 'Miami'),61	new setLocation('28.9270', '-82.0038', 'The Villages'),62	new setLocation('39.3051', '-76.6144', 'Baltimore'),63	new setLocation('43.1121', '-77.4869', 'Rochester'),64	new setLocation('41.8373', '-87.6861', 'Chicago'),65	new setLocation('41.4993', '-81.6944', 'Cleveland'),66	new setLocation('42.3834', '-83.1024', 'Detroit'),67	new setLocation('43.7', '-79.42', 'Toronto'),68	new setLocation('45.5', '-73.5833', 'Montreal'),69	new setLocation('44.65', '-63.6', 'Halifax'),70	new setLocation('32.0282', '-81.1786', 'Savannah'),71	new setLocation('40.4396', '-79.9763', 'Pittsburgh'),72	new setLocation('51.5', '-0.1167', 'London'),73	new setLocation('51.7704', '-1.25', 'Oxford'),74	new setLocation('50.2084', '-5.4909', 'Saint Ives'),75	new setLocation('51.45', '-2.5833', 'Bristol'),76	new setLocation('50.5938', '-4.83', 'Port Issiac'),77	new setLocation('51.3837', '-2.35', 'Bath'),78	new setLocation('55.6786', '12.5635', 'København'),79	new setLocation('27.9937', '-82.4454', 'Tampa'),80	new setLocation('24.5636', '-81.7769', 'Key West'),81	new setLocation('29.1386', '-83.0351', 'Cedar Keys'),82	new setLocation('52.35', '4.9166', 'Amsterdam'),83	new setLocation('47.38', '8.55', 'Zurich'),84	new setLocation('41.1400', '-104.8202', 'Cheyenne'),85	new setLocation('40.7774', '-111.9301', 'Salt Lake City'),86	new setLocation('39.5497', '-119.8483', 'Reno'),87	new setLocation('36.1699', '-115.1398', 'Las Vegas'),88	new setLocation('38.5667', '-121.4683', 'Sacramento'),89	new setLocation('37.7749', '-122.4194', 'San Francisco'),90	new setLocation('34.1139', '-118.4068', 'Los Angeles'),91	new setLocation('32.8312', '-117.1226', 'San Diego'),92	new setLocation('35.1872', '-111.6195', 'Flagstaff'),93	new setLocation('33.5722', '-112.0891', 'Phoenix'),94	new setLocation('39.1239', '-94.5541', 'Kansas City'),95	new setLocation('42.3127', '-83.2129', 'Dearborn'),96	new setLocation('44.4877', '-73.2314', 'Burlington'),97	new setLocation('42.8509', '-72.5579', 'Brattleboro'),98	new setLocation('29.4722', '-98.5247', 'San Antonio'),99	new setLocation('39.5309', '-75.8074', 'Chesapeake City'),100	new setLocation('55.9584', '12.5269', 'Humlebæk'),101	new setLocation('30.0687', '-89.9288', 'New Orleans'),102	new setLocation('39.1534', '-74.6929', 'Sea Isle City'),103	new setLocation('38.9072', '-77.0369', 'Washington D.C.'),104	new setLocation('47.238', '-93.5327', 'Grand Rapids'),105	new setLocation('44.2312', '-76.4860', 'Kingston'),106	new setLocation('44.4918', '-63.9187', 'Peggys Point'),107	new setLocation('44.5421', '-64.2389', 'Chester'),108	new setLocation('44.4592', '-64.1619', 'Big Tancook Island'),109	new setLocation('43.0962', '-79.0377', 'Niagara Falls'),110	new setLocation('41.3543', '-71.9665', 'Mystic'),111	new setLocation('41.6688', '-70.2962', 'Cape Cod'),112	new setLocation('41.0359', '-71.9545', 'Montauk'),113	new setLocation('43.5670', '-76.1277', 'Pulaski'),114	new setLocation('32.5149', '-117.0382', 'Tujianna'),115	new setLocation('42.1014', '-83.1087', 'Amherstburg'),116	new setLocation('42.6526', '-73.7562', 'Albany'),117	new setLocation('40.8759', '-75.7324', 'Jim Thorpe'),118	new setLocation('40.6259', '-75.3705', 'Bethlehem'),119	new setLocation('53.3498', '-6.2603', 'Dublin'),120	new setLocation('51.4852', '-2.7679', 'Portishead'),121	new setLocation('28.3200', '-80.6076', 'Cocoa Beach'),122	new setLocation('36.3803', '-75.8308', 'Corolla Outer Banks'),123	new setLocation('34.8697', '-111.7610', 'Sedona'),124	new setLocation('33.8303', '-116.5453', 'Palm Springs'),125	new setLocation('41.2565', '-95.9345', 'Omaha'),126	new setLocation('42.2917', '-85.5872', 'Kalamazoo'),127	new setLocation('42.8864', '-78.8784', 'Buffalo'),128	new setLocation('41.4901', '-71.3128', 'Newport'),129	new setLocation('38.8032', '-75.0946', 'Cape Henlopen'),130	new setLocation('40.3573', '-74.6672', 'Princeton'),131	new setLocation('55.5940', '12.6605', 'Dragør'),132	new setLocation('41.0807423', '-75.420217', 'The Poconos'),133	new setLocation('40.3643', '-74.9513', 'New Hope'),134	new setLocation('40.2204', '-74.0121', 'Asbury Park'),135	new setLocation('42.0409', '-74.1182', 'Woodstock'),136	new setLocation('40.1573°', '-76.3069', 'Lititz, PA'),137	new setLocation('35.0537916', '-78.8829083', 'Fayetteville'),138	new setLocation('32.8209674', '-80.1105604', 'Charleston'),139	new setLocation('31.368576', '-81.4352139', 'Darien'),140	new setLocation('43.0566242', '-70.8105213', 'Portsmouth'),141	new setLocation('36.9308009', '-76.309759', 'Norfolk'),142	new setLocation('41.7713327', '-76.4571832', 'Towanda'),143	new setLocation('43.4604012', '-76.5393677', 'Oswego'),144	new setLocation('43.0352286', '-76.1742993', 'Syracuse'),145	new setLocation('42.4427017', '-76.5158845', 'Ithica'),146	new setLocation('39.2605068', '-74.6380517', 'Ocean City'),147	new setLocation('38.9707996', '-74.8345959', 'Wildwood'),148	new setLocation('38.9403316', '-74.9212611', 'Cape May'),149	new setLocation('39.5473402', '-76.1240484', 'Harve De grace'),150	new setLocation('39.5753181', '-75.6093883', 'Delaware City'),151	new setLocation('36.1913724', '-75.7901978', 'Duck'),152	new setLocation('36.0710382', '-75.7302105', 'Kitty Hawk'),153	new setLocation('37.9161043', '-85.9562469', 'Fort Knox'),154	new setLocation('38.9784', '-76.4922', 'Annapolis'),155	new setLocation('38.7854', '-76.2233', 'St. Michaels'),156	// new setLocation('','',''),157	// new setLocation('','',''),158	// new setLocation('','',''),159	// new setLocation('','',''),160	// new setLocation('','',''),161	// new setLocation('','',''),162	// new setLocation('','',''),163	,164];165function goTravel() {166	myTravels.map((place) => {167		setMarkers(place.setLat, place.setLng, place.name);168	});169}170function setMarkers(lat, lng, copy) {171	let marker = new google.maps.Marker({172		position: {173			lat: parseFloat(lat),174			lng: parseFloat(lng),175		},176		map: map,...setLocationSpec.js
Source:setLocationSpec.js  
1describe('SetLocation', function () {2    var cleanup = function () {3        $('script[src*="gpt.js"]').remove();4        window.googletag = undefined;5    };6    beforeEach(cleanup);7    it('setLocation method called correctly with latitude and longitude', function (done) {8        var mock = {};9        mock.setLocation = function (param) { };10        var dummyTag = {};11        dummyTag.pubads = function () {12            return {13                enableSingleRequest: function () {},14                setTargeting: function () {},15                collapseEmptyDivs: function () {},16                addEventListener: function () {},17                setLocation: mock.setLocation18            };19        };20        dummyTag.enableServices = function() {};21        spyOn(dummyTag, 'enableServices').and.callThrough();22        spyOn(mock, 'setLocation').and.callThrough();23        jQuery.dfp({24            dfpID: 'xxxxxxxxx',25            googletag: dummyTag,26            setLocation: { latitude: 34, longitude: -45.12 }27        });28        waitsForAndRuns(function () {29            if (dummyTag.enableServices.calls.count() === 1) {30                return true;31            } else {32                return false;33            }34        }, function () {35            expect(mock.setLocation).toHaveBeenCalled();36            expect(mock.setLocation.calls.count()).toEqual(1);37            expect(mock.setLocation.calls.argsFor(0).length).toEqual(2);38            expect(mock.setLocation.calls.argsFor(0)[0]).toEqual(34);39            expect(mock.setLocation.calls.argsFor(0)[1]).toEqual(-45.12);40            done();41        }, 5000);42    });43    it('setLocation method called correctly with latitude, longitude and precision', function (done) {44        var mock = {};45        mock.setLocation = function (param) { };46        var dummyTag = {};47        dummyTag.pubads = function () {48            return {49                enableSingleRequest: function () {},50                setTargeting: function () {},51                collapseEmptyDivs: function () {},52                addEventListener: function () {},53                setLocation: mock.setLocation54            };55        };56        dummyTag.enableServices = function() {};57        spyOn(dummyTag, 'enableServices').and.callThrough();58        spyOn(mock, 'setLocation').and.callThrough();59        jQuery.dfp({60            dfpID: 'xxxxxxxxx',61            googletag: dummyTag,62            setLocation: { latitude: 34, longitude: -45.12, precision: 1000 }63        });64        waitsForAndRuns(function () {65            if (dummyTag.enableServices.calls.count() === 1) {66                return true;67            } else {68                return false;69            }70        }, function () {71            expect(mock.setLocation).toHaveBeenCalled();72            expect(mock.setLocation.calls.count()).toEqual(1);73            expect(mock.setLocation.calls.argsFor(0).length).toEqual(3);74            expect(mock.setLocation.calls.argsFor(0)[0]).toEqual(34);75            expect(mock.setLocation.calls.argsFor(0)[1]).toEqual(-45.12);76            expect(mock.setLocation.calls.argsFor(0)[2]).toEqual(1000);77            done();78        }, 5000);79    });80    it('setLocation method not called with latitude missing', function (done) {81        var mock = {};82        mock.setLocation = function (param) { };83        var dummyTag = {};84        dummyTag.pubads = function () {85            return {86                enableSingleRequest: function () {},87                setTargeting: function () {},88                collapseEmptyDivs: function () {},89                addEventListener: function () {},90                setLocation: mock.setLocation91            };92        };93        dummyTag.enableServices = function() {};94        spyOn(dummyTag, 'enableServices').and.callThrough();95        spyOn(mock, 'setLocation').and.callThrough();96        jQuery.dfp({97            dfpID: 'xxxxxxxxx',98            googletag: dummyTag,99            setLocation: { longitude: -45.12, precision: 1000 }100        });101        waitsForAndRuns(function () {102            if (dummyTag.enableServices.calls.count() === 1) {103                return true;104            } else {105                return false;106            }107        }, function () {108            expect(mock.setLocation).not.toHaveBeenCalled();109            done();110        }, 5000);111    });112    it('setLocation string variable type not accepted', function (done) {113        var mock = {};114        mock.setLocation = function (param) { };115        var dummyTag = {};116        dummyTag.pubads = function () {117            return {118                enableSingleRequest: function () {},119                setTargeting: function () {},120                collapseEmptyDivs: function () {},121                addEventListener: function () {},122                setLocation: mock.setLocation123            };124        };125        dummyTag.enableServices = function() {};126        spyOn(dummyTag, 'enableServices').and.callThrough();127        spyOn(mock, 'setLocation').and.callThrough();128        jQuery.dfp({129            dfpID: 'xxxxxxxxx',130            googletag: dummyTag,131            setLocation: { latitude: '34', longitude: -45.12, precision: 1000 }132        });133        waitsForAndRuns(function () {134            if (dummyTag.enableServices.calls.count() === 1) {135                return true;136            } else {137                return false;138            }139        }, function () {140            expect(mock.setLocation).not.toHaveBeenCalled();141            done();142        }, 5000);143    });...Using AI Code Generation
1var bestBuy = require('bestbuy')('API_KEY');2bestBuy.stores('area(78701,25)').then(function(data) {3  console.log(data);4});5#### bestBuy.categories([options])6#### bestBuy.categories(id, [options])7#### bestBuy.categories(id, 'products', [options])8#### bestBuy.categories(id, 'path', [options])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!!
