[Pkg-javascript-commits] [leaflet-markercluster] 392/479: Add some tests for events. Refs #200
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 6694a00fad2e447734212934a05ee86b3c699443
Author: danzel <danzel at localhost.geek.nz>
Date: Mon Jun 24 10:23:16 2013 +1200
Add some tests for events. Refs #200
---
spec/index.html | 11 +++--
spec/suites/eventsSpec.js | 102 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 110 insertions(+), 3 deletions(-)
diff --git a/spec/index.html b/spec/index.html
index 5f46790..f9a9418 100644
--- a/spec/index.html
+++ b/spec/index.html
@@ -31,18 +31,23 @@
<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/AddLayer.SingleSpec.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/ChildChangingIconSupportSpec.js"></script>
<script type="text/javascript" src="suites/CircleMarkerSupportSpec.js"></script>
<script type="text/javascript" src="suites/CircleSupportSpec.js"></script>
- <script type="text/javascript" src="suites/ChildChangingIconSupportSpec.js"></script>
+ <script type="text/javascript" src="suites/clearLayersSpec.js"></script>
+ <script type="text/javascript" src="suites/eachLayerSpec.js"></script>
+ <script type="text/javascript" src="suites/eventsSpec.js"></script>
+ <script type="text/javascript" src="suites/getBoundsSpec.js"></script>
+ <script type="text/javascript" src="suites/NonPointSpec.js"></script>
+ <script type="text/javascript" src="suites/RemoveLayerSpec.js"></script>
<script>
(window.mochaPhantomJS || window.mocha).run();
diff --git a/spec/suites/eventsSpec.js b/spec/suites/eventsSpec.js
new file mode 100644
index 0000000..175642e
--- /dev/null
+++ b/spec/suites/eventsSpec.js
@@ -0,0 +1,102 @@
+describe('events', 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('is fired for a single child marker', function () {
+ var callback = sinon.spy();
+ var group = new L.MarkerClusterGroup();
+
+ var marker = new L.Marker([1.5, 1.5]);
+
+ group.on('click', callback);
+ group.addLayer(marker);
+ map.addLayer(group);
+
+ marker.fire('click');
+
+ expect(callback.called).to.be(true);
+ });
+
+ it('is fired for a child polygon', function () {
+ var callback = sinon.spy();
+ 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.on('click', callback);
+ group.addLayer(polygon);
+ map.addLayer(group);
+
+ polygon.fire('click');
+
+ expect(callback.called).to.be(true);
+ });
+
+ it('fires events for nonpoint data after being removed and re-added to the map', function () {
+ var callback = sinon.spy();
+ 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.on('click', callback);
+ group.addLayer(polygon);
+ map.addLayer(group);
+ map.removeLayer(group);
+ map.addLayer(group);
+
+ polygon.fire('click');
+
+ expect(callback.called).to.be(true);
+ });
+
+ it('fires events for point data after being removed and re-added to the map', function () {
+ var callback = sinon.spy();
+ var group = new L.MarkerClusterGroup();
+
+ var marker = new L.Marker([1.5, 1.5]);
+
+ group.on('click', callback);
+ group.addLayer(marker);
+ map.addLayer(group);
+ map.removeLayer(group);
+ map.addLayer(group);
+
+ marker.fire('click');
+
+ expect(callback.called).to.be(true);
+ });
+
+ /*
+ //No normal events can be fired by a clustered marker, so probably don't need this.
+ it('is fired for a clustered child marker', function() {
+ var callback = sinon.spy();
+ var group = new L.MarkerClusterGroup();
+
+ var marker = new L.Marker([1.5, 1.5]);
+ var marker2 = new L.Marker([1.5, 1.5]);
+
+ group.on('click', callback);
+ group.addLayers([marker, marker2]);
+ map.addLayer(group);
+
+ marker.fire('click');
+
+ expect(callback.called).to.be(true);
+ });
+ */
+});
\ 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