Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add layerGroup#getLayers and tests. Fixes #1460
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
describe('LayerGroup', function () { | ||
describe("#addLayer", function () { | ||
it('adds a layer', function() { | ||
var lg = L.layerGroup(), | ||
marker = L.marker([0, 0]); | ||
|
||
expect(lg.addLayer(marker)).toEqual(lg); | ||
|
||
expect(lg.hasLayer(marker)).toBe(true); | ||
}); | ||
}); | ||
describe("#removeLayer", function () { | ||
it('removes a layer', function() { | ||
var lg = L.layerGroup(), | ||
marker = L.marker([0, 0]); | ||
|
||
lg.addLayer(marker); | ||
expect(lg.removeLayer(marker)).toEqual(lg); | ||
|
||
expect(lg.hasLayer(marker)).toBe(false); | ||
}); | ||
}); | ||
describe("#clearLayers", function () { | ||
it('removes all layers', function() { | ||
var lg = L.layerGroup(), | ||
marker = L.marker([0, 0]); | ||
|
||
lg.addLayer(marker); | ||
expect(lg.clearLayers()).toEqual(lg); | ||
|
||
expect(lg.hasLayer(marker)).toBe(false); | ||
}); | ||
}); | ||
describe("#getLayers", function () { | ||
it('gets all layers', function() { | ||
var lg = L.layerGroup(), | ||
marker = L.marker([0, 0]); | ||
|
||
lg.addLayer(marker); | ||
|
||
expect(lg.getLayers()).toEqual([marker]); | ||
}); | ||
}); | ||
describe("#eachLayer", function () { | ||
it('iterates over all layers', function() { | ||
var lg = L.layerGroup(), | ||
marker = L.marker([0, 0]), | ||
ctx = { foo: 'bar' }; | ||
|
||
lg.addLayer(marker); | ||
|
||
lg.eachLayer(function(layer) { | ||
expect(layer).toEqual(marker); | ||
expect(this).toEqual(ctx); | ||
}, ctx); | ||
}); | ||
}); | ||
}); |
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