From db8ed41c9a6335ae8523cbdaf00888461081ac73 Mon Sep 17 00:00:00 2001 From: danzel Date: Fri, 14 Jun 2013 16:33:43 +1200 Subject: [PATCH] Add a test to reproduce #141, but it doesn't break. --- spec/index.html | 33 ++++++++------- spec/suites/ChildChangingIconSupportSpec.js | 45 +++++++++++++++++++++ 2 files changed, 63 insertions(+), 15 deletions(-) create mode 100644 spec/suites/ChildChangingIconSupportSpec.js diff --git a/spec/index.html b/spec/index.html index 1d378b6d1..5f467904a 100644 --- a/spec/index.html +++ b/spec/index.html @@ -1,14 +1,14 @@ - + Spec Runner -
- - +
+ + @@ -20,29 +20,32 @@ - + - + - + - + - - + + + + + diff --git a/spec/suites/ChildChangingIconSupportSpec.js b/spec/suites/ChildChangingIconSupportSpec.js new file mode 100644 index 000000000..2814a1606 --- /dev/null +++ b/spec/suites/ChildChangingIconSupportSpec.js @@ -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'); + }); +}); \ No newline at end of file