-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix getVisibleParent when no parent is visible. Add tests for getVisi…
…bleParent. Fixes #265
- Loading branch information
Showing
4 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
describe('getVisibleParent', 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('gets the marker if the marker is visible', function () { | ||
var group = new L.MarkerClusterGroup(); | ||
var marker = new L.Marker([1.5, 1.5]); | ||
|
||
group.addLayer(marker); | ||
map.addLayer(group); | ||
|
||
var vp = group.getVisibleParent(marker); | ||
|
||
expect(vp).to.be(marker); | ||
}); | ||
|
||
it('gets the visible cluster if it is clustered', function () { | ||
var group = new L.MarkerClusterGroup(); | ||
var marker = new L.Marker([1.5, 1.5]); | ||
var marker2 = new L.Marker([1.5, 1.5]); | ||
|
||
group.addLayers([marker, marker2]); | ||
map.addLayer(group); | ||
|
||
var vp = group.getVisibleParent(marker); | ||
|
||
expect(vp).to.be.a(L.MarkerCluster); | ||
expect(vp._icon).to.not.be(null); | ||
expect(vp._icon).to.not.be(undefined); | ||
}); | ||
|
||
it('returns null if the marker and parents are all not visible', function () { | ||
var group = new L.MarkerClusterGroup(); | ||
var marker = new L.Marker([5.5, 1.5]); | ||
var marker2 = new L.Marker([5.5, 1.5]); | ||
|
||
group.addLayers([marker, marker2]); | ||
map.addLayer(group); | ||
|
||
var vp = group.getVisibleParent(marker); | ||
|
||
expect(vp).to.be(null); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters