55 lines
1.1 KiB
JavaScript
55 lines
1.1 KiB
JavaScript
describe('onAdd', function () {
|
|
var map, div;
|
|
beforeEach(function () {
|
|
div = document.createElement('div');
|
|
div.style.width = '200px';
|
|
div.style.height = '200px';
|
|
document.body.appendChild(div);
|
|
|
|
map = L.map(div);
|
|
|
|
map.fitBounds(new L.LatLngBounds([
|
|
[1, 1],
|
|
[2, 2]
|
|
]));
|
|
});
|
|
afterEach(function () {
|
|
document.body.removeChild(div);
|
|
});
|
|
|
|
|
|
it('throws an error if maxZoom is not specified', function () {
|
|
|
|
var group = new L.MarkerClusterGroup();
|
|
var marker = new L.Marker([1.5, 1.5]);
|
|
|
|
group.addLayer(marker);
|
|
|
|
var ex = null;
|
|
try {
|
|
map.addLayer(group);
|
|
} catch (e) {
|
|
ex = e;
|
|
}
|
|
|
|
expect(ex).to.not.be(null);
|
|
});
|
|
|
|
it('successfully handles removing and re-adding a layer while not on the map', function () {
|
|
map.options.maxZoom = 18;
|
|
var group = new L.MarkerClusterGroup();
|
|
var marker = new L.Marker([1.5, 1.5]);
|
|
|
|
map.addLayer(group);
|
|
group.addLayer(marker);
|
|
|
|
map.removeLayer(group);
|
|
group.removeLayer(marker);
|
|
group.addLayer(marker);
|
|
|
|
map.addLayer(group);
|
|
|
|
expect(map.hasLayer(group)).to.be(true);
|
|
expect(group.hasLayer(marker)).to.be(true);
|
|
});
|
|
}); |