From d18d6618376245515b33c069dce8ea85d6851d0c Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Sat, 2 Jul 2016 12:16:08 +0200 Subject: [PATCH] More label tests https://github.com/Leaflet/Leaflet/pull/4705/commits/431579ce4a420b981aa8515b88be3d0987730e39 needed to make them pass on Phantom --- spec/suites/layer/LabelSpec.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/spec/suites/layer/LabelSpec.js b/spec/suites/layer/LabelSpec.js index 05c4855a..58c9d3dd 100644 --- a/spec/suites/layer/LabelSpec.js +++ b/spec/suites/layer/LabelSpec.js @@ -62,19 +62,40 @@ describe('Label', function () { expect(spy.calledOnce).to.be(true); }); - // Passes on Firefox, but fails on PhantomJS. - xit("can be forced on left direction", function () { + it.skipInPhantom("can be forced on left direction", function () { var layer = new L.Marker(center).addTo(map); var spy = sinon.spy(); layer.on('click', spy); layer.bindLabel('A long label that should be displayed on the left', {permanent: true, direction: 'left', interactive: true}); expect(map.hasLayer(layer._label)).to.be(true); - happen.at('click', 150, 190); // Marker is on the map center, which is 400px large. + happen.at('click', 150, 180); // Marker is on the map center, which is 400px large. expect(spy.calledOnce).to.be(true); }); - it("can be forced on center", function () { + it.skipInPhantom("can be forced on top direction", function () { + var layer = new L.Marker(center).addTo(map); + var spy = sinon.spy(); + layer.on('click', spy); + + layer.bindLabel('A label that should be displayed on the top', {permanent: true, direction: 'top', interactive: true}); + expect(map.hasLayer(layer._label)).to.be(true); + happen.at('click', 200, 170); // Marker is on the map center, which is 400px large. + expect(spy.calledOnce).to.be(true); + }); + + it.skipInPhantom("can be forced on bottom direction", function () { + var layer = new L.Marker(center).addTo(map); + var spy = sinon.spy(); + layer.on('click', spy); + + layer.bindLabel('A label that should be displayed on the top', {permanent: true, direction: 'bottom', interactive: true}); + expect(map.hasLayer(layer._label)).to.be(true); + happen.at('click', 200, 210); // Marker is on the map center, which is 400px large. + expect(spy.calledOnce).to.be(true); + }); + + it.skipInPhantom("can be forced on center", function () { var layer = new L.Marker(center).addTo(map); var spy = sinon.spy(); layer.on('click', spy);