[Pkg-javascript-commits] [leaflet-markercluster] 388/479: tests for clearLayers

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:01:00 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 47ea5476112868c387bb1a09c64580db1ef8ce42
Author: danzel <danzel at localhost.geek.nz>
Date:   Sat Jun 22 10:25:12 2013 +1200

    tests for clearLayers
---
 spec/suites/clearLayersSpec.js | 44 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/spec/suites/clearLayersSpec.js b/spec/suites/clearLayersSpec.js
new file mode 100644
index 0000000..3dde762
--- /dev/null
+++ b/spec/suites/clearLayersSpec.js
@@ -0,0 +1,44 @@
+describe('clearLayer', 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('clears everything before adding to map', function () {
+		var group = new L.MarkerClusterGroup();
+		var polygon = new L.Polygon([[1.5, 1.5], [2.0, 1.5], [2.0, 2.0], [1.5, 2.0]]);
+		var marker = new L.Marker([1.5, 1.5]);
+
+		group.addLayers([polygon, marker]);
+		group.clearLayers();
+
+		expect(group.hasLayer(polygon)).to.be(false);
+		expect(group.hasLayer(marker)).to.be(false);
+	});
+
+	it('hits polygons and markers after adding to map', function () {
+		var group = new L.MarkerClusterGroup();
+		var polygon = new L.Polygon([[1.5, 1.5], [2.0, 1.5], [2.0, 2.0], [1.5, 2.0]]);
+		var marker = new L.Marker([1.5, 1.5]);
+
+		group.addLayers([polygon, marker]);
+		map.addLayer(group);
+		group.clearLayers();
+
+		expect(group.hasLayer(polygon)).to.be(false);
+		expect(group.hasLayer(marker)).to.be(false);
+	});
+});
\ 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