remove the old tests

This commit is contained in:
Éric Lemoine
2012-09-24 18:12:51 +02:00
parent 002e23cb74
commit baeddfac12
38 changed files with 0 additions and 4838 deletions

View File

@@ -1,179 +0,0 @@
describe("ol.geom.Collection", function() {
var c;
beforeEach(function(){
c = new ol.geom.Collection([
new ol.geom.Point(10,20),
new ol.geom.LineString([
new ol.geom.Point(47,11),
new ol.geom.Point(3.14,2.8)
])
]);
});
afterEach(function(){
c = null;
});
it("constructs instances", function() {
expect( c ).toBeA( ol.geom.Collection );
});
it("can construct instances without any components", function() {
// empty array
c = new ol.geom.Collection([]);
expect( c ).toBeA( ol.geom.Collection );
// no argument at all
c = new ol.geom.Collection();
expect( c ).toBeA( ol.geom.Collection );
});
it("cannot construct instances when passed illegal components", function() {
// collection cannot contain collections
expect(function(){
c = new ol.geom.Collection([
new ol.geom.Collection()
]);
}).toThrow();
});
it("inherits from ol.geom.Geometry", function() {
expect( c ).toBeA( ol.geom.Geometry );
});
it("has a working getter for components", function() {
var components = c.getComponents();
expect( components ).toBeA( Array );
expect( components.length ).toBe( 2 );
expect( components[0] ).toBeA( ol.geom.Point );
expect( components[1] ).toBeA( ol.geom.LineString );
expect( components[0].getX() + ',' + components[0].getY()).toBe( '10,20' );
expect( components[1].getVertices()[0].getX() + ',' + components[1].getVertices()[0].getY()).toBe( '47,11' );
});
it("has a working setter for components", function() {
c.setComponents([
new ol.geom.Point(30,40),
new ol.geom.LineString([
new ol.geom.Point(3,9),
new ol.geom.Point(4,16)
])
]);
var components = c.getComponents();
expect( components.length ).toBe( 2 );
expect( components[0] ).toBeA( ol.geom.Point );
expect( components[1] ).toBeA( ol.geom.LineString );
expect( components[0].getX() + ',' + components[0].getY()).toBe( '30,40' );
expect( components[1].getVertices()[0].getX() + ',' + components[1].getVertices()[0].getY()).toBe( '3,9' );
});
it("has a method to add components", function() {
c.addComponent(
new ol.geom.Point(30,40),
1
);
c.addComponent(
new ol.geom.LineString([
new ol.geom.Point(5,25),
new ol.geom.Point(6,36)
]),
0
);
var components = c.getComponents();
expect( components.length ).toBe( 4 );
expect( components[0].getVertices()[0].getX() + ',' + components[0].getVertices()[0].getY()).toBe( '5,25' );
expect( components[1].getX() + ',' + components[1].getY()).toBe( '10,20' );
expect( components[2].getX() + ',' + components[2].getY()).toBe( '30,40' );
expect( components[3].getVertices()[0].getX() + ',' + components[3].getVertices()[0].getY()).toBe( '47,11' );
});
it("cannot add instances of 'ol.geom.Collection'", function(){
expect(function(){
c.addComponent(
new ol.geom.Collection([
new ol.geom.Point(5,25),
new ol.geom.Point(6,36)
])
);
}).toThrow();
});
it("allows instances of 'ol.geom.Multi*' (even though these are subclasses of ol.geom.Collection)", function(){
expect(function(){
c.addComponent(
new ol.geom.MultiPoint([
new ol.geom.Point(5,25),
new ol.geom.Point(6,36)
])
);
}).not.toThrow();
});
it("has a method to remove components", function() {
c.setComponents([
new ol.geom.Point(0,10),
new ol.geom.Point(10,20),
new ol.geom.Point(20,30),
new ol.geom.Point(30,40)
]);
var p = c.getComponents()[2]; // 20,30;
c.removeComponent( p );
var components = c.getComponents();
expect( components.length ).toBe( 3 );
expect( components[0].getX() + ',' + components[0].getY()).toBe( '0,10' );
expect( components[1].getX() + ',' + components[1].getY()).toBe( '10,20' );
expect( components[2].getX() + ',' + components[2].getY()).toBe( '30,40' );
});
describe("the getCentroid method is functional", function(){
it("returns an instance of ol.geom.Point", function(){
expect(c.getCentroid()).toBeA(ol.geom.Point);
});
it("does not choke when components returns a null centroid", function(){
var centroid;
expect(
function(){
c.addComponent(new ol.geom.LineString([]));
centroid = c.getCentroid();
}
).not.toThrow();
expect(centroid).toBeA(ol.geom.Point);
});
it("has the expected coordinates", function(){
c = new ol.geom.Collection([
new ol.geom.Point(10,10),
new ol.geom.Point(30,30),
new ol.geom.LineString([
new ol.geom.Point(10,10),
new ol.geom.Point(10,30),
new ol.geom.Point(30,30),
new ol.geom.Point(30,10)
])
]);
var centroid = c.getCentroid();
expect(centroid.getX() + ',' + centroid.getY()).toBe('20,20');
});
});
});

