[Pkg-javascript-commits] [leaflet-markercluster] 368/479: Add a test to reproduce #141, but it doesn't break.

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:58 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 db8ed41c9a6335ae8523cbdaf00888461081ac73
Author: danzel <danzel at localhost.geek.nz>
Date:   Fri Jun 14 16:33:43 2013 +1200

    Add a test to reproduce #141, but it doesn't break.
---
 spec/index.html                             | 33 +++++++++++----------
 spec/suites/ChildChangingIconSupportSpec.js | 45 +++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 15 deletions(-)

diff --git a/spec/index.html b/spec/index.html
index 1d378b6..5f46790 100644
--- a/spec/index.html
+++ b/spec/index.html
@@ -1,14 +1,14 @@
 <!DOCTYPE html>
 <html>
 <head>
-    <meta charset="utf-8">
+	<meta charset="utf-8">
 	<title>Spec Runner</title>
 	<link rel="stylesheet" type="text/css" href="../node_modules/mocha/mocha.css">
 </head>
 <body>
-    <div id="mocha"></div>
-    <script src="expect.js"></script>
-   	<script type="text/javascript" src="../node_modules/mocha/mocha.js"></script>
+	<div id="mocha"></div>
+	<script src="expect.js"></script>
+	<script type="text/javascript" src="../node_modules/mocha/mocha.js"></script>
 	<script type="text/javascript" src="happen.js"></script>
 	<script type="text/javascript" src="sinon.js"></script>
 	<script type="text/javascript" src="../node_modules/leaflet/dist/leaflet-src.js"></script>
@@ -20,29 +20,32 @@
 	<script type="text/javascript" src="../src/MarkerCluster.QuickHull.js"></script>
 	<script type="text/javascript" src="../src/MarkerCluster.Spiderfier.js"></script>
 
-    <script>
-        mocha.setup('bdd');
-        mocha.ignoreLeaks();
-    </script>
+	<script>
+		mocha.setup('bdd');
+		mocha.ignoreLeaks();
+	</script>
 
 	<!-- spec files -->
 
 	<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/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>
 
-	
-    <script>
-        (window.mochaPhantomJS || window.mocha).run();
-    </script>
+	<script type="text/javascript" src="suites/ChildChangingIconSupportSpec.js"></script>
+
+
+
+	<script>
+		(window.mochaPhantomJS || window.mocha).run();
+	</script>
 </body>
 </html>
diff --git a/spec/suites/ChildChangingIconSupportSpec.js b/spec/suites/ChildChangingIconSupportSpec.js
new file mode 100644
index 0000000..2814a16
--- /dev/null
+++ b/spec/suites/ChildChangingIconSupportSpec.js
@@ -0,0 +1,45 @@
+describe('support child markers changing icon', 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('child markers end up with the right icon after becoming unclustered', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.Marker([1.5, 1.5], { icon: new L.DivIcon({html: 'Inner1Text' }) });
+		var marker2 = new L.Marker([1.5, 1.5]);
+
+		map.addLayer(group);
+		group.addLayer(marker);
+
+		expect(marker._icon.parentNode).to.be(map._panes.markerPane);
+		expect(marker._icon.innerHTML).to.contain('Inner1Text');
+
+		group.addLayer(marker2);
+
+		expect(marker._icon).to.be(null); //Have been removed from the map
+
+		marker.setIcon(new L.DivIcon({ html: 'Inner2Text' })); //Change the icon
+
+		group.removeLayer(marker2); //Remove the other marker, so we'll become unclustered
+
+		expect(marker._icon.innerHTML).to.contain('Inner2Text');
+	});
+});
\ 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