[Pkg-javascript-commits] [leaflet-markercluster] 387/479: Lots of failing tests for non-point data.
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 6053d39128c89bb8693029a6aa2b256586d6ccf8
Author: danzel <danzel at localhost.geek.nz>
Date: Sat Jun 22 10:23:34 2013 +1200
Lots of failing tests for non-point data.
---
spec/suites/NonPointSpec.js | 170 +++++++++++++++++++++++++++++++++++++++++++
spec/suites/eachLayerSpec.js | 54 ++++++++++++++
2 files changed, 224 insertions(+)
diff --git a/spec/suites/NonPointSpec.js b/spec/suites/NonPointSpec.js
new file mode 100644
index 0000000..4e41a36
--- /dev/null
+++ b/spec/suites/NonPointSpec.js
@@ -0,0 +1,170 @@
+describe('adding non point data works', 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('Allows adding a polygon before via addLayer', 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]]);
+
+ group.addLayer(polygon);
+ map.addLayer(group);
+
+ expect(polygon._container).to.not.be(undefined);
+ expect(polygon._container.parentNode).to.be(map._pathRoot);
+
+ expect(group.hasLayer(polygon));
+ });
+
+ it('Allows adding a polygon before via addLayers([])', 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]]);
+
+ group.addLayers([polygon]);
+ map.addLayer(group);
+
+ expect(polygon._container).to.not.be(undefined);
+ expect(polygon._container.parentNode).to.be(map._pathRoot);
+ });
+
+ describe('hasLayer', function () {
+ it('returns false when not added', 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]]);
+
+ expect(group.hasLayer(polygon)).to.be(false);
+
+ map.addLayer(group);
+
+ expect(group.hasLayer(polygon)).to.be(false);
+
+ map.addLayer(polygon);
+
+ expect(group.hasLayer(polygon)).to.be(false);
+ });
+
+ it('returns true 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]]);
+
+ group.addLayers([polygon]);
+
+ expect(group.hasLayer(polygon)).to.be(true);
+ });
+
+ it('returns true after adding to map after adding polygon', 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]]);
+
+ group.addLayer(polygon);
+ map.addLayer(group);
+
+ expect(group.hasLayer(polygon)).to.be(true);
+ });
+
+ it('returns true after adding to map before adding polygon', 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]]);
+
+ map.addLayer(group);
+ group.addLayer(polygon);
+
+ expect(group.hasLayer(polygon)).to.be(true);
+ });
+ });
+
+ describe('getBounds', function() {
+ it('returns the correct bounds before adding to the 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]]);
+
+ group.addLayer(polygon);
+
+ expect(group.getBounds()).to.be(polygon.getBounds());
+ });
+
+ it('returns the correct bounds after adding to the map after adding polygon', 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]]);
+
+ group.addLayer(polygon);
+ map.addLayer(group);
+
+ expect(group.getBounds()).to.be(polygon.getBounds());
+ });
+
+ it('returns the correct bounds after adding to the map before adding polygon', 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]]);
+
+ map.addLayer(group);
+ group.addLayer(polygon);
+
+ expect(group.getBounds()).to.be(polygon.getBounds());
+ });
+ });
+
+ describe('removeLayer', function() {
+ it('removes 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]]);
+
+ group.addLayer(polygon);
+ expect(group.hasLayer(polygon)).to.be(true);
+
+ group.removeLayer(polygon);
+ expect(group.hasLayer(polygon)).to.be(false);
+ });
+
+ it('removes 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]]);
+
+ group.addLayers([polygon]);
+ expect(group.hasLayer(polygon)).to.be(true);
+
+ group.removeLayer(polygon);
+ expect(group.hasLayer(polygon)).to.be(false);
+ });
+
+ it('removes after adding to map after adding polygon', 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]]);
+
+ group.addLayers(polygon);
+ map.addLayers(group);
+ expect(group.hasLayer(polygon)).to.be(true);
+
+ group.removeLayer(polygon);
+ expect(group.hasLayer(polygon)).to.be(false);
+ });
+
+ it('removes after adding to map before adding polygon', 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]]);
+
+ map.addLayers(group);
+ group.addLayers(polygon);
+ expect(group.hasLayer(polygon)).to.be(true);
+
+ group.removeLayer(polygon);
+ expect(group.hasLayer(polygon)).to.be(false);
+ });
+ });
+});
\ No newline at end of file
diff --git a/spec/suites/eachLayerSpec.js b/spec/suites/eachLayerSpec.js
new file mode 100644
index 0000000..0b10a92
--- /dev/null
+++ b/spec/suites/eachLayerSpec.js
@@ -0,0 +1,54 @@
+describe('eachLayer', 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('hits polygons and markers 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]);
+
+ var layers = [];
+ group.eachLayer(function (l) {
+ layers.push(l);
+ });
+
+ expect(layers.length).to.be(2);
+ expect(layers).to.contain(marker);
+ expect(layers).to.contain(polygon);
+ });
+
+ 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);
+
+ var layers = [];
+ group.eachLayer(function (l) {
+ layers.push(l);
+ });
+
+ expect(layers.length).to.be(2);
+ expect(layers).to.contain(marker);
+ expect(layers).to.contain(polygon);
+ });
+});
\ 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