Платформа ЦРНП "Мирокод" для разработки проектов
https://git.mirocod.ru
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.5 KiB
51 lines
1.5 KiB
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()); |
|
}); |
|
}); |
|
|
|
describe("#remove", function () { |
|
it("removes the container from the map", function () { |
|
var control = new L.Control(); |
|
control.onAdd = onAdd; |
|
control.addTo(map).remove(); |
|
expect(map.getContainer().querySelector('.leaflet-test-control')).to.equal(null); |
|
}); |
|
|
|
it("calls onRemove if defined", function () { |
|
var control = new L.Control(); |
|
control.onAdd = onAdd; |
|
control.onRemove = sinon.spy(); |
|
control.addTo(map).remove(); |
|
expect(control.onRemove.called).to.be(true); |
|
}); |
|
|
|
it("is a no-op if the control has not been added", function () { |
|
var control = new L.Control(); |
|
expect(control.remove()).to.equal(control); |
|
}); |
|
}); |
|
});
|
|
|