[Pkg-javascript-commits] [leaflet-markercluster] 362/479: Test for having Circle(Marker) children.

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:51 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository leaflet-markercluster.

commit 41ccbf8ac6ba57f97584b2124bcb0d20cf90cc12
Author: danzel <danzel at localhost.geek.nz>
Date:   Fri Jun 14 15:36:08 2013 +1200

    Test for having Circle(Marker) children.
---
 spec/index.html                                |   6 +-
 spec/suites/{AddLayers.js => AddLayersSpec.js} |   0
 spec/suites/CircleMarkerSupportSpec.js         | 118 +++++++++++++++++++++++++
 spec/suites/CircleSupportSpec.js               | 118 +++++++++++++++++++++++++
 4 files changed, 241 insertions(+), 1 deletion(-)

diff --git a/spec/index.html b/spec/index.html
index 2866d21..8d3544d 100644
--- a/spec/index.html
+++ b/spec/index.html
@@ -30,9 +30,13 @@
 	<script type="text/javascript" src="suites/SpecHelper.js"></script>
 	
 	<script type="text/javascript" src="suites/LeafletSpec.js"></script>
+	
 	<script type="text/javascript" src="suites/AddLayer.SingleSpec.js"></script>
 	<script type="text/javascript" src="suites/AddLayer.MultipleSpec.js"></script>
-	<script type="text/javascript" src="suites/AddLayers.js"></script>
+	<script type="text/javascript" src="suites/AddLayersSpec.js"></script>
+
+	<script type="text/javascript" src="suites/CircleMarkerSupportSpec.js"></script>
+	<script type="text/javascript" src="suites/CircleSupportSpec.js"></script>
 
 	
     <script>
