From 99c56a1f08d88175a1dc4fd2d9595c67e990f718 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Thu, 26 Sep 2019 23:42:44 +0200 Subject: [PATCH] Additional tests for LineString --- test/spec/ol/geom/linestring.test.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/spec/ol/geom/linestring.test.js b/test/spec/ol/geom/linestring.test.js index 8c7b73d897..25e28493cd 100644 --- a/test/spec/ol/geom/linestring.test.js +++ b/test/spec/ol/geom/linestring.test.js @@ -73,6 +73,12 @@ describe('ol.geom.LineString', function() { expect(lineString.getStride()).to.be(2); }); + describe('#intersectsCoordinate', function() { + it('returns true for an intersecting coordinate', function() { + expect(lineString.intersectsCoordinate([1.5, 2.5])).to.be(true); + }); + }); + describe('#intersectsExtent', function() { it('return false for non matching extent', function() { @@ -89,6 +95,23 @@ describe('ol.geom.LineString', function() { }); + describe('#intersectsCoordinate', function() { + + it('detects intersecting coordinates', function() { + expect(lineString.intersectsCoordinate([1, 2])).to.be(true); + }); + + }); + + describe('#getClosestPoint', function() { + + it('uses existing vertices', function() { + const closestPoint = lineString.getClosestPoint([0.9, 1.8]); + expect(closestPoint).to.eql([1, 2]); + }); + + }); + describe('#getCoordinateAt', function() { it('return the first point when fraction is 0', function() {