[Pkg-javascript-commits] [leaflet-markercluster] 365/479: Add some starting tests for RemoveLayer.

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 58fe4615ceba6a18487f658a46cfa8b2568171d7
Author: danzel <danzel at localhost.geek.nz>
Date:   Fri Jun 14 16:19:41 2013 +1200

    Add some starting tests for RemoveLayer.
---
 spec/index.html                |   2 +
 spec/suites/RemoveLayerSpec.js | 101 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 103 insertions(+)

diff --git a/spec/index.html b/spec/index.html
index 8d3544d..1d378b6 100644
--- a/spec/index.html
+++ b/spec/index.html
@@ -34,6 +34,8 @@
 	<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/AddLayersSpec.js"></script>
+	
+	<script type="text/javascript" src="suites/RemoveLayerSpec.js"></script>
 
 	<script type="text/javascript" src="suites/CircleMarkerSupportSpec.js"></script>
 	<script type="text/javascript" src="suites/CircleSupportSpec.js"></script>
diff --git a/spec/suites/RemoveLayerSpec.js b/spec/suites/RemoveLayerSpec.js
new file mode 100644
index 0000000..a3d8d88
--- /dev/null
+++ b/spec/suites/RemoveLayerSpec.js
@@ -0,0 +1,101 @@
+describe('removeLayer', 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, { maxZoom: 18 });
+
+		map.fitBounds(new L.LatLngBounds([
+			[1, 1],
+			[2, 2]
+		]));
+	});
+	afterEach(function () {
+		document.body.removeChild(div);
+	});
+
+	it('removes a layer that was added to it', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.Marker([1.5, 1.5]);
+
+		map.addLayer(group);
+
+		group.addLayer(marker);
+
+		expect(marker._icon.parentNode).to.be(map._panes.markerPane);
+
+		group.removeLayer(marker);
+
+		expect(marker._icon).to.be(null);
+	});
+
+	it('doesnt remove a layer not added to it', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.Marker([1.5, 1.5]);
+
+		map.addLayer(group);
+
+		map.addLayer(marker);
+
+		expect(marker._icon.parentNode).to.be(map._panes.markerPane);
+
+		group.removeLayer(marker);
+
+		expect(marker._icon.parentNode).to.be(map._panes.markerPane);
+	});
+
+	it('removes a layer that was added to it (before being on the map) that is shown in a cluster', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.Marker([1.5, 1.5]);
+		var marker2 = new L.Marker([1.5, 1.5]);
+
+		group.addLayers([marker, marker2]);
+		map.addLayer(group);
+
+		group.removeLayer(marker);
+
+		expect(marker._icon).to.be(undefined);
+		expect(marker2._icon.parentNode).to.be(map._panes.markerPane);
+	});
+
+	it('removes a layer that was added to it (after being on the map) that is shown in a cluster', function () {
+
+		var group = new L.MarkerClusterGroup();
+		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);
+
+		group.removeLayer(marker);
+
+		expect(marker._icon).to.be(null);
+		expect(marker2._icon.parentNode).to.be(map._panes.markerPane);
+	});
+
+	it('removes a layer that was added to it (before being on the map) that is individually', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.Marker([1, 1.5]);
+		var marker2 = new L.Marker([3, 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);
+
+		group.removeLayer(marker);
+
+		expect(marker._icon).to.be(null);
+		expect(marker2._icon.parentNode).to.be(map._panes.markerPane);
+	});
+});
\ 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