View File

@@ -1,131 +0,0 @@
describe("ol.geom.LineString", function() {
var ls;
beforeEach(function(){
ls = new ol.geom.LineString([
new ol.geom.Point(0,0),
new ol.geom.Point(10,10),
new ol.geom.Point(10,0),
new ol.geom.Point(20,20)
]);
});
afterEach(function(){
ls = null;
});
it("constructs instances", function() {
expect( ls ).toBeA( ol.geom.LineString );
});
it("can construct instances without any points", function() {
// empty array
mp = new ol.geom.LineString([]);
expect( ls ).toBeA( ol.geom.LineString );
// no argument at all
mp = new ol.geom.LineString();
expect( ls ).toBeA( ol.geom.LineString );
});
it("inherits from ol.geom.Geometry", function() {
expect( ls ).toBeA( ol.geom.Geometry );
});
it("has a working getter for vertices", function() {
var vertices = ls.getVertices();
expect( vertices ).toBeA( Array );
expect( vertices.length ).toBe( 4 );
expect( vertices[0] ).toBeA( ol.geom.Point );
expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '0,0' );
});
it("has a working setter for vertices", function() {
ls.setVertices([
new ol.geom.Point(30,40),
new ol.geom.Point(50,60)
]);
var vertices = ls.getVertices();
expect( vertices.length ).toBe( 2 );
expect( vertices[0] ).toBeA( ol.geom.Point );
expect( vertices[1] ).toBeA( ol.geom.Point );
expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '30,40' );
expect( vertices[1].getX() + ',' + vertices[1].getY()).toBe( '50,60' );
});
it("has a method to add vertices", function() {
ls.addVertex(
new ol.geom.Point(30,40),
1
);
ls.addVertex(
new ol.geom.Point(50,60),
2
);
ls.addVertex(
new ol.geom.Point(-10,0),
0
);
var vertices = ls.getVertices();
expect( vertices.length ).toBe( 7 );
expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '-10,0' );
expect( vertices[1].getX() + ',' + vertices[1].getY()).toBe( '0,0' );
expect( vertices[2].getX() + ',' + vertices[2].getY()).toBe( '30,40' );
expect( vertices[3].getX() + ',' + vertices[3].getY()).toBe( '50,60' );
expect( vertices[4].getX() + ',' + vertices[4].getY()).toBe( '10,10' );
expect( vertices[5].getX() + ',' + vertices[5].getY()).toBe( '10,0' );
expect( vertices[6].getX() + ',' + vertices[6].getY()).toBe( '20,20' );
});
it("has a method to remove vertices", function() {
ls.setVertices([
new ol.geom.Point(0,10),
new ol.geom.Point(10,20),
new ol.geom.Point(20,30),
new ol.geom.Point(30,40)
]);
var v = ls.getVertices()[2]; // 20,30;
ls.removeVertex( v );
var vertices = ls.getVertices();
expect( vertices.length ).toBe( 3 );
expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '0,10' );
expect( vertices[1].getX() + ',' + vertices[1].getY()).toBe( '10,20' );
expect( vertices[2].getX() + ',' + vertices[2].getY()).toBe( '30,40' );
});
describe("the getCentroid method is functional", function(){
it("returns an instance of ol.geom.Point", function(){
expect(ls.getCentroid()).toBeA(ol.geom.Point);
});
it("has the expected coordinates", function(){
ls.setVertices([
new ol.geom.Point(0.5, 1),
new ol.geom.Point(1, 1.5),
new ol.geom.Point(1.5, 1),
new ol.geom.Point(1, 0.5)
]);
var c = ls.getCentroid();
expect(c.getX() + ',' + c.getY()).toBe('1,1');
});
});
});

