diff --git a/test/ol.html b/test/ol.html index 6f6c691f07..92b9232bdf 100644 --- a/test/ol.html +++ b/test/ol.html @@ -78,6 +78,7 @@ + diff --git a/test/spec/ol/Loc.test.js b/test/spec/ol/Loc.test.js new file mode 100644 index 0000000000..1b06695296 --- /dev/null +++ b/test/spec/ol/Loc.test.js @@ -0,0 +1,30 @@ +describe('ol.Loc', function() { + + it("should be easy to get a new location with deltas added to coordinates", function() { + var loc, newLoc; + + loc = new ol.Loc(1, 2, 3); + newLoc = loc.add(1, 2, 3); + expect(newLoc.getX()).toBe(2); + expect(newLoc.getY()).toBe(4); + expect(newLoc.getZ()).toBe(6); + + loc = new ol.Loc(1, 2); + newLoc =loc.add(1, 2); + expect(newLoc.getX()).toBe(2); + expect(newLoc.getY()).toBe(4); + expect(newLoc.getZ()).toBeUndefined(); + + newLoc = loc.add(0, 0, 1); + expect(newLoc.getZ()).toBeUndefined(); + }); + + it("should be immutable", function() { + var loc = new ol.Loc(1, 2, 3); + loc.add(1, 2, 3); + expect(loc.getX()).toBe(1); + expect(loc.getY()).toBe(2); + expect(loc.getZ()).toBe(3); + }); + +}); \ No newline at end of file