From 25bb880379387657a60af4b953ecefe3c08e1c59 Mon Sep 17 00:00:00 2001 From: danzel Date: Fri, 14 Jun 2013 15:36:22 +1200 Subject: [PATCH] Animation test for adding multiple markers with animations on --- spec/suites/AddLayer.MultipleSpec.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/spec/suites/AddLayer.MultipleSpec.js b/spec/suites/AddLayer.MultipleSpec.js index 804484a29..f2ab53401 100644 --- a/spec/suites/AddLayer.MultipleSpec.js +++ b/spec/suites/AddLayer.MultipleSpec.js @@ -1,6 +1,8 @@ describe('addLayer adding multiple markers', function () { - var map, div; + var map, div, clock; beforeEach(function () { + clock = sinon.useFakeTimers(); + div = document.createElement('div'); div.style.width = '200px'; div.style.height = '200px'; @@ -14,6 +16,7 @@ ])); }); afterEach(function () { + clock.restore(); document.body.removeChild(div); }); @@ -47,7 +50,30 @@ expect(map._panes.markerPane.childNodes.length).to.be(1); }); + it('creates a cluster with an animation when 2 overlapping markers are added after the group is added to the map', function () { + var group = new L.MarkerClusterGroup({ animateAddingMarkers: true }); + var marker = new L.Marker([1.5, 1.5]); + var marker2 = new L.Marker([1.5, 1.5]); + + map.addLayer(group); + group.addLayer(marker); + group.addLayer(marker2); + + expect(marker._icon.parentNode).to.be(map._panes.markerPane); + expect(marker2._icon.parentNode).to.be(map._panes.markerPane); + + expect(map._panes.markerPane.childNodes.length).to.be(3); + + //Run the the animation + clock.tick(1000); + + //Then markers should be removed from map + expect(marker._icon).to.be(null); + expect(marker2._icon).to.be(null); + + expect(map._panes.markerPane.childNodes.length).to.be(1); + }); it('creates a cluster and marker when 2 overlapping markers and one non-overlapping are added before the group is added to the map', function () {