30 lines
864 B
JavaScript
30 lines
864 B
JavaScript
|
describe("Control", function () {
|
||
|
var map;
|
||
|
|
||
|
beforeEach(function () {
|
||
|
map = L.map(document.createElement('div'));
|
||
|
});
|
||
|
|
||
|
function onAdd() {
|
||
|
return L.DomUtil.create('div', 'leaflet-test-control');
|
||
|
}
|
||
|
|
||
|
describe("#addTo", function () {
|
||
|
it("adds the container to the map", function () {
|
||
|
var control = new L.Control();
|
||
|
control.onAdd = onAdd;
|
||
|
control.addTo(map);
|
||
|
expect(map.getContainer().querySelector('.leaflet-test-control')).to.equal(control.getContainer());
|
||
|
});
|
||
|
|
||
|
it("removes the control from any existing map", function () {
|
||
|
var control = new L.Control();
|
||
|
control.onAdd = onAdd;
|
||
|
control.addTo(map);
|
||
|
control.addTo(map);
|
||
|
expect(map.getContainer().querySelectorAll('.leaflet-test-control').length).to.equal(1);
|
||
|
expect(map.getContainer().querySelector('.leaflet-test-control')).to.equal(control.getContainer());
|
||
|
});
|
||
|
});
|
||
|
});
|