Test the getCentroid/centroid Method of multipoints

This commit is contained in:
Marc Jansen
2012-06-22 17:51:28 +02:00
parent 2fffa0293d
commit abb254a0fb
2 changed files with 32 additions and 0 deletions

View File

@@ -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');
});
});
});

View File

@@ -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');
});
});
});