From 53a1f9b579ef0904378b0d446e66922bd685c9c9 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Sun, 24 Jun 2012 12:02:45 +0200 Subject: [PATCH] Adding tests for Loc.add. --- test/ol.html | 1 + test/spec/ol/Loc.test.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 test/spec/ol/Loc.test.js 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