Tests for adding an individual marker and having it now show up.

This commit is contained in:
danzel
2013-06-14 14:14:41 +12:00
parent fc39349b3f
commit fc9d8953ca
2 changed files with 78 additions and 0 deletions
+2
View File
@@ -28,7 +28,9 @@
<!-- spec files -->
<script type="text/javascript" src="suites/SpecHelper.js"></script>
<script type="text/javascript" src="suites/LeafletSpec.js"></script>
<script type="text/javascript" src="suites/AddLayerSpec.js"></script>
<script>
+76
View File
@@ -0,0 +1,76 @@
describe('addLayer', 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('adds an individual marker that is added before the group is added to the map', function () {
var group = new L.MarkerClusterGroup();
var marker = new L.Marker([1.5, 1.5]);
group.addLayer(marker);
map.addLayer(group);
expect(marker._icon).to.not.be(undefined);
expect(marker._icon.parentNode).to.be(map._panes.markerPane);
});
it('adds an individual marker that is added after the group is added to the map', function () {
var group = new L.MarkerClusterGroup();
var marker = new L.Marker([1.5, 1.5]);
map.addLayer(group);
group.addLayer(marker);
expect(marker._icon).to.not.be(undefined);
expect(marker._icon.parentNode).to.be(map._panes.markerPane);
});
it('adds (using animations) an individual marker that is added after the group is added to the map', function () {
var group = new L.MarkerClusterGroup({ animateAddingMarkers: true });
var marker = new L.Marker([1.5, 1.5]);
map.addLayer(group);
group.addLayer(marker);
expect(marker._icon).to.not.be(undefined);
expect(marker._icon.parentNode).to.be(map._panes.markerPane);
});
it('does not add an individual marker that is too far away that is added before the group is added to the map', function () {
var group = new L.MarkerClusterGroup();
var marker = new L.Marker([3.5, 1.5]);
group.addLayer(marker);
map.addLayer(group);
expect(marker._icon).to.be(undefined);
});
it('does not add an individual marker that is too far away that is added after the group is added to the map', function () {
var group = new L.MarkerClusterGroup();
var marker = new L.Marker([3.5, 1.5]);
map.addLayer(group);
group.addLayer(marker);
expect(marker._icon).to.be(undefined);
});
});