From c5ba5b0456a711d157e317f220e9c739226e7f50 Mon Sep 17 00:00:00 2001 From: Joar Wandborg Date: Tue, 10 Jan 2012 01:54:37 +0100 Subject: Installed leaflet in extlib --- extlib/leaflet/spec/suites/geometry/BoundsSpec.js | 43 +++++++++++++++++++++ extlib/leaflet/spec/suites/geometry/PointSpec.js | 45 ++++++++++++++++++++++ .../spec/suites/geometry/TransformationSpec.js | 19 +++++++++ 3 files changed, 107 insertions(+) create mode 100644 extlib/leaflet/spec/suites/geometry/BoundsSpec.js create mode 100644 extlib/leaflet/spec/suites/geometry/PointSpec.js create mode 100644 extlib/leaflet/spec/suites/geometry/TransformationSpec.js (limited to 'extlib/leaflet/spec/suites/geometry') diff --git a/extlib/leaflet/spec/suites/geometry/BoundsSpec.js b/extlib/leaflet/spec/suites/geometry/BoundsSpec.js new file mode 100644 index 00000000..eee05e4b --- /dev/null +++ b/extlib/leaflet/spec/suites/geometry/BoundsSpec.js @@ -0,0 +1,43 @@ +describe('Bounds', function() { + var a, b; + + beforeEach(function() { + a = new L.Bounds( + new L.Point(14, 12), + new L.Point(30, 40)); + b = new L.Bounds([ + new L.Point(20, 12), + new L.Point(14, 20), + new L.Point(30, 40) + ]); + }); + + describe('constructor', function() { + it('should create bounds with proper min & max on (Point, Point)', function() { + expect(a.min).toEqual(new L.Point(14, 12)); + expect(a.max).toEqual(new L.Point(30, 40)); + }); + it('should create bounds with proper min & max on (Point[])', function() { + expect(b.min).toEqual(new L.Point(14, 12)); + expect(b.max).toEqual(new L.Point(30, 40)); + }); + }); + + describe('#extend', function() { + it('should extend the bounds to contain the given point', function() { + a.extend(new L.Point(50, 20)); + expect(a.min).toEqual(new L.Point(14, 12)); + expect(a.max).toEqual(new L.Point(50, 40)); + + b.extend(new L.Point(25, 50)); + expect(b.min).toEqual(new L.Point(14, 12)); + expect(b.max).toEqual(new L.Point(30, 50)); + }); + }); + + describe('#getCenter', function() { + it('should return the center point', function() { + expect(a.getCenter()).toEqual(new L.Point(22, 26)); + }); + }); +}); \ No newline at end of file diff --git a/extlib/leaflet/spec/suites/geometry/PointSpec.js b/extlib/leaflet/spec/suites/geometry/PointSpec.js new file mode 100644 index 00000000..d004d60b --- /dev/null +++ b/extlib/leaflet/spec/suites/geometry/PointSpec.js @@ -0,0 +1,45 @@ +describe("Point", function() { + + describe('constructor', function() { + + it("should create a point with the given x and y", function() { + var p = new L.Point(1.5, 2.5); + expect(p.x).toEqual(1.5); + expect(p.y).toEqual(2.5); + }); + + it("should round the given x and y if the third argument is true", function() { + var p = new L.Point(1.3, 2.7, true); + expect(p.x).toEqual(1); + expect(p.y).toEqual(3); + }); + }); + + describe('#subtract', function() { + it('should subtract the given point from this one', function() { + var a = new L.Point(50, 30), + b = new L.Point(20, 10); + expect(a.subtract(b)).toEqual(new L.Point(30, 20)); + }); + }); + + describe('#add', function() { + it('should add the given point to this one', function() { + expect(new L.Point(50, 30).add(new L.Point(20, 10))).toEqual(new L.Point(70, 40)); + }); + }); + + describe('#divideBy', function() { + it('should divide this point by the given amount', function() { + expect(new L.Point(50, 30).divideBy(5)).toEqual(new L.Point(10, 6)); + }); + }); + + describe('#multiplyBy', function() { + it('should multiply this point by the given amount', function() { + expect(new L.Point(50, 30).multiplyBy(2)).toEqual(new L.Point(100, 60)); + }); + }); + + describe('#distanceTo', noSpecs); +}); \ No newline at end of file diff --git a/extlib/leaflet/spec/suites/geometry/TransformationSpec.js b/extlib/leaflet/spec/suites/geometry/TransformationSpec.js new file mode 100644 index 00000000..8a945df1 --- /dev/null +++ b/extlib/leaflet/spec/suites/geometry/TransformationSpec.js @@ -0,0 +1,19 @@ +describe("Transformation", function() { + var t, p; + + beforeEach(function() { + t = new L.Transformation(1, 2, 3, 4); + p = new L.Point(10, 20); + }); + + it("#transform should perform a transformation", function() { + var p2 = t.transform(p, 2); + expect(p2).toEqual(new L.Point(24, 128)); + }); + + it("#untransform should perform a reverse transformation", function() { + var p2 = t.transform(p, 2); + var p3 = t.untransform(p2, 2); + expect(p3).toEqual(p); + }); +}); \ No newline at end of file -- cgit v1.2.3