From abb254a0fb000773952849ac05c1fab7fb04087a Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Fri, 22 Jun 2012 17:51:28 +0200 Subject: [PATCH] Test the getCentroid/centroid Method of multipoints --- test/spec/api/geom/multipoint.test.js | 16 ++++++++++++++++ test/spec/ol/geom/MultiPoint.test.js | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/test/spec/api/geom/multipoint.test.js b/test/spec/api/geom/multipoint.test.js index a7e409500c..6d955e86ef 100644 --- a/test/spec/api/geom/multipoint.test.js +++ b/test/spec/api/geom/multipoint.test.js @@ -217,6 +217,22 @@ describe("ol.geom.multipoint", function() { expect(mp.points().length).toBe(0); }); }); + + describe("the centroid method is functional", function(){ + it("returns an instance of ol.geom.Point", function(){ + expect(mp.centroid()).toBeA(ol.geom.Point); + }); + + it("has the expected coordinates", function(){ + mp.points([ + new ol.geom.Point(10,10), + new ol.geom.Point(20,20), + new ol.geom.Point(30,30) + ]); + var c = mp.centroid(); + expect(c.x() + ',' + c.y()).toBe('20,20'); + }); + }); }); diff --git a/test/spec/ol/geom/MultiPoint.test.js b/test/spec/ol/geom/MultiPoint.test.js index ab8d35437e..72879491e5 100644 --- a/test/spec/ol/geom/MultiPoint.test.js +++ b/test/spec/ol/geom/MultiPoint.test.js @@ -122,4 +122,20 @@ describe("ol.geom.MultiPoint", function() { expect( points[1].getX() + ',' + points[1].getY()).toBe( '10,20' ); expect( points[2].getX() + ',' + points[2].getY()).toBe( '30,40' ); }); + + describe("the getCentroid method is functional", function(){ + it("returns an instance of ol.geom.Point", function(){ + expect(mp.getCentroid()).toBeA(ol.geom.Point); + }); + + it("has the expected coordinates", function(){ + mp.setPoints([ + new ol.geom.Point(10,10), + new ol.geom.Point(20,20), + new ol.geom.Point(30,30) + ]); + var c = mp.getCentroid(); + expect(c.getX() + ',' + c.getY()).toBe('20,20'); + }); + }); });