More tests for #200, this was really bugged!

This commit is contained in:
danzel
2013-06-24 10:23:33 +12:00
parent 6694a00fad
commit 21580cc066
+59 -2
View File
@@ -47,7 +47,27 @@
expect(callback.called).to.be(true);
});
it('fires events for nonpoint data after being removed and re-added to the map', function () {
it('is fired for a cluster click', 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('clusterclick', callback);
group.addLayers([marker, marker2]);
map.addLayer(group);
var cluster = group.getVisibleParent(marker);
expect(cluster instanceof L.MarkerCluster).to.be(true);
cluster.fire('click');
expect(callback.called).to.be(true);
});
describe('after being added, removed, re-added from the map', function() {
it('still fires events for nonpoint data', function() {
var callback = sinon.spy();
var group = new L.MarkerClusterGroup();
@@ -64,7 +84,7 @@
expect(callback.called).to.be(true);
});
it('fires events for point data after being removed and re-added to the map', function () {
it('still fires events for point data', function() {
var callback = sinon.spy();
var group = new L.MarkerClusterGroup();
@@ -81,6 +101,43 @@
expect(callback.called).to.be(true);
});
it('still fires cluster events', 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('clusterclick', callback);
group.addLayers([marker, marker2]);
map.addLayer(group);
map.removeLayer(group);
map.addLayer(group);
var cluster = group.getVisibleParent(marker);
expect(cluster instanceof L.MarkerCluster).to.be(true);
cluster.fire('click');
expect(callback.called).to.be(true);
});
it('doesnt break map events', function () {
var callback = sinon.spy();
var group = new L.MarkerClusterGroup();
map.on('zoomend', callback);
map.addLayer(group);
map.removeLayer(group);
map.addLayer(group);
map.fire('zoomend');
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() {