[Pkg-javascript-commits] [leaflet] 89/301: Add test specifications for CRS classes.

Jonas Smedegaard js at moszumanska.debian.org
Mon Jan 27 22:22:43 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository leaflet.

commit df320c3b0619245d8ad0478e76d204c2ec1efbec
Author: Alexander Parshin <parshin.alexander at gmail.com>
Date:   Tue Sep 10 11:03:59 2013 +0400

    Add test specifications for CRS classes.
---
 spec/suites/SpecHelper.js         | 18 ++++++++++++++-
 spec/suites/geo/CRSSpec.js        | 47 +++++++++++++++++++++++++++++++++++++++
 spec/suites/geo/ProjectionSpec.js |  8 -------
 3 files changed, 64 insertions(+), 9 deletions(-)

diff --git a/spec/suites/SpecHelper.js b/spec/suites/SpecHelper.js
index 353359f..cd86791 100644
--- a/spec/suites/SpecHelper.js
+++ b/spec/suites/SpecHelper.js
@@ -23,4 +23,20 @@ if (!Array.prototype.map) {
 
     return res;
   };
-}
\ No newline at end of file
+}
+
+expect.Assertion.prototype.near = function(expected, delta) {
+    delta = delta || 1;
+    expect(this.obj.x).to
+        .be.within(expected.x - delta, expected.x + delta);
+    expect(this.obj.y).to
+        .be.within(expected.y - delta, expected.y + delta);
+};
+
+expect.Assertion.prototype.nearLatLng = function(expected, delta) {
+    delta = delta || 1e-4;
+    expect(this.obj.lat).to
+        .be.within(expected.lat - delta, expected.lat + delta);
+    expect(this.obj.lng).to
+        .be.within(expected.lng - delta, expected.lng + delta);
+};
\ No newline at end of file
diff --git a/spec/suites/geo/CRSSpec.js b/spec/suites/geo/CRSSpec.js
new file mode 100644
index 0000000..f4ef0d4
--- /dev/null
+++ b/spec/suites/geo/CRSSpec.js
@@ -0,0 +1,47 @@
+describe("CRS.EPSG3395", function() {
+	var crs = L.CRS.EPSG3395;
+
+	describe("#latLngToPoint", function() {
+		it("projects a center point", function() {
+			expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near(new L.Point(128, 128), 0.01);
+		})
+
+		it("projects the northeast corner of the world", function() {
+			expect(crs.latLngToPoint(L.latLng(85.0840591556, 180), 0)).near(new L.Point(256, 0));
+		});
+	});
+
+	describe("#pointToLatLng", function() {
+		it("reprojects a center point", function() {
+			expect(crs.pointToLatLng(new L.Point(128, 128), 0)).nearLatLng(L.latLng(0, 0), 0.01);
+		})
+
+		it("reprojects the northeast corner of the world", function() {
+			expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng(L.latLng(85.0840591556, 180));
+		});
+	});
+});
+
+describe("CRS.EPSG3857", function() {
+	var crs = L.CRS.EPSG3857;
+
+	describe("#latLngToPoint", function() {
+		it("projects a center point", function() {
+			expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near(new L.Point(128, 128), 0.01);
+		})
+
+		it("projects the northeast corner of the world", function() {
+			expect(crs.latLngToPoint(L.latLng(85.0511287798, 180), 0)).near(new L.Point(256, 0));
+		});
+	});
+
+	describe("#pointToLatLng", function() {
+		it("reprojects a center point", function() {
+			expect(crs.pointToLatLng(new L.Point(128, 128), 0)).nearLatLng(L.latLng(0, 0), 0.01);
+		})
+
+		it("reprojects the northeast corner of the world", function() {
+			expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng(L.latLng(85.0511287798, 180));
+		});
+	});
+});
\ No newline at end of file
diff --git a/spec/suites/geo/ProjectionSpec.js b/spec/suites/geo/ProjectionSpec.js
index 2414bfa..e2ff547 100644
--- a/spec/suites/geo/ProjectionSpec.js
+++ b/spec/suites/geo/ProjectionSpec.js
@@ -1,14 +1,6 @@
 describe("Projection.Mercator", function() {
 	var p = L.Projection.Mercator;
 
-	expect.Assertion.prototype.near = function(expected, delta) {
-		delta = delta || 1;
-		expect(this.obj.x).to
-			.be.within(expected.x - delta, expected.x + delta);
-		expect(this.obj.y).to
-			.be.within(expected.y - delta, expected.y + delta);
-	};
-
 	describe("#project", function() {
 		it("projects a center point", function() {
 			//edge cases

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet.git



More information about the Pkg-javascript-commits mailing list