[Pkg-javascript-commits] [leaflet-markercluster] 393/479: More tests for #200, this was really bugged!

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 21580cc066221d153ff4469bccfc496ef3b4ff85
Author: danzel <danzel at localhost.geek.nz>
Date:   Mon Jun 24 10:23:33 2013 +1200

    More tests for #200, this was really bugged!
---
 spec/suites/eventsSpec.js | 95 +++++++++++++++++++++++++++++++++++++----------
 1 file changed, 76 insertions(+), 19 deletions(-)

diff --git a/spec/suites/eventsSpec.js b/spec/suites/eventsSpec.js
index 175642e..38599b8 100644
--- a/spec/suites/eventsSpec.js
+++ b/spec/suites/eventsSpec.js
@@ -47,40 +47,97 @@
 		expect(callback.called).to.be(true);
 	});
 
-	it('fires events for nonpoint data after being removed and re-added to the map', function () {
+	it('is fired for a cluster click', function () {
 		var callback = sinon.spy();
 		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]);
+		var marker2 = new L.Marker([1.5, 1.5]);
 
-		group.on('click', callback);
-		group.addLayer(polygon);
-		map.addLayer(group);
-		map.removeLayer(group);
+		group.on('clusterclick', callback);
+		group.addLayers([marker, marker2]);
 		map.addLayer(group);
 
-		polygon.fire('click');
+		var cluster = group.getVisibleParent(marker);
+		expect(cluster instanceof L.MarkerCluster).to.be(true);
+
+		cluster.fire('click');
 
 		expect(callback.called).to.be(true);
 	});
 
-	it('fires events for point data after being removed and re-added to the map', function () {
-		var callback = sinon.spy();
-		var group = new L.MarkerClusterGroup();
+	describe('after being added, removed, re-added from the map', function() {
+		it('still fires events for nonpoint data', function() {
+			var callback = sinon.spy();
+			var group = new L.MarkerClusterGroup();
 
-		var marker = new L.Marker([1.5, 1.5]);
+			var polygon = new L.Polygon([[1.5, 1.5], [2.0, 1.5], [2.0, 2.0], [1.5, 2.0]]);
 
-		group.on('click', callback);
-		group.addLayer(marker);
-		map.addLayer(group);
-		map.removeLayer(group);
-		map.addLayer(group);
+			group.on('click', callback);
+			group.addLayer(polygon);
+			map.addLayer(group);
+			map.removeLayer(group);
+			map.addLayer(group);
 
-		marker.fire('click');
+			polygon.fire('click');
 
-		expect(callback.called).to.be(true);
-	});
+			expect(callback.called).to.be(true);
+		});
+
+		it('still fires events for point data', function() {
+			var callback = sinon.spy();
+			var group = new L.MarkerClusterGroup();
+
+			var marker = new L.Marker([1.5, 1.5]);
+
+			group.on('click', callback);
+			group.addLayer(marker);
+			map.addLayer(group);
+			map.removeLayer(group);
+			map.addLayer(group);
+
+			marker.fire('click');
+
+			expect(callback.called).to.be(true);
+		});
+
+		it('still fires cluster events', function() {
+			var callback = sinon.spy();
+			var group = new L.MarkerClusterGroup();
+
+			var marker = new L.Marker([1.5, 1.5]);
+			var marker2 = new L.Marker([1.5, 1.5]);
+
+			group.on('clusterclick', callback);
+			group.addLayers([marker, marker2]);
+			map.addLayer(group);
 
+			map.removeLayer(group);
+			map.addLayer(group);
+
+			var cluster = group.getVisibleParent(marker);
+			expect(cluster instanceof L.MarkerCluster).to.be(true);
+
+			cluster.fire('click');
+
+			expect(callback.called).to.be(true);
+		});
+
+		it('doesnt break map events', function () {
+			var callback = sinon.spy();
+			var group = new L.MarkerClusterGroup();
+
+			map.on('zoomend', callback);
+			map.addLayer(group);
+
+			map.removeLayer(group);
+			map.addLayer(group);
+
+			map.fire('zoomend');
+
+			expect(callback.called).to.be(true);
+		});
+	});
 	/*
 	//No normal events can be fired by a clustered marker, so probably don't need this.
 	it('is fired for a clustered child marker', function() {

-- 
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