From f0e6ec66596de7d8bad6d76d5491b4441195a90b Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Thu, 17 Jan 2013 13:53:52 -0500 Subject: [PATCH] Finish tests for new geo functionality --- test/spec/util.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/spec/util.js b/test/spec/util.js index 3ac1cdda2..2cfa8dc16 100644 --- a/test/spec/util.js +++ b/test/spec/util.js @@ -92,5 +92,25 @@ describe('Util', function() { expect(iD.util.geo.polygonContainsPolygon(outer, inner)).to.be.false; }); }); + + describe('#polygonIntersectsPolygon', function() { + it('says a polygon in a polygon intersects it', function() { + var outer = [[0, 0], [0, 3], [3, 3], [3, 0], [0, 0]]; + var inner = [[1, 1], [1, 2], [2, 2], [2, 1], [1, 1]]; + expect(iD.util.geo.polygonIntersectsPolygon(outer, inner)).to.be.true; + }); + + it('says a polygon that partially intersects does', function() { + var outer = [[0, 0], [0, 3], [3, 3], [3, 0], [0, 0]]; + var inner = [[-1, -1], [1, 2], [2, 2], [2, 1], [1, 1]]; + expect(iD.util.geo.polygonIntersectsPolygon(outer, inner)).to.be.true; + }); + + it('says totally disjoint polygons do not intersect', function() { + var outer = [[0, 0], [0, 3], [3, 3], [3, 0], [0, 0]]; + var inner = [[-1, -1], [-1, -2], [-2, -2], [-2, -1], [-1, -1]]; + expect(iD.util.geo.polygonIntersectsPolygon(outer, inner)).to.be.false; + }); + }); }); });