chai-leaflet
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -36,4 +36,5 @@ /** | ||
var i; | ||
if (Array.isArray(actual)) { | ||
for (var i = 0; i < actual.length; i++) { | ||
for (i = 0; i < actual.length; i++) { | ||
if (!deepAlmostEqual(actual[i], expected[i], delta)) { | ||
@@ -44,5 +45,5 @@ return false; | ||
} else if (typeof actual === 'object') { | ||
for (var i in actual) { | ||
for (i in actual) { | ||
if (typeof actual[i] === 'function') { | ||
continue; | ||
continue; | ||
} | ||
@@ -72,9 +73,10 @@ if (!deepAlmostEqual(actual[i], expected[i], delta)) { | ||
/* jshint validthis:true */ | ||
new Assertion( | ||
this._obj, | ||
'expected #{act} to be a L.LatLng object' | ||
).to.be.an.instanceof(L.LatLng); | ||
var actual = this._obj; | ||
// TODO fix this for negating | ||
// this.assert( | ||
// actual instanceof L.LatLng, | ||
// 'expected #{act} to be a L.LatLng object' | ||
// ); | ||
var expected = L.latLng(expected); | ||
expected = L.latLng(expected); | ||
@@ -93,2 +95,12 @@ this.assert( | ||
Assertion.addMethod('zoom', function (zoom) { | ||
new Assertion( | ||
this._obj, | ||
'expected #{act} to be a L.Map' | ||
).to.be.an.instanceof(L.Map); | ||
new Assertion( | ||
zoom, | ||
'expect zoom to be a number' | ||
).to.be.a('number'); | ||
var actual = this._obj.getZoom(); | ||
@@ -106,2 +118,7 @@ | ||
Assertion.addMethod('view', function (center, zoom, delta) { | ||
new Assertion( | ||
this._obj, | ||
'expected #{act} to be a L.Map' | ||
).to.be.an.instanceof(L.Map); | ||
var map = this._obj; | ||
@@ -108,0 +125,0 @@ |
{ | ||
"name": "chai-leaflet", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Chai assertions to use with Leaflet map apps", | ||
@@ -5,0 +5,0 @@ "main": "chai-leaflet.js", |
@@ -43,45 +43,65 @@ 'use strict'; | ||
describe('nearLatLng', function () { | ||
it('works', function () { | ||
var latlng = L.latLng(51, 4); | ||
describe('should.be.', function () { | ||
describe('near', function () { | ||
it('works', function () { | ||
var latlng = L.latLng(51, 4); | ||
latlng.should.be.near(latlng); | ||
latlng.should.be.near([51, 4]); | ||
}); | ||
latlng.should.be.near(latlng); | ||
latlng.should.be.near([51, 4]); | ||
}); | ||
it('negating works', function () { | ||
var latlng = L.latLng(51, 4); | ||
latlng.should.not.be.near(L.latLng([4, 51])); | ||
}); | ||
it('negating works', function () { | ||
var latlng = L.latLng(51, 4); | ||
latlng.should.not.be.near(L.latLng([4, 51])); | ||
}); | ||
it('with bigger delta', function () { | ||
var latlng = L.latLng(51.0001, 4.0009); | ||
it('with bigger delta', function () { | ||
var latlng = L.latLng(51.0001, 4.0009); | ||
var delta = 0.1; | ||
var delta = 0.1; | ||
latlng.should.be.near(L.latLng(51.01, 4.01), delta); | ||
latlng.should.not.be.near(L.latLng(51.4, 4.4), delta); | ||
latlng.should.be.near(L.latLng(51.01, 4.01), delta); | ||
latlng.should.not.be.near(L.latLng(51.4, 4.4), delta); | ||
}); | ||
}); | ||
}); | ||
describe('should.have.zoom', function () { | ||
it('checks zoom correctly', function () { | ||
var map = L.map(document.createElement('div')); | ||
describe('should.have.', function () { | ||
describe('zoom', function () { | ||
it('fails for non-map objects', function () { | ||
var fn = function () { | ||
L.latLng([1, 2]).should.have.zoom([1, 2]); | ||
}; | ||
map.setView([1, 2], 3); | ||
fn.should.throw; | ||
}); | ||
map.should.have.zoom(3); | ||
map.should.not.have.zoom(4); | ||
it('checks zoom correctly', function () { | ||
var map = L.map(document.createElement('div')); | ||
map.setView([1, 2], 3); | ||
map.should.have.zoom(3); | ||
map.should.not.have.zoom(4); | ||
}); | ||
}); | ||
}); | ||
describe('should.have.view', function () { | ||
it('checks view correctly', function () { | ||
var map = L.map(document.createElement('div')); | ||
describe('view', function () { | ||
it('fails for non-map objects', function () { | ||
var fn = function () { | ||
L.latLng([1, 2]).should.have.view([1, 2]); | ||
}; | ||
map.setView([1, 2], 3); | ||
fn.should.throw; | ||
}); | ||
map.should.have.view([1, 2], 3); | ||
it('checks view correctly', function () { | ||
var map = L.map(document.createElement('div')); | ||
map.setView([1, 2], 3); | ||
map.should.have.view([1, 2], 3); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9214
190