add icon popupAnchor option test for nonPhantom browsers (#5865)

This commit is contained in:
Andrew 2017-10-23 15:29:28 +02:00 committed by Per Liedman
parent 919ead4288
commit 7e5cbceaa5

View File

@ -194,18 +194,34 @@ describe('Popup', function () {
expect(spy.callCount).to.be(2);
});
it("should take into account icon popupAnchor option", function () {
var autoPanBefore = L.Popup.prototype.options.autoPan;
describe('should take into account icon popupAnchor option on', function () {
var latlng = new L.LatLng(55.8, 37.6);
var offset = new L.Point(20, 30);
var autoPanBefore;
var popupAnchorBefore;
var icon;
var marker1;
var marker2;
before(function () {
autoPanBefore = L.Popup.prototype.options.autoPan;
L.Popup.prototype.options.autoPan = false;
var popupAnchorBefore = L.Icon.Default.prototype.options.popupAnchor;
popupAnchorBefore = L.Icon.Default.prototype.options.popupAnchor;
L.Icon.Default.prototype.options.popupAnchor = [0, 0];
});
var latlng = new L.LatLng(55.8, 37.6),
offset = new L.Point(20, 30),
icon = new L.DivIcon({popupAnchor: offset}),
marker1 = new L.Marker(latlng),
beforeEach(function () {
icon = new L.DivIcon({popupAnchor: offset});
marker1 = new L.Marker(latlng);
marker2 = new L.Marker(latlng, {icon: icon});
});
after(function () {
L.Popup.prototype.options.autoPan = autoPanBefore;
L.Icon.Default.prototype.options.popupAnchor = popupAnchorBefore;
});
it.skipInNonPhantom("non-any3d browsers", function () {
marker1.bindPopup('Popup').addTo(map);
marker1.openPopup();
var defaultLeft = parseInt(marker1._popup._container.style.left, 10);
@ -224,9 +240,28 @@ describe('Popup', function () {
offsetBottom = parseInt(marker2._popup._container.style.bottom, 10);
expect(offsetLeft - offset.x).to.eql(defaultLeft);
expect(offsetBottom + offset.y).to.eql(defaultBottom);
});
L.Popup.prototype.options.autoPan = autoPanBefore;
L.Icon.Default.prototype.options.popupAnchor = popupAnchorBefore;
it.skipInPhantom("any3d browsers", function () {
marker1.bindPopup('Popup').addTo(map);
marker1.openPopup();
var defaultLeft = marker1._popup._container._leaflet_pos.x;
var defaultTop = marker1._popup._container._leaflet_pos.y;
marker2.bindPopup('Popup').addTo(map);
marker2.openPopup();
var offsetLeft = marker2._popup._container._leaflet_pos.x;
var offsetTop = marker2._popup._container._leaflet_pos.y;
expect(offsetLeft - offset.x).to.eql(defaultLeft);
expect(offsetTop - offset.y).to.eql(defaultTop);
// Now retry passing a popup instance to bindPopup
marker2.bindPopup(new L.Popup());
marker2.openPopup();
offsetLeft = marker2._popup._container._leaflet_pos.x;
offsetTop = marker2._popup._container._leaflet_pos.y;
expect(offsetLeft - offset.x).to.eql(defaultLeft);
expect(offsetTop - offset.y).to.eql(defaultTop);
});
});
it("prevents an underlying map click for Layer", function () {