[Pkg-javascript-commits] [leaflet-markercluster] 155/219: Added test for refresh singleMarkerMode reject alien markers

Jonas Smedegaard dr at jones.dk
Sat May 7 09:39:30 UTC 2016


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

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

commit 8a9f126b52ac4541589edbdf9fa733070841649f
Author: ghybs <ghybs1 at gmail.com>
Date:   Wed Oct 21 14:27:58 2015 +0400

    Added test for refresh singleMarkerMode reject alien markers
---
 spec/suites/RefreshSpec.js | 67 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 53 insertions(+), 14 deletions(-)

diff --git a/spec/suites/RefreshSpec.js b/spec/suites/RefreshSpec.js
index dbd6ed9..44494a6 100644
--- a/spec/suites/RefreshSpec.js
+++ b/spec/suites/RefreshSpec.js
@@ -185,24 +185,27 @@
 
 	});
 
-	it('re-draws markers in singleMarkerMode', function () {
-
-		group = L.markerClusterGroup({
-			singleMarkerMode: true,
-			iconCreateFunction: function (cluster) {
-				var markers = cluster.getAllChildMarkers();
+	// Shared code for the 2 below tests
+	function iconCreateFunction(cluster) {
+		var markers = cluster.getAllChildMarkers();
 
-				for(var i in markers) {
-					if (markers[i].changed) {
-						return new L.DivIcon({
-							className: "changed"
-						});
-					}
-				}
+		for(var i in markers) {
+			if (markers[i].changed) {
 				return new L.DivIcon({
-					className: "original"
+					className: "changed"
 				});
 			}
+		}
+		return new L.DivIcon({
+			className: "original"
+		});
+	}
+
+	it('re-draws markers in singleMarkerMode', function () {
+
+		group = L.markerClusterGroup({
+			singleMarkerMode: true,
+			iconCreateFunction: iconCreateFunction
 		}).addTo(map);
 
 		var marker1 = L.marker([1.5, 1.5]).addTo(group);
@@ -222,6 +225,42 @@
 
 	});
 
+	it('does not modify markers that do not belong to the current group (in singleMarkerMode)', function () {
+
+		group = L.markerClusterGroup({
+			singleMarkerMode: true,
+			iconCreateFunction: iconCreateFunction
+		}).addTo(map);
+
+		var marker1 = L.marker([1.5, 1.5]).addTo(group),
+			marker2 = L.marker([1.5, 1.5], {
+				icon: iconCreateFunction({
+					getAllChildMarkers: function () {
+						return marker2;
+					}
+				})
+			}).addTo(map);
+
+		setMapView();
+
+		expect(marker1._icon.className).to.contain("original");
+		expect(marker2._icon.className).to.contain("original");
+
+		// Alter the markers.
+		marker1.changed = true;
+		marker2.changed = true;
+
+		// Then request clusters refresh.
+		group.refreshClusters([marker1, marker2]);
+
+		expect(marker1._icon.className).to.contain("changed");
+		expect(marker1._icon.className).to.not.contain("original");
+
+		expect(marker2._icon.className).to.contain("original");
+		expect(marker2._icon.className).to.not.contain("changed");
+
+	});
+
 
 	// Shared code for below tests.
 	var marker1 = L.marker([1.5, 1.5]),

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