[Pkg-javascript-commits] [leaflet-markercluster] 33/219: Add some removeLayers tests, everything seems to be working.
Jonas Smedegaard
dr at jones.dk
Sat May 7 09:39:09 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 c0ffbc75a912bc7f0f71096fc351e8394b5aa537
Author: danzel <danzel at localhost.geek.nz>
Date: Mon Apr 7 10:56:18 2014 +1200
Add some removeLayers tests, everything seems to be working.
---
spec/index.html | 3 +-
spec/suites/removeLayersSpec.js | 68 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+), 1 deletion(-)
diff --git a/spec/index.html b/spec/index.html
index 42ad45b..a68feee 100644
--- a/spec/index.html
+++ b/spec/index.html
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
@@ -52,6 +52,7 @@
<script type="text/javascript" src="suites/NonPointSpec.js"></script>
<script type="text/javascript" src="suites/RemoveLayerSpec.js"></script>
+ <script type="text/javascript" src="suites/removeLayersSpec.js"></script>
<script type="text/javascript" src="suites/spiderfySpec.js"></script>
<script type="text/javascript" src="suites/zoomAnimationSpec.js"></script>
diff --git a/spec/suites/removeLayersSpec.js b/spec/suites/removeLayersSpec.js
new file mode 100644
index 0000000..0ff840a
--- /dev/null
+++ b/spec/suites/removeLayersSpec.js
@@ -0,0 +1,68 @@
+describe('removeLayers', 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('removes all the layer given to it', function () {
+
+ var group = new L.MarkerClusterGroup();
+ var markers = [
+ new L.Marker([1.5, 1.5]),
+ new L.Marker([1.5, 1.5]),
+ new L.Marker([1.5, 1.5])
+ ];
+
+ map.addLayer(group);
+
+ group.addLayers(markers);
+
+ group.removeLayers(markers);
+
+ expect(group.hasLayer(markers[0])).to.be(false);
+ expect(group.hasLayer(markers[1])).to.be(false);
+ expect(group.hasLayer(markers[2])).to.be(false);
+
+ expect(group.getLayers().length).to.be(0);
+ });
+
+
+ it('doesnt break if we are spiderfied', function () {
+
+ var group = new L.MarkerClusterGroup();
+ var markers = [
+ new L.Marker([1.5, 1.5]),
+ new L.Marker([1.5, 1.5]),
+ new L.Marker([1.5, 1.5])
+ ];
+
+ map.addLayer(group);
+
+ group.addLayers(markers);
+
+ markers[0].__parent.spiderfy();
+
+ group.removeLayers(markers);
+
+ expect(group.hasLayer(markers[0])).to.be(false);
+ expect(group.hasLayer(markers[1])).to.be(false);
+ expect(group.hasLayer(markers[2])).to.be(false);
+
+ expect(group.getLayers().length).to.be(0);
+ });
+});
\ 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