Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

leaflet-headless

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leaflet-headless - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

test/accept-actual.sh

39

index.js

@@ -8,20 +8,26 @@ /**

var jsdom = require('jsdom').jsdom;
var path = require('path');
if (!GLOBAL.L) {
if (!global.L) {
// make some globals to fake browser behaviour.
GLOBAL.document = jsdom('<html><head></head><body></body></html>');
GLOBAL.window = GLOBAL.document.defaultView;
GLOBAL.window.navigator.userAgent = 'webkit';
GLOBAL.navigator = GLOBAL.window.navigator;
GLOBAL.Image = require('./src/image.js');
global.document = jsdom('<html><head></head><body></body></html>', {
features: {
FetchExternalResources: ['img']
}
});
global.window = global.document.defaultView;
global.window.navigator.userAgent = 'webkit';
global.navigator = global.window.navigator;
global.Image = require('./src/image.js');
GLOBAL.L_DISABLE_3D = true;
GLOBAL.L_PREFER_CANVAS = true;
global.L_DISABLE_3D = true;
global.L_PREFER_CANVAS = true;
global.L_NO_TOUCH = true;
var leafletPath = require.resolve('leaflet');
var L = require(leafletPath);
GLOBAL.L = L;
global.L = L;
var scriptLength = leafletPath.split('/').slice(-1)[0].length;
L.Icon.Default.imagePath = leafletPath.substring(0, leafletPath.length - scriptLength) + 'images';
var scriptLength = leafletPath.split(path.sep).slice(-1)[0].length;
L.Icon.Default.imagePath = 'file://' + leafletPath.substring(0, leafletPath.length - scriptLength) + 'images/';

@@ -36,3 +42,4 @@ // Monkey patch Leaflet

zoomAnimation: false,
markerZoomAnimation: false
markerZoomAnimation: false,
preferCanvas: true
});

@@ -63,2 +70,3 @@

var fs = require('fs');
leafletImage(this, function (err, canvas) {

@@ -84,9 +92,4 @@ if (err) {

});
// leaflet-image checks for instanceof(layer, L.TileLayer.Canvas)
// which is not in leaflet-1.0.0-beta.*, this makes the tests work.
// TODO: remove if this is fixed upstream in leaflet-image
L.TileLayer.Canvas = function () {};
}
module.exports = GLOBAL.L;
module.exports = global.L;
{
"name": "leaflet-headless",
"version": "0.1.2",
"version": "0.2.0",
"description": "Leaflet for node.",

@@ -24,3 +24,3 @@ "main": "index.js",

"leaflet": "^1.0.0-rc.1",
"leaflet-image": "~0.1.0",
"leaflet-image": "^0.4.0",
"request": "^2.65.0"

@@ -27,0 +27,0 @@ },

@@ -13,2 +13,9 @@ /*

function stripQuerystring (url) {
if (url.indexOf('?') !== -1) {
url = url.substr(0, url.indexOf('?'));
}
return url;
}
var Image = function Image () {};

@@ -41,6 +48,6 @@ Image.prototype.__defineSetter__('src', function (src) {

src = src.substr(7);
// and query string
if (src.indexOf('?') !== -1) {
src = src.substr(0, src.indexOf('?'));
}
default: // fallthrough
src = stripQuerystring(src);
fs.exists(src, function (exists) {

@@ -61,4 +68,3 @@ if (!exists) {

break;
default:
console.error('Image not implemented for url: ' + src);
// console.error('Image not implemented for url: ' + src);
}

@@ -65,0 +71,0 @@ });

@@ -79,9 +79,2 @@ 'use strict';

it('has working imagePath', function () {
var path = L.Icon.Default.imagePath + '/';
fs.existsSync(path + 'layers.png').should.be.true;
fs.existsSync(path + 'marker-icon.png').should.be.true;
});
it('has a working saveImage() method', function (done) {

@@ -100,3 +93,3 @@ map.setView([10, 10], 3).setSize(200, 200);

var outfilename = path.join(__dirname, 'test-saveimage.png');
var outfilename = path.join(__dirname, 'actual', 'test-saveimage.png');
var expected = path.join(__dirname, 'expected', 'test-saveimage.png');

@@ -159,3 +152,3 @@

it('runs, wrote an image, equal to what we expected', function (done) {
var filename = path.join(__dirname, 'example-' + example + '.png');
var filename = path.join(__dirname, 'actual', 'example-' + example + '.png');
var expected = path.join(__dirname, 'expected', 'example-' + example + '.png');

@@ -162,0 +155,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc