"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "spec/suites/geometry/LineUtilSpec.js" between
Leaflet-1.8.0.tar.gz and Leaflet-1.9.0.tar.gz

About: Leaflet is a JavaScript library for mobile-friendly interactive maps.

LineUtilSpec.js  (Leaflet-1.8.0):LineUtilSpec.js  (Leaflet-1.9.0)
skipping to change at line 116 skipping to change at line 116
}); });
it('should be aliased as _flat for retrocompat', function () { it('should be aliased as _flat for retrocompat', function () {
expect(L.LineUtil._flat([L.latLng([0, 0])])).to.be(true); expect(L.LineUtil._flat([L.latLng([0, 0])])).to.be(true);
}); });
it('should be aliased as L.Polyline._flat for retrocompat', funct ion () { it('should be aliased as L.Polyline._flat for retrocompat', funct ion () {
expect(L.Polyline._flat([L.latLng([0, 0])])).to.be(true); expect(L.Polyline._flat([L.latLng([0, 0])])).to.be(true);
}); });
}); });
describe('#polylineCenter', function () {
var map, crs, zoom;
beforeEach(function () {
map = L.map(document.createElement('div'), {center: [55.8
, 37.6], zoom: 6});
crs = map.options.crs;
zoom = map.getZoom();
});
afterEach(function () {
map.remove();
});
// More tests in PolylineSpec
it('computes center of line', function () {
var latlngs = [[80, 0], [80, 90]];
var center = L.LineUtil.polylineCenter(latlngs, crs, zoom
);
expect(center).to.be.nearLatLng([80, 45]);
});
it('computes center of line with maxZoom', function () {
L.gridLayer({maxZoom: 18}).addTo(map);
var latlngs = [[80, 0], [80, 90]];
var center = L.LineUtil.polylineCenter(latlngs, crs, map.
getMaxZoom());
expect(center).to.be.nearLatLng([80, 45]);
});
it('computes center of a small line and test it on every zoom', f
unction () {
var latlngs = [[50.49898323576035, 30.509834789772036], [
50.49998323576035, 30.509834789772036], [50.49998323576035, 30.509939789772037],
[50.49898323576035, 30.509939789772037]];
var layer = L.polyline(latlngs).addTo(map);
var i = 0;
function check() {
expect(layer.getCenter()).to.be.nearLatLng([50.49
998323576035, 30.50989603626345]);
i++;
if (i < 30) { map.setZoom(i); }
}
map.on('zoomend', check);
map.setView(layer.getCenter(), i);
});
it('computes center of a small line and test it on every zoom - C
RS.EPSG3395', function () {
map.remove();
map = L.map(document.createElement('div'), {center: [55.8
, 37.6], zoom: 6, crs: L.CRS.EPSG3395});
var latlngs = [[50.49898323576035, 30.509834789772036], [
50.49998323576035, 30.509834789772036], [50.49998323576035, 30.509939789772037],
[50.49898323576035, 30.509939789772037]];
var layer = L.polyline(latlngs).addTo(map);
var i = 0;
function check() {
expect(layer.getCenter()).to.be.nearLatLng([50.49
998323576035, 30.50989603626345]);
i++;
if (i < 30) { map.setZoom(i); }
}
map.on('zoomend', check);
map.setView(layer.getCenter(), i);
});
it('computes center of a small line and test it on every zoom - C
RS.EPSG4326', function () {
map.remove();
map = L.map(document.createElement('div'), {center: [55.8
, 37.6], zoom: 6, crs: L.CRS.EPSG4326});
var latlngs = [[50.49898323576035, 30.509834789772036], [
50.49998323576035, 30.509834789772036], [50.49998323576035, 30.509939789772037],
[50.49898323576035, 30.509939789772037]];
var layer = L.polyline(latlngs).addTo(map);
var i = 0;
function check() {
expect(layer.getCenter()).to.be.nearLatLng([50.49
998323576035, 30.50989603626345]);
i++;
if (i < 30) { map.setZoom(i); }
}
map.on('zoomend', check);
map.setView(layer.getCenter(), i);
});
it('computes center of a small line and test it on every zoom - C
RS.Simple', function () {
map.remove();
map = L.map(document.createElement('div'), {center: [55.8
, 37.6], zoom: 6, crs: L.CRS.Simple});
var latlngs = [[50.49898323576035, 30.509834789772036], [
50.49998323576035, 30.509834789772036], [50.49998323576035, 30.509939789772037],
[50.49898323576035, 30.509939789772037]];
var layer = L.polyline(latlngs).addTo(map);
var i = 0;
function check() {
expect(layer.getCenter()).to.be.nearLatLng([50.49
998323576035, 30.50989603626345]);
i++;
if (i < 30) { map.setZoom(i); }
}
map.on('zoomend', check);
map.setView(layer.getCenter(), i);
});
it('throws error if latlngs not passed', function () {
expect(function () {
L.LineUtil.polylineCenter(null, crs, zoom);
}).to.throwException('latlngs not passed');
});
it('throws error if latlng array is empty', function () {
expect(function () {
L.LineUtil.polylineCenter([], crs, zoom);
}).to.throwException('latlngs not passed');
});
it('throws error if map not passed', function () {
var latlngs = [[80, 0], [80, 90]];
expect(function () {
L.LineUtil.polylineCenter(latlngs, null);
}).to.throwException('map not passed');
});
it('shows warning if latlngs is not flat', function () {
var latlngs = [
[[80, 0], [80, 90]]
];
var spy = sinon.spy(console, 'warn');
var center = L.LineUtil.polylineCenter(latlngs, crs, zoom
);
console.warn.restore();
expect(spy.calledOnce).to.be.ok();
expect(center).to.be.nearLatLng([80, 45]);
});
});
}); });
 End of changes. 1 change blocks. 
0 lines changed or deleted 150 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)