[Pkg-javascript-commits] [leaflet-markercluster] 359/479: More tests about adding markers to the map

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 18b9f77db308b0f8a3a2aff4f916c43dae1d8306
Author: danzel <danzel at localhost.geek.nz>
Date:   Fri Jun 14 14:42:36 2013 +1200

    More tests about adding markers to the map
---
 spec/suites/AddLayer.MultipleSpec.js | 88 ++++++++++++++++++++++++++++++++++++
 spec/suites/AddLayers.js             | 85 ++++++++++++++++++++++++++++++++++
 2 files changed, 173 insertions(+)

diff --git a/spec/suites/AddLayer.MultipleSpec.js b/spec/suites/AddLayer.MultipleSpec.js
new file mode 100644
index 0000000..804484a
--- /dev/null
+++ b/spec/suites/AddLayer.MultipleSpec.js
@@ -0,0 +1,88 @@
+describe('addLayer adding multiple markers', 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('creates a cluster when 2 overlapping markers are added before the group is added to the map', 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.addLayer(marker);
+		group.addLayer(marker2);
+		map.addLayer(group);
+
+		expect(marker._icon).to.be(undefined);
+		expect(marker2._icon).to.be(undefined);
+
+		expect(map._panes.markerPane.childNodes.length).to.be(1);
+	});
+	it('creates a cluster when 2 overlapping markers are added after the group is added to the map', 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);
+
+		expect(marker._icon).to.be(null); //Null as was added and then removed
+		expect(marker2._icon).to.be(undefined);
+
+		expect(map._panes.markerPane.childNodes.length).to.be(1);
+	});
+
+
+	it('creates a cluster and marker when 2 overlapping markers and one non-overlapping are added before the group is added to the map', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.Marker([1.5, 1.5]);
+		var marker2 = new L.Marker([1.5, 1.5]);
+		var marker3 = new L.Marker([3.0, 1.5]);
+
+		group.addLayer(marker);
+		group.addLayer(marker2);
+		group.addLayer(marker3);
+		map.addLayer(group);
+
+		expect(marker._icon).to.be(undefined);
+		expect(marker2._icon).to.be(undefined);
+		expect(marker3._icon.parentNode).to.be(map._panes.markerPane);
+
+		expect(map._panes.markerPane.childNodes.length).to.be(2);
+	});
+	it('creates a cluster and marker when 2 overlapping markers and one non-overlapping are added after the group is added to the map', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.Marker([1.5, 1.5]);
+		var marker2 = new L.Marker([1.5, 1.5]);
+		var marker3 = new L.Marker([3.0, 1.5]);
+
+		map.addLayer(group);
+		group.addLayer(marker);
+		group.addLayer(marker2);
+		group.addLayer(marker3);
+
+		expect(marker._icon).to.be(null); //Null as was added and then removed
+		expect(marker2._icon).to.be(undefined);
+		expect(marker3._icon.parentNode).to.be(map._panes.markerPane);
+
+		expect(map._panes.markerPane.childNodes.length).to.be(2);
+	});
+});
\ No newline at end of file
diff --git a/spec/suites/AddLayers.js b/spec/suites/AddLayers.js
new file mode 100644
index 0000000..f70a62e
--- /dev/null
+++ b/spec/suites/AddLayers.js
@@ -0,0 +1,85 @@
+describe('addLayer adding multiple markers', 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('creates a cluster when 2 overlapping markers are added before the group is added to the map', 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);
+
+		expect(marker._icon).to.be(undefined);
+		expect(marker2._icon).to.be(undefined);
+
+		expect(map._panes.markerPane.childNodes.length).to.be(1);
+	});
+
+	it('creates a cluster when 2 overlapping markers are added after the group is added to the map', 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.addLayers([marker, marker2]);
+
+		expect(marker._icon).to.be(undefined);
+		expect(marker2._icon).to.be(undefined);
+
+		expect(map._panes.markerPane.childNodes.length).to.be(1);
+	});
+
+
+
+	it('creates a cluster and marker when 2 overlapping markers and one non-overlapping are added before the group is added to the map', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.Marker([1.5, 1.5]);
+		var marker2 = new L.Marker([1.5, 1.5]);
+		var marker3 = new L.Marker([3.0, 1.5]);
+
+		group.addLayers([marker, marker2, marker3]);
+		map.addLayer(group);
+
+		expect(marker._icon).to.be(undefined);
+		expect(marker2._icon).to.be(undefined);
+		expect(marker3._icon.parentNode).to.be(map._panes.markerPane);
+
+		expect(map._panes.markerPane.childNodes.length).to.be(2);
+	});
+	it('creates a cluster and marker when 2 overlapping markers and one non-overlapping are added after the group is added to the map', function () {
+
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.Marker([1.5, 1.5]);
+		var marker2 = new L.Marker([1.5, 1.5]);
+		var marker3 = new L.Marker([3.0, 1.5]);
+
+		map.addLayer(group);
+		group.addLayers([marker, marker2, marker3]);
+
+		expect(marker._icon).to.be(undefined);
+		expect(marker2._icon).to.be(undefined);
+		expect(marker3._icon.parentNode).to.be(map._panes.markerPane);
+
+		expect(map._panes.markerPane.childNodes.length).to.be(2);
+	});
+
+});
\ 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