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

chai-leaflet

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-leaflet - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

21

chai-leaflet.js

@@ -31,6 +31,8 @@ /**

function deepAlmostEqual(actual, expected, delta) {
function deepAlmostEqual(actual, expected, delta, error) {
if (delta === undefined) {
throw new Error('No delta provided');
}
error = error || {};
error.message = '';

@@ -41,2 +43,7 @@ var i;

if (!deepAlmostEqual(actual[i], expected[i], delta)) {
error.message = ' at index ' + i;
if (Array.isArray(actual[i]) || typeof actual[i] === 'object') {
error.message += ': ' + actual[i] + ' should be almost equal to ' + expected[i];
}
return false;

@@ -51,2 +58,7 @@ }

if (!deepAlmostEqual(actual[i], expected[i], delta)) {
error.message = ' at key ' + i;
if (Array.isArray(actual[i]) || typeof actual[i] === 'object') {
error.message += ': ' + actual[i] + ' should be almost equal to ' + expected[i];
}
return false;

@@ -62,6 +74,7 @@ }

Assertion.addMethod('deepAlmostEqual', function (expected, delta) {
var error = {};
this.assert(
deepAlmostEqual(this._obj, expected, delta),
'expected #{act} to be almost equal to #{exp}',
'expected #{act} to be not almost equal to #{exp}',
deepAlmostEqual(this._obj, expected, delta, error),
'expected #{act} to be almost equal to #{exp}' + error.message,
'expected #{act} to be not almost equal to #{exp}' + error.message,
expected,

@@ -68,0 +81,0 @@ this._obj

2

package.json
{
"name": "chai-leaflet",
"version": "0.0.7",
"version": "0.0.8",
"description": "Chai assertions to use with Leaflet map apps",

@@ -5,0 +5,0 @@ "main": "chai-leaflet.js",

@@ -41,2 +41,46 @@ 'use strict';

describe('error messages', function () {
var error, fn;
beforeEach(function () {
error = '';
fn = null;
});
it('should report the right index', function () {
fn = function () {
[1, 2, 3, 4].should.be.deepAlmostEqual([1, 2, 3, 5], 0.1);
};
fn.should.throw('expected [ 1, 2, 3, 4 ] to be almost equal to [ 1, 2, 3, 5 ] at index 3');
});
it('should display the second level if type is array/object', function () {
fn = function () {
[
[1, 2],
[2, 3]
].should.be.deepAlmostEqual([
[1, 2],
[4, 4]
], 0.1);
};
fn.should.throw('expected [ [ 1, 2 ], [ 2, 3 ] ] to be almost equal to ' +
'[ [ 1, 2 ], [ 4, 4 ] ] at index 1: 2,3 should be almost equal to 4,4');
});
it('should report the key for objects', function () {
fn = function () {
var obj = {
foo: [1, 2],
bar: [1, 2, 3]
};
obj.should.be.deepAlmostEqual({
foo: [1, 2],
bar: [1, 3, 4]
}, 0.1);
};
fn.should.throw('expected { foo: [ 1, 2 ], bar: [ 1, 2, 3 ] } to be almost equal to ' +
'{ foo: [ 1, 2 ], bar: [ 1, 3, 4 ] } at key bar: 1,2,3 should be almost equal to 1,3,4');
});
});
});

@@ -43,0 +87,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