Add hasLayer tests

This commit is contained in:
John Firebaugh 2013-12-13 17:51:37 -05:00
parent 5e0d343501
commit c1654c4626
2 changed files with 22 additions and 0 deletions

View File

@ -1,4 +1,13 @@
describe('LayerGroup', function () {
describe("#hasLayer", function () {
it("returns false when passed undefined, null, or false", function () {
var lg = L.layerGroup();
expect(lg.hasLayer(undefined)).to.equal(false);
expect(lg.hasLayer(null)).to.equal(false);
expect(lg.hasLayer(false)).to.equal(false);
});
});
describe("#addLayer", function () {
it('adds a layer', function () {
var lg = L.layerGroup(),
@ -9,6 +18,7 @@
expect(lg.hasLayer(marker)).to.be(true);
});
});
describe("#removeLayer", function () {
it('removes a layer', function () {
var lg = L.layerGroup(),
@ -20,6 +30,7 @@
expect(lg.hasLayer(marker)).to.be(false);
});
});
describe("#clearLayers", function () {
it('removes all layers', function () {
var lg = L.layerGroup(),
@ -31,6 +42,7 @@
expect(lg.hasLayer(marker)).to.be(false);
});
});
describe("#getLayers", function () {
it('gets all layers', function () {
var lg = L.layerGroup(),
@ -41,6 +53,7 @@
expect(lg.getLayers()).to.eql([marker]);
});
});
describe("#eachLayer", function () {
it('iterates over all layers', function () {
var lg = L.layerGroup(),

View File

@ -199,6 +199,15 @@ describe("Map", function () {
});
});
describe("#hasLayer", function () {
it("returns false when passed undefined, null, or false", function () {
var map = L.map(document.createElement('div'));
expect(map.hasLayer(undefined)).to.equal(false);
expect(map.hasLayer(null)).to.equal(false);
expect(map.hasLayer(false)).to.equal(false);
});
});
function layerSpy() {
var layer = new L.Layer();
layer.onAdd = sinon.spy();