Best JavaScript code snippet using cypress
leafletLayerHelpers.js
Source:leafletLayerHelpers.js
...144 mustHaveUrl: false,145 createLayer: function(params) {146 var lyrs = [];147 $it.each(params.options.layers, function(l) {148 lyrs.push(createLayer(l));149 });150 params.options.loadedDefer = function() {151 var defers = [];152 if (isDefined(params.options.layers)) {153 for (var i = 0; i < params.options.layers.length; i++) {154 var d = params.options.layers[i].layerOptions.loadedDefer;155 if (isDefined(d)) {156 defers.push(d);157 }158 }159 }160 return defers;161 };162 return L.layerGroup(lyrs);163 },164 },165 featureGroup: {166 mustHaveUrl: false,167 createLayer: function() {168 return L.featureGroup();169 },170 },171 google: {172 mustHaveUrl: false,173 createLayer: function(params) {174 var type = params.type || 'SATELLITE';175 if (!Helpers.GoogleLayerPlugin.isLoaded()) {176 return;177 }178 return new L.Google(type, params.options);179 },180 },181 here: {182 mustHaveUrl: false,183 createLayer: function(params) {184 var provider = params.provider || 'HERE.terrainDay';185 if (!Helpers.LeafletProviderPlugin.isLoaded()) {186 return;187 }188 return new L.TileLayer.Provider(provider, params.options);189 },190 },191 china:{192 mustHaveUrl:false,193 createLayer:function(params) {194 var type = params.type || '';195 if (!Helpers.ChinaLayerPlugin.isLoaded()) {196 return;197 }198 return L.tileLayer.chinaProvider(type, params.options);199 },200 },201 agsBase: {202 mustHaveLayer: true,203 createLayer: function(params) {204 if (!Helpers.AGSBaseLayerPlugin.isLoaded()) {205 return;206 }207 return L.esri.basemapLayer(params.layer, params.options);208 },209 },210 ags: {211 mustHaveUrl: true,212 createLayer: function(params) {213 if (!Helpers.AGSLayerPlugin.isLoaded()) {214 return;215 }216 var options = angular.copy(params.options);217 angular.extend(options, {218 url: params.url,219 });220 var layer = new lvector.AGS(options);221 layer.onAdd = function(map) {222 this.setMap(map);223 };224 layer.onRemove = function() {225 this.setMap(null);226 };227 return layer;228 },229 },230 agsFeature: {231 mustHaveUrl: true,232 createLayer: function(params) {233 if (!Helpers.AGSFeatureLayerPlugin.isLoaded()) {234 $log.warn(errorHeader + ' The esri plugin is not loaded.');235 return;236 }237 params.options.url = params.url;238 var layer = L.esri.featureLayer(params.options);239 var load = function() {240 if (isDefined(params.options.loadedDefer)) {241 params.options.loadedDefer.resolve();242 }243 };244 layer.on('loading', function() {245 params.options.loadedDefer = $q.defer();246 layer.off('load', load);247 layer.on('load', load);248 });249 return layer;250 },251 },252 agsTiled: {253 mustHaveUrl: true,254 createLayer: function(params) {255 if (!Helpers.AGSTiledMapLayerPlugin.isLoaded()) {256 $log.warn(errorHeader + ' The esri plugin is not loaded.');257 return;258 }259 params.options.url = params.url;260 return L.esri.tiledMapLayer(params.options);261 },262 },263 agsDynamic: {264 mustHaveUrl: true,265 createLayer: function(params) {266 if (!Helpers.AGSDynamicMapLayerPlugin.isLoaded()) {267 $log.warn(errorHeader + ' The esri plugin is not loaded.');268 return;269 }270 params.options.url = params.url;271 return L.esri.dynamicMapLayer(params.options);272 },273 },274 agsImage: {275 mustHaveUrl: true,276 createLayer: function(params) {277 if (!Helpers.AGSImageMapLayerPlugin.isLoaded()) {278 $log.warn(errorHeader + ' The esri plugin is not loaded.');279 return;280 }281 params.options.url = params.url;282 return L.esri.imageMapLayer(params.options);283 },284 },285 agsClustered: {286 mustHaveUrl: true,287 createLayer: function(params) {288 if (!Helpers.AGSClusteredLayerPlugin.isLoaded()) {289 $log.warn(errorHeader + ' The esri clustered layer plugin is not loaded.');290 return;291 }292 if (!Helpers.MarkerClusterPlugin.isLoaded()) {293 $log.warn(errorHeader + ' The markercluster plugin is not loaded.');294 return;295 }296 return L.esri.clusteredFeatureLayer(params.url, params.options);297 },298 },299 agsHeatmap: {300 mustHaveUrl: true,301 createLayer: function(params) {302 if (!Helpers.AGSHeatmapLayerPlugin.isLoaded()) {303 $log.warn(errorHeader + ' The esri heatmap layer plugin is not loaded.');304 return;305 }306 if (!Helpers.HeatLayerPlugin.isLoaded()) {307 $log.warn(errorHeader + ' The heatlayer plugin is not loaded.');308 return;309 }310 return L.esri.heatmapFeatureLayer(params.url, params.options);311 },312 },313 markercluster: {314 mustHaveUrl: false,315 createLayer: function(params) {316 if (!Helpers.MarkerClusterPlugin.isLoaded()) {317 $log.warn(errorHeader + ' The markercluster plugin is not loaded.');318 return;319 }320 return new L.MarkerClusterGroup(params.options);321 },322 },323 bing: {324 mustHaveUrl: false,325 createLayer: function(params) {326 if (!Helpers.BingLayerPlugin.isLoaded()) {327 return;328 }329 return new L.BingLayer(params.key, params.options);330 },331 },332 webGLHeatmap: {333 mustHaveUrl: false,334 mustHaveData: true,335 createLayer: function(params) {336 if (!Helpers.WebGLHeatMapLayerPlugin.isLoaded()) {337 return;338 }339 var layer = new L.TileLayer.WebGLHeatMap(params.options);340 if (isDefined(params.data)) {341 layer.setData(params.data);342 }343 return layer;344 },345 },346 heat: {347 mustHaveUrl: false,348 mustHaveData: true,349 createLayer: function(params) {350 if (!Helpers.HeatLayerPlugin.isLoaded()) {351 return;352 }353 var layer = new L.heatLayer();354 if (isArray(params.data)) {355 layer.setLatLngs(params.data);356 }357 if (isObject(params.options)) {358 layer.setOptions(params.options);359 }360 return layer;361 },362 },363 yandex: {364 mustHaveUrl: false,365 createLayer: function(params) {366 var type = params.type || 'map';367 if (!Helpers.YandexLayerPlugin.isLoaded()) {368 return;369 }370 return new L.Yandex(type, params.options);371 },372 },373 imageOverlay: {374 mustHaveUrl: true,375 mustHaveBounds: true,376 createLayer: function(params) {377 return L.imageOverlay(params.url, params.bounds, params.options);378 },379 },380 iip: {381 mustHaveUrl: true,382 createLayer: function(params) {383 return L.tileLayer.iip(params.url, params.options);384 },385 },386 // This "custom" type is used to accept every layer that user want to define himself.387 // We can wrap these custom layers like heatmap or yandex, but it means a lot of work/code to wrap the world,388 // so we let user to define their own layer outside the directive,389 // and pass it on "createLayer" result for next processes390 custom: {391 createLayer: function(params) {392 if (params.layer instanceof L.Class) {393 return angular.copy(params.layer);394 } else {395 $log.error('[AngularJS - Leaflet] A custom layer must be a leaflet Class');396 }397 },398 },399 cartodb: {400 mustHaveUrl: true,401 createLayer: function(params) {402 return cartodb.createLayer(params.map, params.url);403 },404 },405 };406 function isValidLayerType(layerDefinition) {407 // Check if the baselayer has a valid type408 if (!isString(layerDefinition.type)) {409 $log.error('[AngularJS - Leaflet] A layer must have a valid type defined.');410 return false;411 }412 if (Object.keys(layerTypes).indexOf(layerDefinition.type) === -1) {413 $log.error('[AngularJS - Leaflet] A layer must have a valid type: ' + Object.keys(layerTypes));414 return false;415 }416 // Check if the layer must have an URL417 if (layerTypes[layerDefinition.type].mustHaveUrl && !isString(layerDefinition.url)) {418 $log.error('[AngularJS - Leaflet] A base layer must have an url');419 return false;420 }421 if (layerTypes[layerDefinition.type].mustHaveData && !isDefined(layerDefinition.data)) {422 $log.error('[AngularJS - Leaflet] The base layer must have a "data" array attribute');423 return false;424 }425 if (layerTypes[layerDefinition.type].mustHaveLayer && !isDefined(layerDefinition.layer)) {426 $log.error('[AngularJS - Leaflet] The type of layer ' + layerDefinition.type + ' must have an layer defined');427 return false;428 }429 if (layerTypes[layerDefinition.type].mustHaveBounds && !isDefined(layerDefinition.bounds)) {430 $log.error('[AngularJS - Leaflet] The type of layer ' + layerDefinition.type + ' must have bounds defined');431 return false;432 }433 if (layerTypes[layerDefinition.type].mustHaveKey && !isDefined(layerDefinition.key)) {434 $log.error('[AngularJS - Leaflet] The type of layer ' + layerDefinition.type + ' must have key defined');435 return false;436 }437 return true;438 }439 function createLayer(layerDefinition) {440 if (!isValidLayerType(layerDefinition)) {441 return;442 }443 if (!isString(layerDefinition.name)) {444 $log.error('[AngularJS - Leaflet] A base layer must have a name');445 return;446 }447 if (!isObject(layerDefinition.layerParams)) {448 layerDefinition.layerParams = {};449 }450 if (!isObject(layerDefinition.layerOptions)) {451 layerDefinition.layerOptions = {};452 }453 // Mix the layer specific parameters with the general Leaflet options. Although this is an overhead454 // the definition of a base layers is more 'clean' if the two types of parameters are differentiated455 for (var attrname in layerDefinition.layerParams) {456 layerDefinition.layerOptions[attrname] = layerDefinition.layerParams[attrname];457 }458 var params = {459 url: layerDefinition.url,460 data: layerDefinition.data,461 options: layerDefinition.layerOptions,462 layer: layerDefinition.layer,463 icon: layerDefinition.icon,464 type: layerDefinition.layerType,465 bounds: layerDefinition.bounds,466 key: layerDefinition.key,467 apiKey: layerDefinition.apiKey,468 pluginOptions: layerDefinition.pluginOptions,469 user: layerDefinition.user,470 };471 //TODO Add $watch to the layer properties472 return layerTypes[layerDefinition.type].createLayer(params);473 }474 function safeAddLayer(map, layer) {475 if (layer && typeof layer.addTo === 'function') {476 layer.addTo(map);477 } else {478 map.addLayer(layer);479 }480 }481 function safeRemoveLayer(map, layer, layerOptions) {482 if (isDefined(layerOptions) && isDefined(layerOptions.loadedDefer)) {483 if (angular.isFunction(layerOptions.loadedDefer)) {484 var defers = layerOptions.loadedDefer();485 $log.debug('Loaded Deferred', defers);486 var count = defers.length;...
components-frame.js
Source:components-frame.js
...21 frame.setY(10)22 assert.equal(frame.y(), 0)23 })24 it('toString', function() {25 var component1 = Component.init(createLayer('', 10, 40, 30, 40));26 var component2 = Component.init(createLayer('', 30, 20, 50, 60));27 var frame = ComponentsFrame.init(Components.items([component1, component2]))28 assert.equal(frame.toString(), '{10,20,70,60}')29 })30 describe('getter', function() {31 it('default', function() {32 var component1 = Component.init(createLayer('', 10, 40, 30, 40));33 var component2 = Component.init(createLayer('', 30, 20, 50, 60));34 var frame = ComponentsFrame.init(Components.items([component1, component2]))35 assert.equal(frame.x(), 10)36 assert.equal(frame.y(), 20)37 assert.equal(frame.width(), 70)38 assert.equal(frame.height(), 60)39 assert.equal(frame.top(), 20)40 assert.equal(frame.right(), 80)41 assert.equal(frame.bottom(), 80)42 assert.equal(frame.left(), 10)43 assert.equal(frame.maxWidth(), 50)44 assert.equal(frame.maxHeight(), 60)45 })46 it('x', function() {47 var layer1 = createLayer('1', 10, 0, 50, 60);48 var layer2 = createLayer('2', 20, 0, 100, 200);49 assert.equal(Components.init(NSArray.new([layer1, layer2])).frame().x(), 10);50 layer1.frame().setX(100);51 assert.equal(Components.init(NSArray.new([layer1, layer2])).frame().x(), 20);52 });53 it('y', function() {54 var layer1 = createLayer('1', 0, 10, 50, 60);55 var layer2 = createLayer('2', 0, 20, 100, 200);56 assert.equal(Components.init(NSArray.new([layer1, layer2])).frame().y(), 10);57 layer1.frame().setY(200);58 assert.equal(Components.init(NSArray.new([layer1, layer2])).frame().y(), 20);59 });60 it('width', function() {61 var layer1 = createLayer('1', 10, 0, 50, 60);62 var layer2 = createLayer('2', 20, 0, 100, 200);63 assert.equal(Components.init(NSArray.new([layer1, layer2])).frame().width(), 110);64 layer1.frame().setX(100);65 assert.equal(Components.init(NSArray.new([layer1, layer2])).frame().width(), 130);66 });67 it('height', function() {68 var layer1 = createLayer('1', 0, 10, 50, 60);69 var layer2 = createLayer('2', 0, 20, 100, 200);70 assert.equal(Components.init(NSArray.new([layer1, layer2])).frame().height(), 210);71 layer1.frame().setY(200);72 assert.equal(Components.init(NSArray.new([layer1, layer2])).frame().height(), 240);73 });74 it('maxWidth', function() {75 var layer1 = createLayer('1', 0, 0, 50, 60);76 var layer2 = createLayer('2', 0, 0, 100, 200);77 assert.equal(Components.init(NSArray.new([layer1, layer2])).frame().maxWidth(), 100);78 var layer2 = createLayer('w100%', 0, 0, 100, 200);79 assert.equal(Components.init(NSArray.new([layer1, layer2])).frame().maxWidth(), 50);80 var layer2 = createLayer('w100%%', 0, 0, 100, 200);81 assert.equal(Components.init(NSArray.new([layer1, layer2])).frame().maxWidth(), 100);82 });83 it('maxHeight', function() {84 var layer1 = createLayer('1', 0, 0, 50, 60);85 var layer2 = createLayer('2', 0, 0, 100, 200);86 assert.equal(Components.init(NSArray.new([layer1, layer2])).frame().maxHeight(), 200);87 var layer2 = createLayer('h100%', 0, 0, 100, 200);88 assert.equal(Components.init(NSArray.new([layer1, layer2])).frame().maxHeight(), 60);89 var layer2 = createLayer('h100%%', 0, 0, 100, 200);90 assert.equal(Components.init(NSArray.new([layer1, layer2])).frame().maxHeight(), 200);91 });92 it('right - ignore width percentage', function() {93 var component1 = Component.init(createLayer('', 10, 40, 30, 40));94 var component2 = Component.init(createLayer('w100%', 30, 20, 50, 60));95 var frame = ComponentsFrame.init(Components.items([component1, component2]))96 assert.equal(frame.right(), 40)97 var component1 = Component.init(createLayer('w100%', 10, 40, 30, 40));98 var component2 = Component.init(createLayer('', 30, 20, 50, 60));99 var frame = ComponentsFrame.init(Components.items([component1, component2]))100 assert.equal(frame.right(), 80)101 var component1 = Component.init(createLayer('w100%', 10, 40, 30, 40));102 var component2 = Component.init(createLayer('w100%', 30, 20, 50, 60));103 var frame = ComponentsFrame.init(Components.items([component1, component2]))104 assert.equal(frame.right(), 0)105 })106 it('right - ignore margin right', function() {107 var component1 = Component.init(createLayer('', 10, 40, 30, 40));108 var component2 = Component.init(createLayer('r', 30, 20, 50, 60));109 var frame = ComponentsFrame.init(Components.items([component1, component2]))110 assert.equal(frame.right(), 80)111 assert.equal(frame.right(true), 40)112 var component1 = Component.init(createLayer('r', 10, 40, 30, 40));113 var component2 = Component.init(createLayer('', 30, 20, 50, 60));114 var frame = ComponentsFrame.init(Components.items([component1, component2]))115 assert.equal(frame.right(), 80)116 assert.equal(frame.right(true), 80)117 var component1 = Component.init(createLayer('r', 10, 40, 30, 40));118 var component2 = Component.init(createLayer('r', 30, 20, 50, 60));119 var frame = ComponentsFrame.init(Components.items([component1, component2]))120 assert.equal(frame.right(), 80)121 assert.equal(frame.right(true), 0)122 })123 it('bottom - ignore height percentage', function() {124 var component1 = Component.init(createLayer('', 10, 40, 30, 40));125 var component2 = Component.init(createLayer('h100%', 30, 20, 50, 60));126 var frame = ComponentsFrame.init(Components.items([component1, component2]))127 assert.equal(frame.bottom(), 80)128 var component1 = Component.init(createLayer('h100%', 10, 40, 30, 40));129 var component2 = Component.init(createLayer('', 30, 40, 50, 60));130 var frame = ComponentsFrame.init(Components.items([component1, component2]))131 assert.equal(frame.bottom(), 100)132 var component1 = Component.init(createLayer('h100%', 10, 40, 30, 40));133 var component2 = Component.init(createLayer('h100%', 30, 20, 50, 60));134 var frame = ComponentsFrame.init(Components.items([component1, component2]))135 assert.equal(frame.bottom(), 0)136 })137 it('bottom - ignore margin bottom', function() {138 var component1 = Component.init(createLayer('', 10, 40, 30, 40));139 var component2 = Component.init(createLayer('b', 30, 40, 50, 60));140 var frame = ComponentsFrame.init(Components.items([component1, component2]))141 assert.equal(frame.bottom(), 100)142 assert.equal(frame.bottom(true), 80)143 var component1 = Component.init(createLayer('b', 10, 40, 30, 40));144 var component2 = Component.init(createLayer('', 30, 40, 50, 60));145 var frame = ComponentsFrame.init(Components.items([component1, component2]))146 assert.equal(frame.bottom(), 100)147 assert.equal(frame.bottom(true), 100)148 var component1 = Component.init(createLayer('b', 10, 40, 30, 40));149 var component2 = Component.init(createLayer('b', 30, 40, 50, 60));150 var frame = ComponentsFrame.init(Components.items([component1, component2]))151 assert.equal(frame.bottom(), 100)152 assert.equal(frame.bottom(true), 0)153 })154 it('maxWidth - ignore width percentage', function() {155 var component1 = Component.init(createLayer('', 10, 40, 30, 40));156 var component2 = Component.init(createLayer('w100%', 30, 20, 50, 60));157 var frame = ComponentsFrame.init(Components.items([component1, component2]))158 assert.equal(frame.maxWidth(), 30)159 var component1 = Component.init(createLayer('w100%', 10, 40, 30, 40));160 var component2 = Component.init(createLayer('', 30, 20, 50, 60));161 var frame = ComponentsFrame.init(Components.items([component1, component2]))162 assert.equal(frame.maxWidth(), 50)163 var component1 = Component.init(createLayer('w100%', 10, 40, 30, 40));164 var component2 = Component.init(createLayer('w100%', 30, 20, 50, 60));165 var frame = ComponentsFrame.init(Components.items([component1, component2]))166 assert.equal(frame.maxWidth(), 0)167 })168 it('maxHeight - ignore height percentage', function() {169 var component1 = Component.init(createLayer('', 10, 40, 30, 40));170 var component2 = Component.init(createLayer('h100%', 30, 20, 50, 60));171 var frame = ComponentsFrame.init(Components.items([component1, component2]))172 assert.equal(frame.maxHeight(), 40)173 var component1 = Component.init(createLayer('h100%', 10, 40, 30, 40));174 var component2 = Component.init(createLayer('', 30, 40, 50, 60));175 var frame = ComponentsFrame.init(Components.items([component1, component2]))176 assert.equal(frame.maxHeight(), 60)177 var component1 = Component.init(createLayer('h100%', 10, 40, 30, 40));178 var component2 = Component.init(createLayer('h100%', 30, 20, 50, 60));179 var frame = ComponentsFrame.init(Components.items([component1, component2]))180 assert.equal(frame.maxHeight(), 0)181 })182 })183 describe('setter', function() {184 it('setX', function() {185 var component1 = Component.init(createLayer('', 10, 40, 30, 40));186 var component2 = Component.init(createLayer('', 30, 20, 50, 60));187 var frame = ComponentsFrame.init(Components.items([component1, component2]))188 frame.setX(100)189 assert.equal(frame.x(), 100)190 assert.equal(frame.y(), 20)191 assert.equal(frame.width(), 70)192 assert.equal(frame.height(), 60)193 assert.equal(frame.top(), 20)194 assert.equal(frame.right(), 170)195 assert.equal(frame.bottom(), 80)196 assert.equal(frame.left(), 100)197 assert.equal(component1.frame().x(), 100)198 assert.equal(component2.frame().x(), 120)199 })200 it('setY', function() {201 var component1 = Component.init(createLayer('', 10, 40, 30, 40));202 var component2 = Component.init(createLayer('', 30, 20, 50, 60));203 var frame = ComponentsFrame.init(Components.items([component1, component2]))204 frame.setY(100)205 assert.equal(frame.x(), 10)206 assert.equal(frame.y(), 100)207 assert.equal(frame.width(), 70)208 assert.equal(frame.height(), 60)209 assert.equal(frame.top(), 100)210 assert.equal(frame.right(), 80)211 assert.equal(frame.bottom(), 160)212 assert.equal(frame.left(), 10)213 assert.equal(component1.frame().y(), 120)214 assert.equal(component2.frame().y(), 100)215 })216 it('setWidth', function() {217 var component1 = Component.init(createLayer('', 10, 40, 30, 40));218 var component2 = Component.init(createLayer('', 30, 20, 50, 60));219 var frame = ComponentsFrame.init(Components.items([component1, component2]))220 frame.setWidth(100)221 assert.equal(frame.x(), 10)222 assert.equal(frame.y(), 20)223 assert.equal(frame.width(), 70)224 assert.equal(frame.height(), 60)225 assert.equal(frame.top(), 20)226 assert.equal(frame.right(), 80)227 assert.equal(frame.bottom(), 80)228 assert.equal(frame.left(), 10)229 assert.equal(frame.maxWidth(), 50)230 assert.equal(frame.maxHeight(), 60)231 })232 it('setHeight', function() {233 var component1 = Component.init(createLayer('', 10, 40, 30, 40));234 var component2 = Component.init(createLayer('', 30, 20, 50, 60));235 var frame = ComponentsFrame.init(Components.items([component1, component2]))236 frame.setHeight(100)237 assert.equal(frame.x(), 10)238 assert.equal(frame.y(), 20)239 assert.equal(frame.width(), 70)240 assert.equal(frame.height(), 60)241 assert.equal(frame.top(), 20)242 assert.equal(frame.right(), 80)243 assert.equal(frame.bottom(), 80)244 assert.equal(frame.left(), 10)245 assert.equal(frame.maxWidth(), 50)246 assert.equal(frame.maxHeight(), 60)247 })248 });...
quads.test.js
Source:quads.test.js
1'use strict';2const test = require('mapbox-gl-js-test').test;3const getIconQuads = require('../../../src/symbol/quads').getIconQuads;4const Anchor = require('../../../src/symbol/anchor');5function createLayer(layer) {6 return {7 layout: layer.layout,8 getLayoutValue: function(key) {9 return layer.layout[key];10 }11 };12}13function createShapedIcon() {14 return {15 top: -5,16 bottom: 6,17 left: -7,18 right: 8,19 image: {20 pixelRatio: 1,21 textureRect: { x: 1, y: 1, w: 15, h: 11}22 }23 };24}25test('getIconQuads', (t) => {26 t.test('point', (t) => {27 const anchor = new Anchor(2, 3, 0, undefined);28 const layer = createLayer({29 layout: {'icon-rotate': 0}30 });31 t.deepEqual(getIconQuads(anchor, createShapedIcon(), layer, false), [32 {33 tl: { x: -8, y: -6 },34 tr: { x: 9, y: -6 },35 bl: { x: -8, y: 7 },36 br: { x: 9, y: 7 },37 tex: { x: 0, y: 0, w: 17, h: 13 },38 writingMode: null,39 glyphOffset: [0, 0]40 }]);41 t.end();42 });43 t.test('line', (t) => {44 const anchor = new Anchor(2, 3, 0, 0);45 const layer = createLayer({46 layout: {'icon-rotate': 0}47 });48 t.deepEqual(getIconQuads(anchor, createShapedIcon(), layer, false), [49 {50 tl: { x: -8, y: -6 },51 tr: { x: 9, y: -6 },52 bl: { x: -8, y: 7 },53 br: { x: 9, y: 7 },54 tex: { x: 0, y: 0, w: 17, h: 13 },55 writingMode: null,56 glyphOffset: [0, 0]57 }]);58 t.end();59 });60 t.end();61});62test('getIconQuads text-fit', (t) => {63 const anchor = new Anchor(0, 0, 0, undefined);64 function createShapedIcon() {65 return {66 top: -10,67 bottom: 10,68 left: -10,69 right: 10,70 image: {71 pixelRatio: 1,72 textureRect: { x: 1, y: 1, w: 20, h: 20 }73 }74 };75 }76 function createshapedText() {77 return {78 top: -10,79 bottom: 30,80 left: -60,81 right: 2082 };83 }84 t.test('icon-text-fit: none', (t) => {85 const quads = getIconQuads(anchor, createShapedIcon(), createLayer({86 layout: {87 'icon-text-fit': 'none'88 }89 }), false, createshapedText());90 t.deepEqual(quads[0].tl, { x: -11, y: -11 });91 t.deepEqual(quads[0].tr, { x: 11, y: -11 });92 t.deepEqual(quads[0].bl, { x: -11, y: 11 });93 t.deepEqual(quads[0].br, { x: 11, y: 11 });94 t.deepEqual(quads, getIconQuads(anchor, createShapedIcon(), createLayer({95 layout: {96 'icon-text-fit': 'none',97 'icon-text-fit-padding': [10, 10]98 }99 }), false, createshapedText()), 'ignores padding');100 t.end();101 });102 t.test('icon-text-fit: width', (t) => {103 // - Uses text width104 // - Preserves icon height, centers vertically105 const quads = getIconQuads(anchor, createShapedIcon(), createLayer({106 layout: {107 'text-size': 24,108 'icon-text-fit': 'width',109 'icon-text-fit-padding': [ 0, 0, 0, 0 ]110 }111 }), false, createshapedText());112 t.deepEqual(quads[0].tl, { x: -60, y: -1 });113 t.deepEqual(quads[0].tr, { x: 20, y: -1 });114 t.deepEqual(quads[0].bl, { x: -60, y: 21 });115 t.deepEqual(quads[0].br, { x: 20, y: 21 });116 t.end();117 });118 t.test('icon-text-fit: width, x textSize', (t) => {119 // - Uses text width (adjusted for textSize)120 // - Preserves icon height, centers vertically121 const quads = getIconQuads(anchor, createShapedIcon(), createLayer({122 layout: {123 'text-size': 12,124 'icon-text-fit': 'width',125 'icon-text-fit-padding': [ 0, 0, 0, 0 ]126 }127 }), false, createshapedText());128 t.deepEqual(quads[0].tl, { x: -30, y: -6 });129 t.deepEqual(quads[0].tr, { x: 10, y: -6 });130 t.deepEqual(quads[0].bl, { x: -30, y: 16 });131 t.deepEqual(quads[0].br, { x: 10, y: 16 });132 t.end();133 });134 t.test('icon-text-fit: width, x textSize, + padding', (t) => {135 // - Uses text width (adjusted for textSize)136 // - Preserves icon height, centers vertically137 // - Applies padding x, padding y138 const quads = getIconQuads(anchor, createShapedIcon(), createLayer({139 layout: {140 'text-size': 12,141 'icon-text-fit': 'width',142 'icon-text-fit-padding': [ 5, 10, 5, 10 ]143 }144 }), false, createshapedText());145 t.deepEqual(quads[0].tl, { x: -40, y: -11 });146 t.deepEqual(quads[0].tr, { x: 20, y: -11 });147 t.deepEqual(quads[0].bl, { x: -40, y: 21 });148 t.deepEqual(quads[0].br, { x: 20, y: 21 });149 t.end();150 });151 t.test('icon-text-fit: height', (t) => {152 // - Uses text height153 // - Preserves icon width, centers horizontally154 const quads = getIconQuads(anchor, createShapedIcon(), createLayer({155 layout: {156 'text-size': 24,157 'icon-text-fit': 'height',158 'icon-text-fit-padding': [ 0, 0, 0, 0 ]159 }160 }), false, createshapedText());161 t.deepEqual(quads[0].tl, { x: -31, y: -10 });162 t.deepEqual(quads[0].tr, { x: -9, y: -10 });163 t.deepEqual(quads[0].bl, { x: -31, y: 30 });164 t.deepEqual(quads[0].br, { x: -9, y: 30 });165 t.end();166 });167 t.test('icon-text-fit: height, x textSize', (t) => {168 // - Uses text height (adjusted for textSize)169 // - Preserves icon width, centers horizontally170 const quads = getIconQuads(anchor, createShapedIcon(), createLayer({171 layout: {172 'text-size': 12,173 'icon-text-fit': 'height',174 'icon-text-fit-padding': [ 0, 0, 0, 0 ]175 }176 }), false, createshapedText());177 t.deepEqual(quads[0].tl, { x: -21, y: -5 });178 t.deepEqual(quads[0].tr, { x: 1, y: -5 });179 t.deepEqual(quads[0].bl, { x: -21, y: 15 });180 t.deepEqual(quads[0].br, { x: 1, y: 15 });181 t.end();182 });183 t.test('icon-text-fit: height, x textSize, + padding', (t) => {184 // - Uses text height (adjusted for textSize)185 // - Preserves icon width, centers horizontally186 // - Applies padding x, padding y187 const quads = getIconQuads(anchor, createShapedIcon(), createLayer({188 layout: {189 'text-size': 12,190 'icon-text-fit': 'height',191 'icon-text-fit-padding': [ 5, 10, 5, 10 ]192 }193 }), false, createshapedText());194 t.deepEqual(quads[0].tl, { x: -31, y: -10 });195 t.deepEqual(quads[0].tr, { x: 11, y: -10 });196 t.deepEqual(quads[0].bl, { x: -31, y: 20 });197 t.deepEqual(quads[0].br, { x: 11, y: 20 });198 t.end();199 });200 t.test('icon-text-fit: both', (t) => {201 // - Uses text width + height202 const quads = getIconQuads(anchor, createShapedIcon(), createLayer({203 layout: {204 'text-size': 24,205 'icon-text-fit': 'both',206 'icon-text-fit-padding': [ 0, 0, 0, 0 ]207 }208 }), false, createshapedText());209 t.deepEqual(quads[0].tl, { x: -60, y: -10 });210 t.deepEqual(quads[0].tr, { x: 20, y: -10 });211 t.deepEqual(quads[0].bl, { x: -60, y: 30 });212 t.deepEqual(quads[0].br, { x: 20, y: 30 });213 t.end();214 });215 t.test('icon-text-fit: both, x textSize', (t) => {216 // - Uses text width + height (adjusted for textSize)217 const quads = getIconQuads(anchor, createShapedIcon(), createLayer({218 layout: {219 'text-size': 12,220 'icon-text-fit': 'both',221 'icon-text-fit-padding': [ 0, 0, 0, 0 ]222 }223 }), false, createshapedText());224 t.deepEqual(quads[0].tl, { x: -30, y: -5 });225 t.deepEqual(quads[0].tr, { x: 10, y: -5 });226 t.deepEqual(quads[0].bl, { x: -30, y: 15 });227 t.deepEqual(quads[0].br, { x: 10, y: 15 });228 t.end();229 });230 t.test('icon-text-fit: both, x textSize, + padding', (t) => {231 // - Uses text width + height (adjusted for textSize)232 // - Applies padding x, padding y233 const quads = getIconQuads(anchor, createShapedIcon(), createLayer({234 layout: {235 'text-size': 12,236 'icon-text-fit': 'both',237 'icon-text-fit-padding': [ 5, 10, 5, 10 ]238 }239 }), false, createshapedText());240 t.deepEqual(quads[0].tl, { x: -40, y: -10 });241 t.deepEqual(quads[0].tr, { x: 20, y: -10 });242 t.deepEqual(quads[0].bl, { x: -40, y: 20 });243 t.deepEqual(quads[0].br, { x: 20, y: 20 });244 t.end();245 });246 t.test('icon-text-fit: both, padding t/r/b/l', (t) => {247 // - Uses text width + height (adjusted for textSize)248 // - Applies padding t/r/b/l249 const quads = getIconQuads(anchor, createShapedIcon(), createLayer({250 layout: {251 'text-size': 12,252 'icon-text-fit': 'both',253 'icon-text-fit-padding': [ 0, 5, 10, 15 ]254 }255 }), false, createshapedText());256 t.deepEqual(quads[0].tl, { x: -45, y: -5 });257 t.deepEqual(quads[0].tr, { x: 15, y: -5 });258 t.deepEqual(quads[0].bl, { x: -45, y: 25 });259 t.deepEqual(quads[0].br, { x: 15, y: 25 });260 t.end();261 });262 t.end();263});
ui-leaflet-layers.js
Source:ui-leaflet-layers.js
...67 };68 angular.extend($delegate.layerTypes, {69 google: {70 mustHaveUrl: false,71 createLayer: function createLayer(params) {72 var type = params.type || 'SATELLITE';73 if (!leafletHelpers.GoogleLayerPlugin.isLoaded()) {74 $log.error(errorHeader + ' The GoogleLayer plugin is not loaded.');75 return;76 }77 return new L.Google(type, params.options);78 }79 },80 mapboxGL: {81 createLayer: function createLayer(params) {82 if (!leafletHelpers.MapboxGL.isLoaded()) {83 $log.error(errorHeader + ' The MapboxGL plugin is not loaded.');84 return;85 }86 return new L.mapboxGL(params.options);87 }88 },89 bing: {90 mustHaveUrl: false,91 createLayer: function createLayer(params) {92 if (!leafletHelpers.BingLayerPlugin.isLoaded()) {93 $log.error(errorHeader + ' The Bing plugin is not loaded.');94 return;95 }96 return new L.BingLayer(params.key, params.options);97 }98 },99 wfs: {100 mustHaveUrl: true,101 mustHaveLayer: true,102 createLayer: function createLayer(params) {103 if (!leafletHelpers.WFSLayerPlugin.isLoaded()) {104 $log.error(errorHeader + ' The WFSLayer plugin is not loaded.');105 return;106 }107 var options = angular.copy(params.options);108 if (options.crs && 'string' === typeof options.crs) {109 options.crs = eval(options.crs);110 }111 return new L.GeoJSON.WFS(params.url, params.layer, options);112 }113 },114 china: {115 mustHaveUrl: false,116 createLayer: function createLayer(params) {117 var type = params.type || '';118 if (!leafletHelpers.ChinaLayerPlugin.isLoaded()) {119 $log.error(errorHeader + ' The ChinaLayer plugin is not loaded.');120 return;121 }122 return L.tileLayer.chinaProvider(type, params.options);123 }124 },125 heat: {126 mustHaveUrl: false,127 mustHaveData: true,128 createLayer: function createLayer(params) {129 if (!leafletHelpers.HeatLayerPlugin.isLoaded()) {130 $log.error(errorHeader + ' The HeatMapLayer plugin is not loaded.');131 return;132 }133 var layer = new L.heatLayer();134 if (isArray(params.data)) {135 layer.setLatLngs(params.data);136 }137 if (isObject(params.options)) {138 layer.setOptions(params.options);139 }140 return layer;141 }142 },143 webGLHeatmap: {144 mustHaveUrl: false,145 mustHaveData: true,146 createLayer: function createLayer(params) {147 if (!leafletHelpers.WebGLHeatMapLayerPlugin.isLoaded()) {148 $log.error(errorHeader + ' The WebGLHeatMapLayer plugin is not loaded.');149 return;150 }151 var layer = new L.TileLayer.WebGLHeatMap(params.options);152 if (isDefined(params.data)) {153 layer.setData(params.data);154 }155 return layer;156 }157 },158 yandex: {159 mustHaveUrl: false,160 createLayer: function createLayer(params) {161 var type = params.type || 'map';162 if (!leafletHelpers.YandexLayerPlugin.isLoaded()) {163 $log.error(errorHeader + ' The YandexLayer plugin is not loaded.');164 return;165 }166 return new L.Yandex(type, params.options);167 }168 },169 utfGrid: {170 mustHaveUrl: true,171 createLayer: utfGridCreateLayer172 }173 });174 return $delegate;...
table-create-layer.js
Source:table-create-layer.js
1define(2['jquery'],3function (jQuery) {4 /**5 * Initialize of the CreateLayer object6 */7 CreateLayer = function(TablePlugin){8 this.TablePlugin = TablePlugin;9 };10 /**11 * Internal configuration of the create-table panel12 */13 CreateLayer.prototype.parameters = {14 elemId: 'aloha-table-createLayer', // id of the create-table panel15 className: 'aloha-table-createdialog', // class-name of the create-table panel16 numX: 10, // Number of cols in the create-layer17 numY: 10, // Number of rows in the create-layer vertically18 layer: undefined, // Attribute holding the create-layer19 target: undefined // the clicktarget which was clicked on (mostly the button of the floatingmenu)20 };21 /**22 * The configuration-object for the implementer of the plugin. All keys of23 * the "parameters" object could be overwritten within this object and will24 * simply be used instead.25 */26 CreateLayer.prototype.config = new Object();27 /**28 * Flag wether the CreateLayer is currently visble or not29 */30 CreateLayer.prototype.visible = false;31 /**32 * This function checks if there is an create-table-layer. If no layer exists, it creates one and puts it into the configuration.33 * If the layer was already created it sets the position of the panel and shows it.34 *35 * @return void36 */37 CreateLayer.prototype.show = function(){38 var layer = this.get('layer');39 // create the panel if the layer doesn't exist40 if (layer == null) {41 this.create();42 }else {43 // or reposition, cleanup and show the layer44 this.setPosition(layer);45 layer.find('td').removeClass('hover');46 layer.show();47 }48 this.visible = true;49 };50 /**51 * Creates the div-layer which holds a table with the given number of rows and cols.52 * It sets click and mouseover-events to the table data fields53 *54 * @return void55 */56 CreateLayer.prototype.create = function () {57 var that = this;58 var layer = jQuery('<div></div>');59 layer.id = this.get('elemId');60 layer.addClass(this.get('className'));61 var table = jQuery('<table></table>');62 table.css('width', (this.get('numX') + 6) * 15);63 var tr;64 var td;65 for (var i = 0; i < this.get('numY'); i++) {66 tr = jQuery('<tr></tr>');67 for (var j = 0; j < this.get('numX'); j++) {68 td = jQuery('<td>\u00a0</td>');69 if (i == 0 && j == 0) {70 td.addClass('hover');71 }72 td.bind('mouseover', {rowId: i, colId: j}, function(e) {73 that.handleMouseOver(e, table);74 });75 td.bind('click', {rowId: i, colId: j}, function(e){76 var rows = e.data.rowId + 1;77 var cols = e.data.colId + 1;78 that.TablePlugin.createTable(cols, rows);79 that.hide();80 });81 tr.append(td);82 }83 table.append(tr);84 }85 layer.append(table);86 // set attributes87 this.set('layer', layer);88 this.setPosition();89 // stop bubbling the click on the create-dialog up to the body event90 layer.bind('click', function(e) {91 e.stopPropagation();92 }).mousedown(function(e) {93 e.stopPropagation();94 });95 // append layer to body and96 // hide the create layer if user clicks anywhere in the body97 jQuery('body').append(layer).bind('click', function(e) {98 // If the layer is visible and the event target is not the99 // button itself or a descendant of the button, hide the100 // layer.101 if (that.visible && !(e.target === that.get('target')[0] || jQuery.contains(that.get('target')[0], e.target))) {102 that.hide();103 }104 });105 };106 /**107 * handles the mose over state for a cell108 * @param e event object109 * @param table the aeffected table110 * @return void111 */112 CreateLayer.prototype.handleMouseOver = function(e, table) {113 var rowId = e.data.rowId;114 var colId = e.data.colId;115 var innerRows = table.find('tr');116 for (var n = 0; n <= innerRows.length; n++) {117 var innerCells = jQuery(innerRows[n]).find('td');118 for (var k = 0; k <= innerCells.length; k++) {119 if (n <= rowId && k <= colId) {120 jQuery(innerCells[k]).addClass('hover');121 } else {122 jQuery(innerCells[k]).removeClass('hover');123 }124 }125 }126 };127 /**128 * Sets the "left" and "top" style-attributes according to the clicked target-button129 *130 * @return void131 */132 CreateLayer.prototype.setPosition = function() {133 var targetObj = jQuery(this.get('target'));134 var pos = targetObj.offset();135 this.get('layer').css('left', pos.left + 'px');136 this.get('layer').css('top', (pos.top + targetObj.height()) + 'px');137 };138 /**139 * Hides the create-table panel width the jQuery-method hide()140 *141 * @see jQuery().hide()142 * @return void143 */144 CreateLayer.prototype.hide = function() {145 this.get('layer').hide();146 this.visible = false;147 };148 /**149 * The "get"-method returns the value of the given key. First it searches in the150 * config for the property. If there is no property with the given name in the151 * "config"-object it returns the entry associated with in the parameters-object152 *153 * @param property154 * @return void155 */156 CreateLayer.prototype.get = function(property) {157 // return param from the config158 if (this.config[property]) {159 return this.config[property];160 }161 // if config-param was not found return param from the parameters-object162 if (this.parameters[property]) {163 return this.parameters[property];164 }165 return undefined;166 };167 /**168 * The "set"-method takes a key and a value. It checks if there is a key-value169 * pair in the config-object. If so it saves the data in the config-object. If170 * not it saves the data in the parameters-object.171 *172 * @param key173 * the key which should be set174 * @param value175 * the value which should be set for the associated key176 */177 CreateLayer.prototype.set = function (key, value) {178 // if the key already exists in the config-object, set it to the config-object179 if (this.config[key]) {180 this.config[key] = value;181 // otherwise "add" it to the parameters-object182 }else{183 this.parameters[key] = value;184 }185 };186 return CreateLayer;...
setTileLevel.js
Source:setTileLevel.js
...16 map = game.add.tilemap('testLevel');17 map.addTilesetImage('smallSheet', 'tileSheet');18 19 /* Setting up layers*/20 testDeco = map.createLayer('Decorations');21 testLevel = map.createLayer('Map');22 /* Enableing map collision*/23 map.setCollisionByExclusion([1] ,true ,testLevel);24 collisionLayer = testLevel;25 /* Adding zombie group*/26 zombies = game.add.group();27 /* Spawning 3 zombies, starting at 350px into the map, in steps of 50px*/28 zombieConfig(3, game.world.left + 350, game.world.top + 250, 50);29 /* Debug option*/30 //testLevel.debug = true;31}32function createTestLevel2() {33 /* Settin up gloabal gravity for thetestLevel*/34 game.physics.arcade.gravity.y = 200;35 /* Setting background Color fortestLevel*/36 background = game.add.image(0,0, 'bg3');37 background.scale.setTo(2, 2);38 /* Specifying the mapdata for the currenttestLevel & linking the correct image*/39 map = game.add.tilemap('testLevel2');40 map.addTilesetImage('smallSheet', 'tileSheet');41 42 /* Setting up layers*/43 testDeco = map.createLayer('decorations');44 testLevel = map.createLayer('map');45 testDeco2 = map.createLayer('decorations2');46 /* Enableing map collision*/47 map.setCollisionByExclusion([1] ,true ,testLevel);48 collisionLayer = testLevel;49 /* Adding zombie group*/50 zombies = game.add.group();51 /* Spawning 2 zombies on each plato*/52 zombieConfig(2, game.world.left + 100, game.world.top + 100, 50);53 zombieConfig(2, game.width - 200, game.world.top + 100, 50);54 /* Debug option*/55 //testLevel.debug = true;56}57function createTestLevel3() {58 /* Settin up gloabal gravity for thetestLevel*/59 game.physics.arcade.gravity.y = 200;60 /* Setting background Color fortestLevel*/61 background = game.add.image(0,0, 'bg3');62 background.scale.setTo(2, 2);63 /* Specifying the mapdata for the currenttestLevel & linking the correct image*/64 map = game.add.tilemap('testLevel3');65 map.addTilesetImage('smallSheet', 'tileSheet');66 67 /* Setting up layers*/68 testDeco1 = map.createLayer('botDeco');69 testLevel = map.createLayer('map');70 testDeco2 = map.createLayer('topDeco');71 spikeLayer = map.createLayer('spikes');72 /* Enableing map collision*/73 map.setCollisionByExclusion([531] ,true ,testLevel);74 map.setCollisionByExclusion([531] ,true ,spikeLayer);75 /*Defining gloabal collision layers*/76 collisionLayer = testLevel;77 spikes = spikeLayer;78 /* Adding zombie group*/79 zombies = game.add.group();80 /* Spawning 2 zombies on each plato*/81 zombieConfig(2, game.world.left + 100, game.world.top + 100, 50);82 zombieConfig(2, game.width - 200, game.world.top + 100, 50);83 /* Debug option*/84 //spikeLayer.debug = true;85 //testLevel.debug = true;86}87function createHighScoreLevel() {88 /* Settin up gloabal gravity for thetestLevel*/89 game.physics.arcade.gravity.y = 200;90 /* Setting background Color fortestLevel*/91 background = game.add.image(0,0, 'bg3');92 background.scale.setTo(2, 2);93 /* Specifying the mapdata for the currenttestLevel & linking the correct image*/94 map = game.add.tilemap('testLevel3');95 map.addTilesetImage('smallSheet', 'tileSheet');96 97 /* Setting up layers*/98 testDeco1 = map.createLayer('botDeco');99 testLevel = map.createLayer('map');100 testDeco2 = map.createLayer('topDeco');101 spikeLayer = map.createLayer('spikes');102 /* Enableing map collision*/103 map.setCollisionByExclusion([531] ,true ,testLevel);104 map.setCollisionByExclusion([531] ,true ,spikeLayer);105 /*Defining gloabal collision layers*/106 collisionLayer = testLevel;107 spikes = spikeLayer;108 /* Adding zombie group*/109 zombies = game.add.group();110 /* Spawning 2 zombies on each plato*/111 zombieConfig(2, game.world.left + 100, game.world.top + 100, 50);112 zombieConfig(2, game.width - 200, game.world.top + 100, 50);113 /* Debug option*/114 //spikeLayer.debug = true;115 //testLevel.debug = true;...
resolve_text.test.js
Source:resolve_text.test.js
1'use strict';2const test = require('mapbox-gl-js-test').test;3const StyleLayer = require('../../../src/style/style_layer');4const resolveText = require('../../../src/symbol/resolve_text');5function createLayer(layout) {6 return new StyleLayer({7 id: 'my-layer',8 type: 'symbol',9 layout: layout10 });11}12test('resolveText', (t) => {13 // Basic.14 t.deepEqual(15 resolveText(createLayer({'text-field': '{name}'}), { zoom: 0 }, {name: 'Test'}),16 'Test');17 t.deepEqual(18 resolveText(createLayer({'text-field': '{name}-suffix'}), { zoom: 0 }, {name: 'Test'}),19 'Test-suffix');20 // Undefined property.21 t.deepEqual(22 resolveText(createLayer({'text-field': '{name}'}), { zoom: 0 }, {}), undefined);23 t.deepEqual(24 resolveText(createLayer({'text-field': '{name}-suffix'}), { zoom: 0 }, {}), '-suffix');25 // Non-latin.26 t.deepEqual(27 resolveText(createLayer({'text-field': '{city}'}), { zoom: 0 }, {city: 'ìì¸í¹ë³ì'}),28 'ìì¸í¹ë³ì');29 // Unicode up to 65535.30 t.deepEqual(31 resolveText(createLayer({'text-field': '{text}'}), { zoom: 0 }, {text: '\ufff0'}),32 '\ufff0');33 t.deepEqual(34 resolveText(createLayer({'text-field': '{text}'}), { zoom: 0 }, {text: '\uffff'}),35 '\uffff');36 // Non-string values cast to strings.37 t.deepEqual(38 resolveText(createLayer({'text-field': '{name}'}), { zoom: 0 }, {name: 5000}),39 '5000');40 t.deepEqual(41 resolveText(createLayer({'text-field': '{name}'}), { zoom: 0 }, {name: -15.5}),42 '-15.5');43 t.deepEqual(44 resolveText(createLayer({'text-field': '{name}'}), { zoom: 0 }, {name: true}),45 'true');46 // Non-string values cast to strings, with token replacement.47 t.deepEqual(48 resolveText(createLayer({'text-field': '{name}-suffix'}), { zoom: 0 }, {name: 5000}),49 '5000-suffix');50 t.deepEqual(51 resolveText(createLayer({'text-field': '{name}-suffix'}), { zoom: 0 }, {name: -15.5}),52 '-15.5-suffix');53 t.deepEqual(54 resolveText(createLayer({'text-field': '{name}-suffix'}), { zoom: 0 }, {name: true}),55 'true-suffix');56 t.end();...
CreateLayer.js
Source:CreateLayer.js
1define([2 "../object"3], function(object){4 // Modes - CreateLayer5 var CreateLayer = function(){6 var pad = false;7 return object.Mode({8 name: "CreateLayer",9 thisIndex: 1,10 regisPad: function( padObject ){11 if( pad === false ){12 pad = padObject;13 }14 },15 play: function( data, callback ){16 if( !this.dataCheck( data ) ){17 return false;18 }19 pad.layer.create();20 this.eventSave();21 if(callback){ 22 callback( this );23 }24 },25 // EventTrigger - needs to defines.26 eventTrigger: function(){},27 eventSave: function(){28 var data = {};29 data[this.defines.drawType] = this.thisIndex;30 data[this.defines.time] = pad.history.getTimeStep(),31 32 // count Time and Event33 pad.history.countTime();34 pad.history.countEvent();35 36 // add Event37 pad.history.addEvent( data );38 39 // add History40 pad.history.addHistory({41 data: {42 layer: pad.layer.getLayer()43 },44 undo: function( history, callback ){45 pad.layer.remove( this.data.layer );46 if( typeof callback === "function" ){47 callback();48 }49 },50 redo: function( history, callback ){51 pad.layer.create();52 if( typeof callback === "function" ){53 callback();54 } 55 }56 });57 }58 });59 };60 61 CreateLayer = CreateLayer();62 63 return CreateLayer;...
Using AI Code Generation
1Cypress.Commands.add('createLayer', (layerName) => {2 cy.get('[data-cy="layers"]').click();3 cy.get('[data-cy="add-layer"]').click();4 cy.get('[data-cy="layer-name-input"]').type(layerName);5 cy.get('[data-cy="layer-type-dropdown"]').click();6 cy.get('[data-cy="layer-type-option"]').contains('GeoJSON').click();7 cy.get('[data-cy="layer-data-input"]').type(8 );9 cy.get('[data-cy="layer-submit"]').click();10});11Cypress.Commands.add('createLayer', (layerName) => {12 cy.get('[data-cy="layers"]').click();13 cy.get('[data-cy="add-layer"]').click();14 cy.get('[data-cy="layer-name-input"]').type(layerName);15 cy.get('[data-cy="layer-type-dropdown"]').click();16 cy.get('[data-cy="layer-type-option"]').contains('GeoJSON').click();17 cy.get('[data-cy="layer-data-input"]').type(18 );19 cy.get('[data-cy="layer-submit"]').click();20});21Cypress.Commands.add('createLayer', (layerName) => {22 cy.get('[data-cy="layers"]').click();23 cy.get('[data-cy="add-layer"]').click();24 cy.get('[data-cy="layer-name-input"]').type(layerName);25 cy.get('[data-cy="layer-type-dropdown"]').click();26 cy.get('[data-cy="layer-type-option"]').contains('GeoJSON').click();27 cy.get('[data-cy="layer-data-input"]').type(28 );29 cy.get('[data-cy="layer-submit"]').click();30});
Using AI Code Generation
1Cypress.Commands.add('createLayer', (layerName) => {2 cy.get('.leaflet-draw-draw-marker').click()3 cy.get('.leaflet-draw-toolbar-top').should('be.visible')4 cy.get('.leaflet-draw-toolbar-top').within(() => {5 cy.get('input').type(layerName)6 cy.get('button').contains('Create').click()7 })8 cy.get('.leaflet-draw-toolbar-top').should('not.be.visible')9})10Cypress.Commands.add('createLayer', (layerName) => {11 cy.get('.leaflet-draw-draw-marker').click()12 cy.get('.leaflet-draw-toolbar-top').should('be.visible')13 cy.get('.leaflet-draw-toolbar-top').within(() => {14 cy.get('input').type(layerName)15 cy.get('button').contains('Create').click()16 })17 cy.get('.leaflet-draw-toolbar-top').should('not.be.visible')18})19Cypress.Commands.add('createLayer', (layerName) => {20 cy.get('.leaflet-draw-draw-marker').click()21 cy.get('.leaflet-draw-toolbar-top').should('be.visible')22 cy.get('.leaflet-draw-toolbar-top').within(() => {23 cy.get('input').type(layerName)24 cy.get('button').contains('Create').click()25 })26 cy.get('.leaflet-draw-toolbar-top').should('not.be.visible')27})28Cypress.Commands.add('createLayer', (layerName) => {29 cy.get('.leaflet-draw-draw-marker').click()30 cy.get('.leaflet-draw-toolbar-top').should('be.visible')31 cy.get('.leaflet-draw-toolbar-top').within(() => {32 cy.get('input').type(layerName)33 cy.get('button').contains('Create').click()34 })35 cy.get('.leaflet-draw-toolbar-top').should('not.be.visible')36})37Cypress.Commands.add('createLayer', (layerName)
Using AI Code Generation
1Cypress.Commands.add('createLayer', (layerName) => {2 cy.get('#add-layer-button').click();3 cy.get('#layer-name-input').type(layerName);4 cy.get('#add-layer-submit').click();5});6Cypress.Commands.add('deleteLayer', (layerName) => {7 cy.get(`#delete-${layerName}`).click();8 cy.get('#confirm-delete-button').click();9});10[MIT](
Using AI Code Generation
1Cypress.Commands.add('createLayer', (layerName) => {2 cy.get('.layers-list__add-layer-btn').click();3 cy.get('.add-layer-modal__name-input').type(layerName);4 cy.get('.add-layer-modal__add-btn').click();5});6describe('test', () => {7 it('test', () => {8 cy.createLayer('test');9 });10});11describe('test', () => {12 it('test', () => {13 cy.createLayer('test');14 cy.createLayer('test2');15 });16});17describe('test', () => {18 it('test', () => {19 cy.createLayer('test');20 cy.createLayer('test2');21 cy.createLayer('test3');22 });23});24describe('test', () => {25 it('test', () => {26 cy.createLayer('test');27 cy.createLayer('test2');28 cy.createLayer('test3');29 cy.createLayer('test4');30 });31});32describe('test', () => {33 it('test', () => {34 cy.createLayer('test');35 cy.createLayer('test2');36 cy.createLayer('test3');37 cy.createLayer('test4');38 cy.createLayer('test5');39 });40});41describe('test', () => {42 it('test', () => {43 cy.createLayer('test');44 cy.createLayer('test2');45 cy.createLayer('test3');46 cy.createLayer('test4');47 cy.createLayer('test5');48 cy.createLayer('test6');49 });50});51describe('test', () => {52 it('test', () => {53 cy.createLayer('test');54 cy.createLayer('test2');55 cy.createLayer('test3');56 cy.createLayer('test4');57 cy.createLayer('test5');58 cy.createLayer('test6');
Using AI Code Generation
1const createLayer = (layerType, layerName) => {2 cy.get('button[title="Layers"]').click();3 cy.get(`button[title="${layerType}"]`).click();4 cy.get(`button[title="${layerName}"]`).click();5 cy.get('button[title="Close"]').click();6};7const createLayer = (layerType, layerName) => {8 cy.get('button[title="Layers"]').click();9 cy.get(`button[title="${layerType}"]`).click();10 cy.get(`button[title="${layerName}"]`).click();11 cy.get('button[title="Close"]').click();12};13const createLayer = (layerType, layerName) => {14 cy.get('button[title="Layers"]').click();15 cy.get(`button[title="${layerType}"]`).click();16 cy.get(`button[title="${layerName}"]`).click();17 cy.get('button[title="Close"]').click();18};19const createLayer = (layerType, layerName) => {20 cy.get('button[title="Layers"]').click();21 cy.get(`button[title="${layerType}"]`).click();22 cy.get(`button[title="${layerName}"]`).click();
Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.
You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.
Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.
Get 100 minutes of automation test minutes FREE!!