View File

@@ -1,229 +0,0 @@
describe("ol.geom.MultiLineString", function() {
var mls,
formatPoint = function(p){
return p.getX() + ',' + p.getY();
},
linestringNPointN = function(mls, i, j) {
return formatPoint(mls.getLineStrings()[i].getVertices()[j]);
};
beforeEach(function(){
mls = new ol.geom.MultiLineString([
new ol.geom.LineString([
new ol.geom.Point(10,10),
new ol.geom.Point(10,0),
new ol.geom.Point(20,20)
]),
new ol.geom.LineString([
new ol.geom.Point(30,10),
new ol.geom.Point(30,0),
new ol.geom.Point(40,20)
])
]);
});
afterEach(function(){
mls = null;
});
it("constructs instances", function() {
expect( mls ).toBeA( ol.geom.MultiLineString );
});
it("can construct instances without any linestrings", function() {
// empty array
mls = new ol.geom.MultiLineString([]);
expect( mls ).toBeA( ol.geom.MultiLineString );
// no argument at all
mls = new ol.geom.MultiLineString();
expect( mls ).toBeA( ol.geom.MultiLineString );
});
it("cannot be constructed with component-types other than 'ol.geom.Point'", function() {
expect(function(){
mls = new ol.geom.MultiLineString([
new ol.geom.Point()
]);
}).toThrow();
expect(function(){
mls = new ol.geom.MultiLineString([
new ol.geom.MultiPoint([
new ol.geom.Point()
])
]);
}).toThrow();
});
it("inherits from ol.geom.Geometry", function() {
expect( mls ).toBeA( ol.geom.Geometry );
});
it("has a working getter for linestrings", function() {
var linestrings = mls.getLineStrings();
expect( linestrings ).toBeA( Array );
expect( linestrings.length ).toBe( 2 );
expect( linestrings[0] ).toBeA( ol.geom.LineString );
expect( linestringNPointN(mls, 0, 0) ).toBe( '10,10' );
});
it("has a working setter for linestrings", function() {
mls.setLineStrings([
new ol.geom.LineString([
new ol.geom.Point(-10,10),
new ol.geom.Point(-10,0),
new ol.geom.Point(-20,20)
])
]);
var linestrings = mls.getLineStrings();
expect( linestrings.length ).toBe( 1 );
expect( linestrings[0] ).toBeA( ol.geom.LineString );
expect( linestringNPointN(mls, 0, 0) ).toBe( '-10,10' );
});
it("has a method to add linestrings", function() {
mls.addLineString(
new ol.geom.LineString([
new ol.geom.Point(11,11),
new ol.geom.Point(11,1),
new ol.geom.Point(21,21)
]),
1
);
mls.addLineString(
new ol.geom.LineString([
new ol.geom.Point(9,9),
new ol.geom.Point(9,-1),
new ol.geom.Point(19,19)
]),
0
);
mls.addLineString(
new ol.geom.LineString([
new ol.geom.Point(31,11),
new ol.geom.Point(31,1),
new ol.geom.Point(41,21)
]),
4
);
var linestrings = mls.getLineStrings();
expect( linestrings.length ).toBe( 5 );
expect( linestringNPointN(mls, 0, 0) ).toBe( '9,9' );
expect( linestringNPointN(mls, 1, 0) ).toBe( '10,10' );
expect( linestringNPointN(mls, 2, 0) ).toBe( '11,11' );
expect( linestringNPointN(mls, 3, 0) ).toBe( '30,10' );
expect( linestringNPointN(mls, 4, 0) ).toBe( '31,11' );
});
it("has a method to remove linestrings", function() {
mls.setLineStrings([
new ol.geom.LineString([
new ol.geom.Point(9,9),
new ol.geom.Point(9,-1),
new ol.geom.Point(19,19)
]),
new ol.geom.LineString([
new ol.geom.Point(10,10),
new ol.geom.Point(10,0),
new ol.geom.Point(20,20)
]),
new ol.geom.LineString([
new ol.geom.Point(11,11),
new ol.geom.Point(11,1),
new ol.geom.Point(21,21)
])
]);
var ls = mls.getLineStrings()[1]; // p1: 10,10;
mls.removeLineString( ls );
var linestrings = mls.getLineStrings();
expect( linestrings.length ).toBe( 2 );
expect( linestringNPointN(mls, 0, 0) ).toBe( '9,9' );
expect( linestringNPointN(mls, 1, 0) ).toBe( '11,11' );
});
describe('The setters ensure only linestrings can be added', function(){
it('addLineString cannot be tricked', function(){
expect(function(){
mls.addLineString(
new ol.geom.Point(30,40)
);
}).toThrow();
expect(function(){
mls.addLineString(
new ol.geom.MultiPoint()
);
}).toThrow();
expect(function(){
mls.addLineString(
new ol.geom.Collection()
);
}).toThrow();
});
it('addComponent cannot be tricked', function(){
expect(function(){
mls.addComponent(
new ol.geom.Point(30,40)
);
}).toThrow();
expect(function(){
mls.addComponent(
new ol.geom.MultiPoint()
);
}).toThrow();
expect(function(){
mls.addComponent(
new ol.geom.Collection()
);
}).toThrow();
});
});
describe("the getCentroid method is functional", function(){
it("returns an instance of ol.geom.Point", function(){
expect(mls.getCentroid()).toBeA(ol.geom.Point);
});
it("has the expected coordinates", function(){
mls.setLineStrings([
new ol.geom.LineString([
new ol.geom.Point(0,40),
new ol.geom.Point(40,40)
]),
new ol.geom.LineString([
new ol.geom.Point(0,0),
new ol.geom.Point(40,40)
])
]);
var c = mls.getCentroid();
expect( formatPoint(c) ).toBe('20,20');
});
});
});

