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:
ghybs
2018-10-09 10:52:50 +04:00
parent 76dcd0f079
commit e02453f1f6
2 changed files with 75 additions and 0 deletions

View File

@ -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');
});
});

View File

@ -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;
});
});