Created
April 24, 2023 09:53
-
-
Save linhx/35a4083ba433765a3ea249608b4b0b2f to your computer and use it in GitHub Desktop.
leaflet-1.5.1-mocks: This file for avoiding the error "Uncaught ReferenceError: L is not defined" when when running your Karma tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // eslint-disable | |
| (function (global, factory) { | |
| typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | |
| typeof define === 'function' && define.amd ? define(['exports'], factory) : | |
| (factory((global.L = {}))); | |
| }(this, (function (exports) { | |
| 'use strict'; | |
| var version = "1.5.1+HEAD.2e3e0ff"; | |
| var freeze = Object.freeze; | |
| Object.freeze = function (obj) { | |
| return obj; | |
| }; | |
| function extend(dest) { | |
| var i, j, len, src; | |
| for (j = 1, len = arguments.length; j < len; j++) { | |
| src = arguments[j]; | |
| for (i in src) { | |
| dest[i] = src[i]; | |
| } | |
| } | |
| return dest; | |
| } | |
| var create = Object.create || (function () { | |
| function F() {} | |
| return function (proto) { | |
| F.prototype = proto; | |
| return new F(); | |
| }; | |
| })(); | |
| function bind(fn, obj) { | |
| var slice = Array.prototype.slice; | |
| if (fn.bind) { | |
| return fn.bind.apply(fn, slice.call(arguments, 1)); | |
| } | |
| var args = slice.call(arguments, 2); | |
| return function () { | |
| return fn.apply(obj, args.length ? args.concat(slice.call(arguments)) : arguments); | |
| }; | |
| } | |
| var lastId = 0; | |
| function stamp(obj) { | |
| obj._leaflet_id = obj._leaflet_id || ++lastId; | |
| return obj._leaflet_id; | |
| } | |
| function setOptions(obj, options) { | |
| if (!obj.hasOwnProperty('options')) { | |
| obj.options = obj.options ? create(obj.options) : {}; | |
| } | |
| for (var i in options) { | |
| obj.options[i] = options[i]; | |
| } | |
| return obj.options; | |
| } | |
| var Util = (Object.freeze || Object)({}); | |
| function Class() {} | |
| Class.extend = function (props) { | |
| var NewClass = function () { | |
| if (this.initialize) { | |
| this.initialize.apply(this, arguments); | |
| } | |
| this.callInitHooks(); | |
| }; | |
| var parentProto = NewClass.__super__ = this.prototype; | |
| var proto = create(parentProto); | |
| proto.constructor = NewClass; | |
| NewClass.prototype = proto; | |
| for (var i in this) { | |
| if (this.hasOwnProperty(i) && i !== 'prototype' && i !== '__super__') { | |
| NewClass[i] = this[i]; | |
| } | |
| } | |
| if (props.statics) { | |
| extend(NewClass, props.statics); | |
| delete props.statics; | |
| } | |
| if (props.includes) { | |
| checkDeprecatedMixinEvents(props.includes); | |
| extend.apply(null, [proto].concat(props.includes)); | |
| delete props.includes; | |
| } | |
| if (proto.options) { | |
| props.options = extend(create(proto.options), props.options); | |
| } | |
| extend(proto, props); | |
| proto._initHooks = []; | |
| proto.callInitHooks = function () { | |
| if (this._initHooksCalled) { | |
| return; | |
| } | |
| if (parentProto.callInitHooks) { | |
| parentProto.callInitHooks.call(this); | |
| } | |
| this._initHooksCalled = true; | |
| for (var i = 0, len = proto._initHooks.length; i < len; i++) { | |
| proto._initHooks[i].call(this); | |
| } | |
| }; | |
| return NewClass; | |
| }; | |
| Class.include = function (props) { | |
| extend(this.prototype, props); | |
| return this; | |
| }; | |
| Class.mergeOptions = function (options) { | |
| extend(this.prototype.options, options); | |
| return this; | |
| }; | |
| Class.addInitHook = function (fn) { | |
| var args = Array.prototype.slice.call(arguments, 1); | |
| var init = typeof fn === 'function' ? fn : function () { | |
| this[fn].apply(this, args); | |
| }; | |
| this.prototype._initHooks = this.prototype._initHooks || []; | |
| this.prototype._initHooks.push(init); | |
| return this; | |
| }; | |
| function checkDeprecatedMixinEvents(includes) {} | |
| var Events = {}; | |
| var Evented = Class.extend(Events); | |
| function Point(x, y, round) {} | |
| function toPoint(x, y, round) { | |
| return new Point(x, y, round); | |
| } | |
| function Bounds(a, b) {} | |
| function toBounds(a, b) { | |
| return new Bounds(a, b); | |
| } | |
| function LatLngBounds(corner1, corner2) {} | |
| function toLatLngBounds(a, b) { | |
| return new LatLngBounds(a, b); | |
| } | |
| function LatLng(lat, lng, alt) {} | |
| function toLatLng(a, b, c) { | |
| return new LatLng(a, b, c); | |
| } | |
| var CRS = {}; | |
| function Transformation(a, b, c, d) {} | |
| function toTransformation(a, b, c, d) { | |
| return new Transformation(a, b, c, d); | |
| } | |
| function svgCreate(name) { | |
| return document.createElementNS('http://www.w3.org/2000/svg', name); | |
| } | |
| var canvas = (function () { | |
| return !!document.createElement('canvas').getContext; | |
| }()); | |
| var svg = !!(document.createElementNS && svgCreate('svg').createSVGRect); | |
| var vml = !svg && (function () { | |
| return false; | |
| }()); | |
| var Browser = (Object.freeze || Object)({}); | |
| var DomUtil = (Object.freeze || Object)({}); | |
| var DomEvent = (Object.freeze || Object)({}); | |
| var PosAnimation = Evented.extend({}); | |
| var Map = Evented.extend({}); | |
| function createMap(id, options) { | |
| return new Map(id, options); | |
| } | |
| var Control = Class.extend({}); | |
| var control = function (options) { | |
| return new Control(options); | |
| }; | |
| Map.include({}); | |
| var Handler = Class.extend({}); | |
| Handler.addTo = function () { | |
| return this; | |
| }; | |
| var Mixin = { | |
| Events: Events | |
| }; | |
| var Draggable = Evented.extend({}); | |
| var LineUtil = (Object.freeze || Object)({}); | |
| var PolyUtil = (Object.freeze || Object)({}); | |
| var index = (Object.freeze || Object)({}); | |
| var Layer = Evented.extend({}); | |
| var LayerGroup = Layer.extend({}); | |
| var layerGroup = function (layers, options) { | |
| return new LayerGroup(layers, options); | |
| }; | |
| var FeatureGroup = LayerGroup.extend({}); | |
| var featureGroup = function (layers) { | |
| return new FeatureGroup(layers); | |
| }; | |
| var Icon = Class.extend({}); | |
| function icon(options) { | |
| return new Icon(options); | |
| } | |
| var IconDefault = Icon.extend({}); | |
| var Marker = Layer.extend({}); | |
| function marker(latlng, options) { | |
| return new Marker(latlng, options); | |
| } | |
| var Path = Layer.extend({}); | |
| var CircleMarker = Path.extend({}); | |
| function circleMarker(latlng, options) { | |
| return new CircleMarker(latlng, options); | |
| } | |
| var Circle = CircleMarker.extend({}); | |
| function circle(latlng, options, legacyOptions) { | |
| return new Circle(latlng, options, legacyOptions); | |
| } | |
| var Polyline = Path.extend({}); | |
| function polyline(latlngs, options) { | |
| return new Polyline(latlngs, options); | |
| } | |
| var Polygon = Polyline.extend({}); | |
| function polygon(latlngs, options) { | |
| return new Polygon(latlngs, options); | |
| } | |
| var GeoJSON = FeatureGroup.extend({}); | |
| function geoJSON(geojson, options) { | |
| return new GeoJSON(geojson, options); | |
| } | |
| var geoJson = geoJSON; | |
| var ImageOverlay = Layer.extend({}); | |
| var imageOverlay = function (url, bounds, options) { | |
| return new ImageOverlay(url, bounds, options); | |
| }; | |
| var VideoOverlay = ImageOverlay.extend({}); | |
| function videoOverlay(video, bounds, options) { | |
| return new VideoOverlay(video, bounds, options); | |
| } | |
| var SVGOverlay = ImageOverlay.extend({}); | |
| function svgOverlay(el, bounds, options) { | |
| return new SVGOverlay(el, bounds, options); | |
| } | |
| var DivOverlay = Layer.extend({}); | |
| var Popup = DivOverlay.extend({}); | |
| var popup = function (options, source) { | |
| return new Popup(options, source); | |
| }; | |
| var Tooltip = DivOverlay.extend({}); | |
| var tooltip = function (options, source) { | |
| return new Tooltip(options, source); | |
| }; | |
| var DivIcon = Icon.extend({}); | |
| function divIcon(options) { | |
| return new DivIcon(options); | |
| } | |
| Icon.Default = IconDefault; | |
| var GridLayer = Layer.extend({}); | |
| function gridLayer(options) { | |
| return new GridLayer(options); | |
| } | |
| var TileLayer = GridLayer.extend({}); | |
| function tileLayer(url, options) { | |
| return new TileLayer(url, options); | |
| } | |
| var Renderer = Layer.extend({}); | |
| var Canvas = Renderer.extend({}); | |
| function canvas$1(options) { | |
| return canvas ? new Canvas(options) : null; | |
| } | |
| var SVG = Renderer.extend({}); | |
| function svg$1(options) { | |
| return svg || vml ? new SVG(options) : null; | |
| } | |
| var Rectangle = Polygon.extend({}); | |
| function rectangle(latLngBounds, options) { | |
| return new Rectangle(latLngBounds, options); | |
| } | |
| Object.freeze = freeze; | |
| exports.version = version; | |
| exports.Control = Control; | |
| exports.control = control; | |
| exports.Browser = Browser; | |
| exports.Evented = Evented; | |
| exports.Mixin = Mixin; | |
| exports.Util = Util; | |
| exports.Class = Class; | |
| exports.Handler = Handler; | |
| exports.extend = extend; | |
| exports.bind = bind; | |
| exports.stamp = stamp; | |
| exports.setOptions = setOptions; | |
| exports.DomEvent = DomEvent; | |
| exports.DomUtil = DomUtil; | |
| exports.PosAnimation = PosAnimation; | |
| exports.Draggable = Draggable; | |
| exports.LineUtil = LineUtil; | |
| exports.PolyUtil = PolyUtil; | |
| exports.Point = Point; | |
| exports.point = toPoint; | |
| exports.Bounds = Bounds; | |
| exports.bounds = toBounds; | |
| exports.Transformation = Transformation; | |
| exports.transformation = toTransformation; | |
| exports.Projection = index; | |
| exports.LatLng = LatLng; | |
| exports.latLng = toLatLng; | |
| exports.LatLngBounds = LatLngBounds; | |
| exports.latLngBounds = toLatLngBounds; | |
| exports.CRS = CRS; | |
| exports.GeoJSON = GeoJSON; | |
| exports.geoJSON = geoJSON; | |
| exports.geoJson = geoJson; | |
| exports.Layer = Layer; | |
| exports.LayerGroup = LayerGroup; | |
| exports.layerGroup = layerGroup; | |
| exports.FeatureGroup = FeatureGroup; | |
| exports.featureGroup = featureGroup; | |
| exports.ImageOverlay = ImageOverlay; | |
| exports.imageOverlay = imageOverlay; | |
| exports.VideoOverlay = VideoOverlay; | |
| exports.videoOverlay = videoOverlay; | |
| exports.SVGOverlay = SVGOverlay; | |
| exports.svgOverlay = svgOverlay; | |
| exports.DivOverlay = DivOverlay; | |
| exports.Popup = Popup; | |
| exports.popup = popup; | |
| exports.Tooltip = Tooltip; | |
| exports.tooltip = tooltip; | |
| exports.Icon = Icon; | |
| exports.icon = icon; | |
| exports.DivIcon = DivIcon; | |
| exports.divIcon = divIcon; | |
| exports.Marker = Marker; | |
| exports.marker = marker; | |
| exports.TileLayer = TileLayer; | |
| exports.tileLayer = tileLayer; | |
| exports.GridLayer = GridLayer; | |
| exports.gridLayer = gridLayer; | |
| exports.SVG = SVG; | |
| exports.svg = svg$1; | |
| exports.Renderer = Renderer; | |
| exports.Canvas = Canvas; | |
| exports.canvas = canvas$1; | |
| exports.Path = Path; | |
| exports.CircleMarker = CircleMarker; | |
| exports.circleMarker = circleMarker; | |
| exports.Circle = Circle; | |
| exports.circle = circle; | |
| exports.Polyline = Polyline; | |
| exports.polyline = polyline; | |
| exports.Polygon = Polygon; | |
| exports.polygon = polygon; | |
| exports.Rectangle = Rectangle; | |
| exports.rectangle = rectangle; | |
| exports.Map = Map; | |
| exports.map = createMap; | |
| var oldL = window.L; | |
| exports.noConflict = function () { | |
| window.L = oldL; | |
| return this; | |
| } | |
| window.L = exports; | |
| }))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment