Add a test to reproduce #141, but it doesn't break.

This commit is contained in:
danzel
2013-06-14 16:33:43 +12:00
parent 9152c2aaba
commit db8ed41c9a
2 changed files with 63 additions and 15 deletions
+18 -15
View File
@@ -1,14 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta charset="utf-8">
<title>Spec Runner</title>
<link rel="stylesheet" type="text/css" href="../node_modules/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script src="expect.js"></script>
<script type="text/javascript" src="../node_modules/mocha/mocha.js"></script>
<div id="mocha"></div>
<script src="expect.js"></script>
<script type="text/javascript" src="../node_modules/mocha/mocha.js"></script>
<script type="text/javascript" src="happen.js"></script>
<script type="text/javascript" src="sinon.js"></script>
<script type="text/javascript" src="../node_modules/leaflet/dist/leaflet-src.js"></script>
@@ -20,29 +20,32 @@
<script type="text/javascript" src="../src/MarkerCluster.QuickHull.js"></script>
<script type="text/javascript" src="../src/MarkerCluster.Spiderfier.js"></script>
<script>
mocha.setup('bdd');
mocha.ignoreLeaks();
</script>
<script>
mocha.setup('bdd');
mocha.ignoreLeaks();
</script>
<!-- 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/AddLayer.SingleSpec.js"></script>
<script type="text/javascript" src="suites/AddLayer.MultipleSpec.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/CircleMarkerSupportSpec.js"></script>
<script type="text/javascript" src="suites/CircleSupportSpec.js"></script>
<script>
(window.mochaPhantomJS || window.mocha).run();
</script>
<script type="text/javascript" src="suites/ChildChangingIconSupportSpec.js"></script>
<script>
(window.mochaPhantomJS || window.mocha).run();
</script>
</body>
</html>
@@ -0,0 +1,45 @@
describe('support child markers changing icon', 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('child markers end up with the right icon after becoming unclustered', function () {
var group = new L.MarkerClusterGroup();
var marker = new L.Marker([1.5, 1.5], { icon: new L.DivIcon({html: 'Inner1Text' }) });
var marker2 = new L.Marker([1.5, 1.5]);
map.addLayer(group);
group.addLayer(marker);
expect(marker._icon.parentNode).to.be(map._panes.markerPane);
expect(marker._icon.innerHTML).to.contain('Inner1Text');
group.addLayer(marker2);
expect(marker._icon).to.be(null); //Have been removed from the map
marker.setIcon(new L.DivIcon({ html: 'Inner2Text' })); //Change the icon
group.removeLayer(marker2); //Remove the other marker, so we'll become unclustered
expect(marker._icon.innerHTML).to.contain('Inner2Text');
});
});