Remove the mixin approach and give the Point class a projection.
This commit is contained in:
@@ -1,35 +1,41 @@
|
||||
describe("ol.geom.Point", function() {
|
||||
var pNoArgs,
|
||||
pNoZ,
|
||||
p;
|
||||
pWithZ,
|
||||
p,
|
||||
proj = "EPSG:4326";
|
||||
|
||||
var instances = {
|
||||
"no arguments passed": ol.geom.point(),
|
||||
"only two arguments [x,y] passed": ol.geom.point([21, 4]),
|
||||
"all arguments passed": ol.geom.point([21, 4, 8])
|
||||
"one argument [x,y] passed": ol.geom.point([21, 4]),
|
||||
"one argument [x,y,z] passed": ol.geom.point([21, 4, 8]),
|
||||
"two arguments passed [x,y,z] & projection": ol.geom.point([21, 4, 8, proj])
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
proj = ol.projection("EPSG:4326");
|
||||
instances = {
|
||||
"no arguments passed": ol.geom.point(),
|
||||
"only two arguments [x,y] passed": ol.geom.point([21, 4]),
|
||||
"all arguments passed": ol.geom.point([21, 4, 8])
|
||||
"one argument [x,y] passed": ol.geom.point([21, 4]),
|
||||
"one argument [x,y,z] passed": ol.geom.point([21, 4, 8]),
|
||||
"two arguments passed [x,y,z] & projection": ol.geom.point([21, 4, 8, proj])
|
||||
};
|
||||
pNoArgs = instances['no arguments passed'];
|
||||
pNoZ = instances['only two arguments [x,y] passed'];
|
||||
p = instances['all arguments passed'];
|
||||
pNoZ = instances['one argument [x,y] passed'];
|
||||
pWithZ = instances['one argument [x,y,z] passed'];
|
||||
p = instances['two arguments passed [x,y,z] & projection'];
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
pNoArgs = pNoZ = p = null;
|
||||
pNoArgs = pNoZ = pWithZ = p = null;
|
||||
instances = {
|
||||
"no arguments passed": pNoArgs,
|
||||
"only two arguments [x,y] passed": pNoZ,
|
||||
"all arguments passed": p
|
||||
"no arguments passed": ol.geom.point(),
|
||||
"one argument [x,y] passed": ol.geom.point([21, 4]),
|
||||
"one argument [x,y,z] passed": ol.geom.point([21, 4, 8]),
|
||||
"two arguments passed [x,y,z] & projection": ol.geom.point([21, 4, 8, proj])
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
for (instancesDesc in instances) {
|
||||
if (instances.hasOwnProperty(instancesDesc)) {
|
||||
var instance = instances[instancesDesc];
|
||||
@@ -42,7 +48,7 @@ describe("ol.geom.Point", function() {
|
||||
expect(instance).toEqual(jasmine.any(ol.geom.Geometry));
|
||||
});
|
||||
|
||||
it("has the coordinate mixin methods (" + instancesDesc + ")", function() {
|
||||
it("has the coordinate accessor methods (" + instancesDesc + ")", function() {
|
||||
expect(instance.getX).not.toBeUndefined();
|
||||
expect(instance.getY).not.toBeUndefined();
|
||||
expect(instance.getZ).not.toBeUndefined();
|
||||
@@ -50,6 +56,11 @@ describe("ol.geom.Point", function() {
|
||||
expect(instance.setY).not.toBeUndefined();
|
||||
expect(instance.setZ).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it("has the projection accessor methods (" + instancesDesc + ")", function() {
|
||||
expect(instance.getProjection).not.toBeUndefined();
|
||||
expect(instance.setProjection).not.toBeUndefined();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,17 +68,28 @@ describe("ol.geom.Point", function() {
|
||||
expect(pNoArgs.getX()).toBe(0);
|
||||
expect(pNoArgs.getY()).toBe(0);
|
||||
expect(pNoArgs.getZ()).toBeUndefined();
|
||||
expect(pNoArgs.getProjection()).toBeNull();
|
||||
});
|
||||
|
||||
it("has functional getters (only two arguments [x,y] passed)", function(){
|
||||
it("has functional getters (one argument [x,y] passed)", function(){
|
||||
expect(pNoZ.getX()).toBe(21);
|
||||
expect(pNoZ.getY()).toBe(4);
|
||||
expect(pNoZ.getZ()).toBeUndefined();
|
||||
expect(pNoZ.getProjection()).toBeNull();
|
||||
});
|
||||
|
||||
it("has functional getters (all arguments passed)", function(){
|
||||
it("has functional getters (one argument [x,y,z] passed)", function(){
|
||||
expect(pWithZ.getX()).toBe(21);
|
||||
expect(pWithZ.getY()).toBe(4);
|
||||
expect(pWithZ.getZ()).toBe(8);
|
||||
expect(pWithZ.getProjection()).toBeNull();
|
||||
});
|
||||
|
||||
it("has functional getters (two arguments passed [x,y,z] & projection)", function(){
|
||||
expect(p.getX()).toBe(21);
|
||||
expect(p.getY()).toBe(4);
|
||||
expect(p.getZ()).toBe(8);
|
||||
expect(p.getProjection()).not.toBeNull();
|
||||
expect(p.getProjection()).toEqual(jasmine.any(ol.Projection));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user