View File

@@ -1,141 +0,0 @@
describe("ol.geom.MultiPoint", function() {
var mp;
beforeEach(function(){
mp = new ol.geom.MultiPoint([
new ol.geom.Point(10,20)
]);
});
afterEach(function(){
mp = null;
});
it("constructs instances", function() {
expect( mp ).toBeA( ol.geom.MultiPoint );
});
it("can construct instances without any points", function() {
// empty array
mp = new ol.geom.MultiPoint([]);
expect( mp ).toBeA( ol.geom.MultiPoint );
// no argument at all
mp = new ol.geom.MultiPoint();
expect( mp ).toBeA( ol.geom.MultiPoint );
});
it("cannot be constructed with component-types other than 'ol.geom.Point'", function() {
expect(function(){
mp = new ol.geom.MultiPoint([
new ol.geom.LineString()
]);
}).toThrow();
});
it("inherits from ol.geom.Geometry", function() {
expect( mp ).toBeA( ol.geom.Geometry );
});
it("has a working getter for points", function() {
var points = mp.getPoints();
expect( points ).toBeA( Array );
expect( points.length ).toBe( 1 );
expect( points[0] ).toBeA( ol.geom.Point );
expect( points[0].getX() + ',' + points[0].getY()).toBe( '10,20' );
});
it("has a working setter for points", function() {
mp.setPoints([
new ol.geom.Point(30,40),
new ol.geom.Point(50,60)
]);
var points = mp.getPoints();
expect( points.length ).toBe( 2 );
expect( points[0] ).toBeA( ol.geom.Point );
expect( points[1] ).toBeA( ol.geom.Point );
expect( points[0].getX() + ',' + points[0].getY()).toBe( '30,40' );
expect( points[1].getX() + ',' + points[1].getY()).toBe( '50,60' );
});
it("has a method to add points", function() {
mp.addPoint(
new ol.geom.Point(30,40),
1
);
mp.addPoint(
new ol.geom.Point(50,60),
2
);
mp.addPoint(
new ol.geom.Point(-10,0),
0
);
var points = mp.getPoints();
expect( points.length ).toBe( 4 );
expect( points[0].getX() + ',' + points[0].getY()).toBe( '-10,0' );
expect( points[1].getX() + ',' + points[1].getY()).toBe( '10,20' );
expect( points[2].getX() + ',' + points[2].getY()).toBe( '30,40' );
expect( points[3].getX() + ',' + points[3].getY()).toBe( '50,60' );
});
it("can only add ol.geom.Point as components", function() {
expect(function(){
mp.addComponent(
new ol.geom.LineString([
new ol.geom.Point(30,40),
new ol.geom.Point(50,60)
])
);
}).toThrow();
});
it("has a method to remove points", function() {
mp.setPoints([
new ol.geom.Point(0,10),
new ol.geom.Point(10,20),
new ol.geom.Point(20,30),
new ol.geom.Point(30,40)
]);
var p = mp.getPoints()[2]; // 20,30;
mp.removePoint( p );
var points = mp.getPoints();
expect( points.length ).toBe( 3 );
expect( points[0].getX() + ',' + points[0].getY()).toBe( '0,10' );
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');
});
});
});

