mirror of
https://github.com/Leaflet/Leaflet.markercluster.git
synced 2025-08-16 15:04:51 +00:00
test(addLayer/s): add 2 tests for unspiderfication
before addLayer and addLayers actually add some Marker(s) to a cluster, so that the UI does not display an incorrect state. The addLayers test fails in current state, fix to be added in next commit.
This commit is contained in:
@ -122,4 +122,39 @@
|
||||
|
||||
expect(map._panes.markerPane.childNodes.length).to.be(2);
|
||||
});
|
||||
|
||||
it('unspiderfies before adding a new Marker', function () {
|
||||
|
||||
group = new L.MarkerClusterGroup();
|
||||
|
||||
var marker = new L.Marker([1.5, 1.5]);
|
||||
var marker2 = new L.Marker([1.5, 1.5]);
|
||||
var marker3 = new L.Marker([1.5, 1.5]);
|
||||
|
||||
group.addLayers([marker, marker2]);
|
||||
map.addLayer(group);
|
||||
|
||||
expect(marker._icon).to.be(undefined);
|
||||
expect(marker2._icon).to.be(undefined);
|
||||
|
||||
group.zoomToShowLayer(marker);
|
||||
//Run the the animation
|
||||
clock.tick(1000);
|
||||
|
||||
expect(marker._icon).to.not.be(undefined);
|
||||
expect(marker._icon).to.not.be(null);
|
||||
expect(marker2._icon).to.not.be(undefined);
|
||||
expect(marker2._icon).to.not.be(null);
|
||||
|
||||
group.addLayer(marker3);
|
||||
//Run the the animation
|
||||
clock.tick(1000);
|
||||
|
||||
expect(marker._icon).to.be(null);
|
||||
expect(marker2._icon).to.be(null);
|
||||
expect(marker3._icon).to.be(undefined);
|
||||
expect(marker3.__parent._icon).to.not.be(undefined);
|
||||
expect(marker3.__parent._icon).to.not.be(null);
|
||||
expect(marker3.__parent._icon.innerText.trim()).to.equal('3');
|
||||
});
|
||||
});
|
@ -120,4 +120,44 @@
|
||||
|
||||
expect(map._panes.markerPane.childNodes.length).to.be(2);
|
||||
});
|
||||
|
||||
it('unspiderfies before adding new Marker(s)', function () {
|
||||
|
||||
var clock = sinon.useFakeTimers();
|
||||
|
||||
group = new L.MarkerClusterGroup();
|
||||
|
||||
var marker = new L.Marker([1.5, 1.5]);
|
||||
var marker2 = new L.Marker([1.5, 1.5]);
|
||||
var marker3 = new L.Marker([1.5, 1.5]);
|
||||
|
||||
group.addLayers([marker, marker2]);
|
||||
map.addLayer(group);
|
||||
|
||||
expect(marker._icon).to.be(undefined);
|
||||
expect(marker2._icon).to.be(undefined);
|
||||
|
||||
group.zoomToShowLayer(marker);
|
||||
//Run the the animation
|
||||
clock.tick(1000);
|
||||
|
||||
expect(marker._icon).to.not.be(undefined);
|
||||
expect(marker._icon).to.not.be(null);
|
||||
expect(marker2._icon).to.not.be(undefined);
|
||||
expect(marker2._icon).to.not.be(null);
|
||||
|
||||
group.addLayers([marker3]);
|
||||
//Run the the animation
|
||||
clock.tick(1000);
|
||||
|
||||
expect(marker._icon).to.be(null);
|
||||
expect(marker2._icon).to.be(null);
|
||||
expect(marker3._icon).to.be(undefined);
|
||||
expect(marker3.__parent._icon).to.not.be(undefined);
|
||||
expect(marker3.__parent._icon).to.not.be(null);
|
||||
expect(marker3.__parent._icon.innerText.trim()).to.equal('3');
|
||||
|
||||
clock.restore();
|
||||
clock = null;
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user