This commit is contained in:
Petr Pridal
2012-06-20 11:40:25 +02:00
3 changed files with 33 additions and 10 deletions

View File

@@ -4,10 +4,28 @@ describe("ol.Events", function() {
var events, element = document.createElement("div"); var events, element = document.createElement("div");
events = new ol.event.Events("foo"); events = new ol.event.Events("foo");
expect(events.getObject()).toBe("foo"); expect(events.getObject()).toBe("foo");
expect(events.getElement()).toBe(null);
events.destroy(); events.destroy();
events = new ol.event.Events("foo", element, true); events = new ol.event.Events("foo", element, true);
expect(events.element_).toBe(element); expect(events.getElement()).toBe(element);
expect(events.includeXY_).toBe(true); expect(events.includeXY_).toBe(true);
events.destroy();
});
it("destroys properly", function() {
var events = new ol.event.Events("foo");
events.destroy();
expect(events.getObject()).toBe(undefined);
});
it("respects event priority", function() {
var log = [], events = new ol.event.Events("foo");
events.register("bar", function() {log.push("normal");});
events.register(
"bar", function() {log.push("priority");}, undefined, true);
events.triggerEvent("bar");
expect(log[0]).toBe("priority");
expect(log[1]).toBe("normal");
}); });
}); });

View File

@@ -133,7 +133,6 @@ describe("ol.Map", function() {
expect(proj instanceof ol.Projection).toBe(true); expect(proj instanceof ol.Projection).toBe(true);
expect(proj.code()).toBe("EPSG:4326"); expect(proj.code()).toBe("EPSG:4326");
debugger;
map.center([10, 20]); map.center([10, 20]);
map.userProjection("EPSG:3857"); map.userProjection("EPSG:3857");

View File

@@ -1,15 +1,21 @@
describe("ol.geom.Point", function() { describe("ol.geom.Point", function() {
var pNoArgs, var pNoArgs,
pNoZ, pNoZ_arr,
pWithZ, pWithZ_arr,
p, p_arr,
pNoZ_obj,
pWithZ_obj,
p_obj,
proj = "EPSG:4326"; proj = "EPSG:4326";
var instances = { var instances = {
"no arguments passed": ol.geom.point(), "no arguments passed": ol.geom.point(),
"one argument [x,y] passed": ol.geom.point([21, 4]), "one argument [x,y] passed": ol.geom.point([21, 4]),
"one argument [x,y,z] passed": ol.geom.point([21, 4, 8]), "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]) "one argument [x,y,z,projection] passed": ol.geom.point([21, 4, 8, proj]),
"one argument {x,y} passed": ol.geom.point([21, 4]),
"one argument {x,y,z} passed": ol.geom.point([21, 4, 8]),
"one argument {x,y,z,projection} passed": ol.geom.point([21, 4, 8, proj])
}; };
beforeEach(function() { beforeEach(function() {
@@ -18,12 +24,12 @@ describe("ol.geom.Point", function() {
"no arguments passed": ol.geom.point(), "no arguments passed": ol.geom.point(),
"one argument [x,y] passed": ol.geom.point([21, 4]), "one argument [x,y] passed": ol.geom.point([21, 4]),
"one argument [x,y,z] passed": ol.geom.point([21, 4, 8]), "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]) "one argument [x,y,z,projection] passed": ol.geom.point([21, 4, 8, proj])
}; };
pNoArgs = instances['no arguments passed']; pNoArgs = instances['no arguments passed'];
pNoZ = instances['one argument [x,y] passed']; pNoZ = instances['one argument [x,y] passed'];
pWithZ = instances['one argument [x,y,z] passed']; pWithZ = instances['one argument [x,y,z] passed'];
p = instances['two arguments passed [x,y,z] & projection']; p = instances['one argument [x,y,z,projection] passed'];
}); });
afterEach(function() { afterEach(function() {
@@ -32,7 +38,7 @@ describe("ol.geom.Point", function() {
"no arguments passed": ol.geom.point(), "no arguments passed": ol.geom.point(),
"one argument [x,y] passed": ol.geom.point([21, 4]), "one argument [x,y] passed": ol.geom.point([21, 4]),
"one argument [x,y,z] passed": ol.geom.point([21, 4, 8]), "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]) "one argument [x,y,z,projection] passed": ol.geom.point([21, 4, 8, proj])
}; };
}); });
@@ -85,7 +91,7 @@ describe("ol.geom.Point", function() {
expect(pWithZ.getProjection()).toBeNull(); expect(pWithZ.getProjection()).toBeNull();
}); });
it("has functional getters (two arguments passed [x,y,z] & projection)", function(){ it("has functional getters (one argument [x,y,z,projection] passed)", function(){
expect(p.getX()).toBe(21); expect(p.getX()).toBe(21);
expect(p.getY()).toBe(4); expect(p.getY()).toBe(4);
expect(p.getZ()).toBe(8); expect(p.getZ()).toBe(8);