View File

@@ -1,149 +0,0 @@
describe("ol.geom.Point", function() {
var p2Args,
p3Args,
p4Args,
proj = "EPSG:4326";
var instances = {
"two arguments <x>,<y> passed": new ol.geom.Point(21, 4),
"three arguments <x>,<y>,<z> passed": new ol.geom.Point(21, 4, 8),
"four arguments <x>,<y>,<z>,<projection> passed": new ol.geom.Point(21, 4, 8, proj)
};
beforeEach(function() {
proj = ol.projection("EPSG:4326");
instances = {
"two arguments <x>,<y> passed": new ol.geom.Point(21, 4),
"three arguments <x>,<y>,<z> passed": new ol.geom.Point(21, 4, 8),
"four arguments <x>,<y>,<z>,<projection> passed": new ol.geom.Point(21, 4, 8, proj)
};
p2Args = instances['two arguments <x>,<y> passed'];
p3Args = instances['three arguments <x>,<y>,<z> passed'];
p4Args = instances['four arguments <x>,<y>,<z>,<projection> passed'];
});
afterEach(function() {
p2Args = p3Args = p4Args = null;
instances = {
"two arguments <x>,<y> passed": new ol.geom.Point(21, 4),
"three arguments <x>,<y>,<z> passed": new ol.geom.Point(21, 4, 8),
"four arguments <x>,<y>,<z>,<projection> passed": new ol.geom.Point(21, 4, 8, proj)
};
});
for (instancesDesc in instances) {
if (instances.hasOwnProperty(instancesDesc)) {
var instance = instances[instancesDesc];
describe("instantiate with " + instancesDesc, function() {
it("constructs instances", function() {
expect(instance).toEqual(jasmine.any(ol.geom.Point));
});
it("constructs instances of ol.geom.Geometry", function() {
expect(instance).toEqual(jasmine.any(ol.geom.Geometry));
});
it("has the coordinate accessor methods", function() {
expect(instance.getX).not.toBeUndefined();
expect(instance.getY).not.toBeUndefined();
expect(instance.getZ).not.toBeUndefined();
expect(instance.setX).not.toBeUndefined();
expect(instance.setY).not.toBeUndefined();
expect(instance.setZ).not.toBeUndefined();
});
it("has the projection accessor methods", function() {
expect(instance.getProjection).not.toBeUndefined();
expect(instance.setProjection).not.toBeUndefined();
});
});
}
}
describe('the getters are functional', function(){
it("works when two arguments <x>,<y> passed", function(){
expect(p2Args.getX()).toBe(21);
expect(p2Args.getY()).toBe(4);
expect(p2Args.getZ()).toBeUndefined();
expect(p2Args.getProjection()).toBeNull();
});
it("works when three arguments <x>,<y>,<z> passed", function(){
expect(p3Args.getX()).toBe(21);
expect(p3Args.getY()).toBe(4);
expect(p3Args.getZ()).not.toBeUndefined();
expect(p3Args.getZ()).toBe(8);
expect(p3Args.getProjection()).toBeNull();
});
it("works when four arguments <x>,<y>,<z>,<projection> passed", function(){
expect(p4Args.getX()).toBe(21);
expect(p4Args.getY()).toBe(4);
expect(p4Args.getZ()).toBe(8);
expect(p4Args.getProjection()).not.toBeNull();
expect(p4Args.getProjection()).toBeA(ol.Projection);
});
});
describe("transformation is functional", function(){
it("can be transformed", function(){
// save for later comparison
var old = {
x: p4Args.getX().toFixed(3),
y: p4Args.getY().toFixed(3)
};
// with code only
var transformedPoint = p4Args.transform("EPSG:3857");
// is it still an instance of ol.geom.Point?
expect(transformedPoint).toBeA(ol.geom.Point);
// coordinates OK?
expect(transformedPoint.getX().toFixed(3)).toBe("2337709.306");
expect(transformedPoint.getY().toFixed(3)).toBe("445640.110");
// with an ol.Projection
var retransformedPoint = transformedPoint.transform(new ol.Projection("EPSG:4326"));
expect(retransformedPoint).toBeA(ol.geom.Point);
// coordinates shopulkd be the originally configured
expect(retransformedPoint.getX().toFixed(3)).toBe(old.x);
expect(retransformedPoint.getY().toFixed(3)).toBe(old.y);
});
it("throws an exception when you try to transform without a source projection", function(){
expect(function() {
p2Args.transform("EPSG:3857");
}).toThrow();
expect(function() {
p3Args.transform("EPSG:3857");
}).toThrow();
});
});
describe("the getCentroid method is functional", function(){
it("returns an instance of ol.geom.Point", function(){
expect(p2Args.getCentroid()).toBeA(ol.geom.Point);
expect(p3Args.getCentroid()).toBeA(ol.geom.Point);
expect(p4Args.getCentroid()).toBeA(ol.geom.Point);
});
it("does return a clone and not the point itself", function(){
expect(p2Args.getCentroid()).not.toBe(p2Args);
expect(p3Args.getCentroid()).not.toBe(p3Args);
expect(p4Args.getCentroid()).not.toBe(p4Args);
});
it("has the expected coordinates", function(){
var c2 = p2Args.getCentroid(),
c3 = p3Args.getCentroid(),
c4 = p4Args.getCentroid();
expect(c2.getX() + ',' + c2.getY()).toBe('21,4');
expect(c3.getX() + ',' + c3.getY()).toBe('21,4');
expect(c4.getX() + ',' + c4.getY()).toBe('21,4');
});
});
});