diff --git a/spec/suites/AddLayers.js b/spec/suites/AddLayersSpec.js
similarity index 100%
rename from spec/suites/AddLayers.js
rename to spec/suites/AddLayersSpec.js
diff --git a/spec/suites/CircleMarkerSupportSpec.js b/spec/suites/CircleMarkerSupportSpec.js
new file mode 100644
index 0000000..861a122
--- /dev/null
+++ b/spec/suites/CircleMarkerSupportSpec.js
@@ -0,0 +1,118 @@
+describe('support for CircleMarker elements', function () {
+	var map, div, clock;
+	beforeEach(function () {
+		clock = sinon.useFakeTimers();
+
+		div = document.createElement('div');
+		div.style.width = '200px';
+		div.style.height = '200px';
+		document.body.appendChild(div);
+
+		map = L.map(div, { maxZoom: 18 });
+
+		map.fitBounds(new L.LatLngBounds([
+			[1, 1],
+			[2, 2]
+		]));
+	});
+	afterEach(function () {
+		clock.restore();
+		document.body.removeChild(div);
+	});
+
+	it('appears when added to the group before the group is added to the map', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.CircleMarker([1.5, 1.5]);
+
+		group.addLayer(marker);
+		map.addLayer(group);
+
+		expect(marker._container).to.not.be(undefined);
+		expect(marker._container.parentNode).to.be(map._pathRoot);
+
+		clock.tick(1000);
+	});
+	it('appears when added to the group after the group is added to the map', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.CircleMarker([1.5, 1.5]);
+
+		group.addLayer(marker);
+		map.addLayer(group);
+
+		expect(marker._container).to.not.be(undefined);
+		expect(marker._container.parentNode).to.be(map._pathRoot);
+
+		clock.tick(1000);
+	});
+	it('appears animated when added to the group after the group is added to the map', function () {
+
+		var group = new L.MarkerClusterGroup({ animateAddingMarkers: true });
+		var marker = new L.CircleMarker([1.5, 1.5]);
+		var marker2 = new L.CircleMarker([1.5, 1.5]);
+
+		map.addLayer(group);
+		group.addLayer(marker);
+		group.addLayer(marker2);
+
+		expect(marker._container.parentNode).to.be(map._pathRoot);
+		expect(marker2._container.parentNode).to.be(map._pathRoot);
+
+		clock.tick(1000);
+	});
+
+
+	it('creates a cluster when 2 overlapping markers are added before the group is added to the map', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.CircleMarker([1.5, 1.5]);
+		var marker2 = new L.CircleMarker([1.5, 1.5]);
+
+		group.addLayers([marker, marker2]);
+		map.addLayer(group);
+
+		expect(marker._container).to.be(undefined);
+		expect(marker2._container).to.be(undefined);
+
+		expect(map._panes.markerPane.childNodes.length).to.be(1);
+
+		clock.tick(1000);
+	});
+	it('creates a cluster when 2 overlapping markers are added after the group is added to the map', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.CircleMarker([1.5, 1.5]);
+		var marker2 = new L.CircleMarker([1.5, 1.5]);
+
+		map.addLayer(group);
+		group.addLayer(marker);
+		group.addLayer(marker2);
+
+		expect(marker._container.parentNode).to.be(null); //Removed then re-added, so null
+		expect(marker2._container).to.be(undefined);
+
+		expect(map._panes.markerPane.childNodes.length).to.be(1);
+
+		clock.tick(1000);
+	});
+
+	it('disappears when removed from the group', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.CircleMarker([1.5, 1.5]);
+
+		group.addLayer(marker);
+		map.addLayer(group);
+
+		expect(marker._container).to.not.be(undefined);
+		expect(marker._container.parentNode).to.be(map._pathRoot);
+
+		group.removeLayer(marker);
+
+		expect(marker._container.parentNode).to.be(null);
+
+		clock.tick(1000);
+	});
+
+});
\ No newline at end of file
diff --git a/spec/suites/CircleSupportSpec.js b/spec/suites/CircleSupportSpec.js
new file mode 100644
index 0000000..245951a
--- /dev/null
+++ b/spec/suites/CircleSupportSpec.js
@@ -0,0 +1,118 @@
+describe('support for Circle elements', function () {
+	var map, div, clock;
+	beforeEach(function () {
+		clock = sinon.useFakeTimers();
+
+		div = document.createElement('div');
+		div.style.width = '200px';
+		div.style.height = '200px';
+		document.body.appendChild(div);
+
+		map = L.map(div, { maxZoom: 18 });
+
+		map.fitBounds(new L.LatLngBounds([
+			[1, 1],
+			[2, 2]
+		]));
+	});
+	afterEach(function () {
+		clock.restore();
+		document.body.removeChild(div);
+	});
+
+	it('appears when added to the group before the group is added to the map', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.Circle([1.5, 1.5], 200);
+
+		group.addLayer(marker);
+		map.addLayer(group);
+
+		expect(marker._container).to.not.be(undefined);
+		expect(marker._container.parentNode).to.be(map._pathRoot);
+
+		clock.tick(1000);
+	});
+	it('appears when added to the group after the group is added to the map', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.Circle([1.5, 1.5], 200);
+
+		group.addLayer(marker);
+		map.addLayer(group);
+
+		expect(marker._container).to.not.be(undefined);
+		expect(marker._container.parentNode).to.be(map._pathRoot);
+
+		clock.tick(1000);
+	});
+	it('appears animated when added to the group after the group is added to the map', function () {
+
+		var group = new L.MarkerClusterGroup({ animateAddingMarkers: true });
+		var marker = new L.Circle([1.5, 1.5], 200);
+		var marker2 = new L.Circle([1.5, 1.5], 200);
+
+		map.addLayer(group);
+		group.addLayer(marker);
+		group.addLayer(marker2);
+
+		expect(marker._container.parentNode).to.be(map._pathRoot);
+		expect(marker2._container.parentNode).to.be(map._pathRoot);
+
+		clock.tick(1000);
+	});
+
+
+	it('creates a cluster when 2 overlapping markers are added before the group is added to the map', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.Circle([1.5, 1.5], 200);
+		var marker2 = new L.Circle([1.5, 1.5], 200);
+
+		group.addLayers([marker, marker2]);
+		map.addLayer(group);
+
+		expect(marker._container).to.be(undefined);
+		expect(marker2._container).to.be(undefined);
+
+		expect(map._panes.markerPane.childNodes.length).to.be(1);
+
+		clock.tick(1000);
+	});
+	it('creates a cluster when 2 overlapping markers are added after the group is added to the map', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.Circle([1.5, 1.5], 200);
+		var marker2 = new L.Circle([1.5, 1.5], 200);
+
+		map.addLayer(group);
+		group.addLayer(marker);
+		group.addLayer(marker2);
+
+		expect(marker._container.parentNode).to.be(null); //Removed then re-added, so null
+		expect(marker2._container).to.be(undefined);
+
+		expect(map._panes.markerPane.childNodes.length).to.be(1);
+
+		clock.tick(1000);
+	});
+
+	it('disappears when removed from the group', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.Circle([1.5, 1.5], 200);
+
+		group.addLayer(marker);
+		map.addLayer(group);
+
+		expect(marker._container).to.not.be(undefined);
+		expect(marker._container.parentNode).to.be(map._pathRoot);
+
+		group.removeLayer(marker);
+
+		expect(marker._container.parentNode).to.be(null);
+
+		clock.tick(1000);
+	});
+
+});
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet-markercluster.git



More information about the Pkg-javascript-commits mailing list