diff options
Diffstat (limited to 'extlib/leaflet/spec')
| -rw-r--r-- | extlib/leaflet/spec/runner.html | 82 | ||||
| -rw-r--r-- | extlib/leaflet/spec/suites/LeafletSpec.js | 15 | ||||
| -rw-r--r-- | extlib/leaflet/spec/suites/SpecHelper.js | 5 | ||||
| -rw-r--r-- | extlib/leaflet/spec/suites/core/ClassSpec.js | 120 | ||||
| -rw-r--r-- | extlib/leaflet/spec/suites/core/EventsSpec.js | 110 | ||||
| -rw-r--r-- | extlib/leaflet/spec/suites/core/UtilSpec.js | 63 | ||||
| -rw-r--r-- | extlib/leaflet/spec/suites/dom/DomEventSpec.js | 102 | ||||
| -rw-r--r-- | extlib/leaflet/spec/suites/dom/DomUtilSpec.js | 29 | ||||
| -rw-r--r-- | extlib/leaflet/spec/suites/geo/LatLngBoundsSpec.js | 1 | ||||
| -rw-r--r-- | extlib/leaflet/spec/suites/geo/LatLngSpec.js | 70 | ||||
| -rw-r--r-- | extlib/leaflet/spec/suites/geo/ProjectionSpec.js | 42 | ||||
| -rw-r--r-- | extlib/leaflet/spec/suites/geometry/BoundsSpec.js | 43 | ||||
| -rw-r--r-- | extlib/leaflet/spec/suites/geometry/PointSpec.js | 45 | ||||
| -rw-r--r-- | extlib/leaflet/spec/suites/geometry/TransformationSpec.js | 19 | ||||
| -rw-r--r-- | extlib/leaflet/spec/suites/layer/TileLayerSpec.js | 1 | ||||
| -rw-r--r-- | extlib/leaflet/spec/suites/map/MapSpec.js | 1 | 
16 files changed, 748 insertions, 0 deletions
| diff --git a/extlib/leaflet/spec/runner.html b/extlib/leaflet/spec/runner.html new file mode 100644 index 00000000..6931d2c9 --- /dev/null +++ b/extlib/leaflet/spec/runner.html @@ -0,0 +1,82 @@ +<!DOCTYPE html> +<html> +<head> +	<title>Jasmine Test Runner</title> +	<link rel="stylesheet" type="text/css" href="../lib/jasmine/jasmine.css"> +	<script type="text/javascript" src="../lib/jasmine/jasmine.js"></script> +	<script type="text/javascript" src="../lib/jasmine/jasmine-html.js"></script> +	 +	<!-- source files --> +		 +		<script type="text/javascript"> +			L = 'test'; //to test L#noConflict later +		</script> +		 +		<script type="text/javascript" src="../src/Leaflet.js"></script> +	   +		<!-- /core --> +		<script type="text/javascript" src="../src/core/Util.js"></script> +		<script type="text/javascript" src="../src/core/Class.js"></script> +		<script type="text/javascript" src="../src/core/Events.js"></script> +		<script type="text/javascript" src="../src/core/Browser.js"></script> + +		<!-- /dom --> +		<script type="text/javascript" src="../src/dom/DomEvent.js"></script> +		<script type="text/javascript" src="../src/dom/DomUtil.js"></script> +	 +		<!-- /geo --> +		<script type="text/javascript" src="../src/geo/LatLng.js"></script> +		<script type="text/javascript" src="../src/geo/LatLngBounds.js"></script> +		<script type="text/javascript" src="../src/geo/Projection.js"></script> + +		<!-- /geometry --> +		<script type="text/javascript" src="../src/geometry/Point.js"></script> +		<script type="text/javascript" src="../src/geometry/Bounds.js"></script> +		<script type="text/javascript" src="../src/geometry/Transformation.js"></script> + +		<!-- /layer --> +		<script type="text/javascript" src="../src/layer/TileLayer.js"></script> +		 +		<!-- /map --> +		<script type="text/javascript" src="../src/map/Map.js"></script> +		 + +	<!-- spec files --> +		 +		<script type="text/javascript" src="suites/SpecHelper.js"></script> +		<script type="text/javascript" src="suites/LeafletSpec.js"></script> +	 +		<!-- /core --> +		<script type="text/javascript" src="suites/core/UtilSpec.js"></script> +		<script type="text/javascript" src="suites/core/ClassSpec.js"></script> +		<script type="text/javascript" src="suites/core/EventsSpec.js"></script> + +		<!-- /geometry --> +		<script type="text/javascript" src="suites/geometry/PointSpec.js"></script> +		<script type="text/javascript" src="suites/geometry/BoundsSpec.js"></script> +		<script type="text/javascript" src="suites/geometry/TransformationSpec.js"></script> + +		<!-- /geo --> +		<script type="text/javascript" src="suites/geo/LatLngSpec.js"></script> +		<script type="text/javascript" src="suites/geo/LatLngBoundsSpec.js"></script> +		<script type="text/javascript" src="suites/geo/ProjectionSpec.js"></script> + +		<!-- /dom --> +		<script type="text/javascript" src="suites/dom/DomEventSpec.js"></script> +		<script type="text/javascript" src="suites/dom/DomUtilSpec.js"></script> + +		<!-- /layer --> +		<script type="text/javascript" src="suites/layer/TileLayerSpec.js"></script> +		 +		<!-- /map --> +		<script type="text/javascript" src="suites/map/MapSpec.js"></script> +</head> +<body> + +<script type="text/javascript"> +	jasmine.getEnv().addReporter(new jasmine.TrivialReporter()); +	jasmine.getEnv().execute(); +</script> + +</body> +</html>
\ No newline at end of file diff --git a/extlib/leaflet/spec/suites/LeafletSpec.js b/extlib/leaflet/spec/suites/LeafletSpec.js new file mode 100644 index 00000000..c67879cf --- /dev/null +++ b/extlib/leaflet/spec/suites/LeafletSpec.js @@ -0,0 +1,15 @@ +describe('L#noConflict', function() {
 +	it('should restore the previous L value and return Leaflet namespace', function(){
 +		
 +		expect(L.VERSION).toBeDefined();
 +		
 +		var L2 = L.noConflict();
 +		
 +		expect(L).toEqual('test');
 +		expect(L2.VERSION).toBeDefined();
 +		
 +		this.after(function() {
 +			window.L = L2;
 +		});
 +	});
 +});
\ No newline at end of file diff --git a/extlib/leaflet/spec/suites/SpecHelper.js b/extlib/leaflet/spec/suites/SpecHelper.js new file mode 100644 index 00000000..8b827041 --- /dev/null +++ b/extlib/leaflet/spec/suites/SpecHelper.js @@ -0,0 +1,5 @@ +function noSpecs() {
 +	it('should have specs', function() {
 +		expect('specs').toBe();
 +	});
 +}
\ No newline at end of file diff --git a/extlib/leaflet/spec/suites/core/ClassSpec.js b/extlib/leaflet/spec/suites/core/ClassSpec.js new file mode 100644 index 00000000..7a289154 --- /dev/null +++ b/extlib/leaflet/spec/suites/core/ClassSpec.js @@ -0,0 +1,120 @@ +describe("Class", function() {
 +	
 +	describe("#extend", function() {
 +		var Klass,
 +			constructor,
 +			method;
 +		
 +		beforeEach(function() {
 +			constructor = jasmine.createSpy(),
 +			method = jasmine.createSpy();
 +
 +			Klass = L.Class.extend({
 +				statics: {bla: 1},
 +				includes: {mixin: true},
 +				
 +				initialize: constructor,
 +				foo: 5,
 +				bar: method
 +			});
 +		});
 +		
 +		it("should create a class with the given constructor & properties", function() {
 +			var a = new Klass();
 +			
 +			expect(constructor).toHaveBeenCalled();
 +			expect(a.foo).toEqual(5);
 +			
 +			a.bar();
 +			
 +			expect(method).toHaveBeenCalled();
 +		});
 +		
 +		it("should inherit parent classes' constructor & properties", function() {
 +			var Klass2 = Klass.extend({baz: 2});
 +			
 +			var b = new Klass2();
 +			
 +			expect(b instanceof Klass).toBeTruthy();
 +			expect(b instanceof Klass2).toBeTruthy();
 +			
 +			expect(constructor).toHaveBeenCalled();
 +			expect(b.baz).toEqual(2);
 +			
 +			b.bar();
 +			
 +			expect(method).toHaveBeenCalled();
 +		});
 +		
 +		it("should grant the ability to call parent methods, including constructor", function() {
 +			var Klass2 = Klass.extend({
 +				initialize: function() {},
 +				bar: function() {}
 +			});
 +			
 +			var b = new Klass2();
 +			
 +			expect(constructor).not.toHaveBeenCalled();
 +			b.superclass.initialize.call(this);
 +			expect(constructor).toHaveBeenCalled();
 +
 +			b.superclass.bar.call(this);
 +			expect(method).toHaveBeenCalled();
 +		});
 +		
 +		it("should support static properties", function() {
 +			expect(Klass.bla).toEqual(1);
 +		});
 +		
 +		it("should inherit parent static properties", function() {
 +			var Klass2 = Klass.extend({});
 +			
 +			expect(Klass2.bla).toEqual(1);
 +		});
 +		
 +		it("should include the given mixin", function() {
 +			var a = new Klass();
 +			expect(a.mixin).toBeTruthy();
 +		});
 +		
 +		it("should be able to include multiple mixins", function() {
 +			var Klass2 = L.Class.extend({
 +				includes: [{mixin: true}, {mixin2: true}]
 +			});
 +			var a = new Klass2();
 +			
 +			expect(a.mixin).toBeTruthy();
 +			expect(a.mixin2).toBeTruthy();
 +		});
 +		
 +		it("should grant the ability to include the given mixin", function() {
 +			Klass.include({mixin2: true});
 +			
 +			var a = new Klass();
 +			expect(a.mixin2).toBeTruthy();
 +		});
 +		
 +		it("should merge options instead of replacing them", function() {
 +			var KlassWithOptions1 = L.Class.extend({
 +				options: {
 +					foo1: 1,
 +					foo2: 2
 +				}
 +			});
 +			var KlassWithOptions2 = KlassWithOptions1.extend({
 +				options: {
 +					foo2: 3,
 +					foo3: 4
 +				}
 +			});
 +			
 +			var a = new KlassWithOptions2();
 +			
 +			expect(a.options).toEqual({
 +				foo1: 1,
 +				foo2: 3,
 +				foo3: 4
 +			});
 +		});
 +	});
 +});
\ No newline at end of file diff --git a/extlib/leaflet/spec/suites/core/EventsSpec.js b/extlib/leaflet/spec/suites/core/EventsSpec.js new file mode 100644 index 00000000..be143866 --- /dev/null +++ b/extlib/leaflet/spec/suites/core/EventsSpec.js @@ -0,0 +1,110 @@ +describe('Events', function() {
 +	var Klass;
 +	
 +	beforeEach(function() {
 +		Klass = L.Class.extend({
 +			includes: L.Mixin.Events
 +		});
 +	});
 +	
 +	describe('#fireEvent', function() {
 +		
 +		it('should fire all listeners added through #addEventListener', function() {
 +			var obj = new Klass(),
 +				spy = jasmine.createSpy(),
 +				spy2 = jasmine.createSpy(),
 +				spy3 = jasmine.createSpy();
 +			
 +			obj.addEventListener('test', spy);
 +			obj.addEventListener('test', spy2);
 +			obj.addEventListener('other', spy3);
 +			
 +			expect(spy).not.toHaveBeenCalled();
 +			expect(spy2).not.toHaveBeenCalled();
 +			expect(spy3).not.toHaveBeenCalled();
 +			
 +			obj.fireEvent('test');
 +			
 +			expect(spy).toHaveBeenCalled();
 +			expect(spy2).toHaveBeenCalled();
 +			expect(spy3).not.toHaveBeenCalled();
 +		});
 +
 +		it('should provide event object to listeners and execute them in the right context', function() {
 +			var obj = new Klass(),
 +				obj2 = new Klass(),
 +				foo = {};
 +			
 +			function listener1(e) {
 +				expect(e.type).toEqual('test');
 +				expect(e.target).toEqual(obj);
 +				expect(this).toEqual(obj);
 +				expect(e.bar).toEqual(3);
 +			};
 +			
 +			function listener2(e) {
 +				expect(e.target).toEqual(obj2);
 +				expect(this).toEqual(foo);
 +			};
 +			
 +			obj.addEventListener('test', listener1);
 +			obj2.addEventListener('test', listener2, foo);
 +			
 +			obj.fireEvent('test', {bar: 3});
 +		});
 +		
 +		it('should not call listeners removed through #removeEventListener', function() {
 +			var obj = new Klass(),
 +				spy = jasmine.createSpy();
 +			
 +			obj.addEventListener('test', spy);
 +			obj.removeEventListener('test', spy);
 +			
 +			obj.fireEvent('test');
 +			
 +			expect(spy).not.toHaveBeenCalled();
 +		});
 +	});
 +	
 +	describe('#on, #off & #fire', function() {
 +		
 +		it('should work like #addEventListener && #removeEventListener', function() {
 +			var obj = new Klass(),
 +				spy = jasmine.createSpy();
 +			
 +			obj.on('test', spy);
 +			obj.fire('test');
 +			
 +			expect(spy).toHaveBeenCalled();
 +			
 +			obj.off('test', spy);
 +			obj.fireEvent('test');
 +			
 +			expect(spy.callCount).toBeLessThan(2);
 +		});
 +		
 +		it('should not override existing methods with the same name', function() {
 +			var spy1 = jasmine.createSpy(),
 +				spy2 = jasmine.createSpy(),
 +				spy3 = jasmine.createSpy();
 +			
 +			var Klass2 = L.Class.extend({
 +				includes: L.Mixin.Events,
 +				on: spy1,
 +				off: spy2,
 +				fire: spy3
 +			});
 +			
 +			var obj = new Klass2();
 +			
 +			obj.on();
 +			expect(spy1).toHaveBeenCalled();
 +			
 +			obj.off();
 +			expect(spy2).toHaveBeenCalled();
 +			
 +			obj.fire();
 +			expect(spy3).toHaveBeenCalled();
 +		});
 +	});
 +});
\ No newline at end of file diff --git a/extlib/leaflet/spec/suites/core/UtilSpec.js b/extlib/leaflet/spec/suites/core/UtilSpec.js new file mode 100644 index 00000000..46cb8fba --- /dev/null +++ b/extlib/leaflet/spec/suites/core/UtilSpec.js @@ -0,0 +1,63 @@ +describe('Util', function() {
 +
 +	describe('#extend', function() {
 +		var a;
 +		
 +		beforeEach(function() {
 +			a = {
 +				foo: 5,
 +				bar: 'asd'
 +			};
 +		});
 +		
 +		it('should extend the first argument with the properties of the second', function() {
 +			L.Util.extend(a, {
 +				bar: 7,
 +				baz: 3
 +			});
 +			
 +			expect(a).toEqual({
 +				foo: 5,
 +				bar: 7,
 +				baz: 3
 +			});
 +		});
 +		
 +		it('should work with more than 2 arguments', function() {
 +			L.Util.extend(a, {bar: 7}, {baz: 3});
 +			
 +			expect(a).toEqual({
 +				foo: 5,
 +				bar: 7,
 +				baz: 3
 +			});
 +		});
 +	});
 +
 +	describe('#bind', function() {
 +		it('should return the given function with the given context', function() {
 +			var fn = function() {
 +				return this;
 +			};
 +			
 +			var fn2 = L.Util.bind(fn, 5);
 +			
 +			expect(fn2()).toEqual(5);
 +		});
 +	});
 +	
 +	describe('#stamp', function() {
 +		it('should set a unique id on the given object and return it', function() {
 +			var a = {},
 +				id = L.Util.stamp(a);
 +			
 +			expect(typeof id).toEqual('number');
 +			expect(L.Util.stamp(a)).toEqual(id);
 +			
 +			var b = {},
 +				id2 = L.Util.stamp(b);
 +			
 +			expect(id2).not.toEqual(id);
 +		});
 +	});
 +});
\ No newline at end of file diff --git a/extlib/leaflet/spec/suites/dom/DomEventSpec.js b/extlib/leaflet/spec/suites/dom/DomEventSpec.js new file mode 100644 index 00000000..83d08541 --- /dev/null +++ b/extlib/leaflet/spec/suites/dom/DomEventSpec.js @@ -0,0 +1,102 @@ +describe('DomEvent', function() {
 +	var el;
 +
 +	function simulateClick(el) {
 +		if (document.createEvent) {
 +			var e = document.createEvent('MouseEvents');
 +			e.initMouseEvent('click', true, true, window, 
 +					0, 0, 0, 0, 0, false, false, false, false, 0, null);
 +			return el.dispatchEvent(e);
 +		} else if (el.fireEvent) {
 +			return el.fireEvent('onclick');
 +		}
 +	}
 +	
 +	beforeEach(function() {
 +		el = document.createElement('div');
 +		el.style.position = 'absolute';
 +		el.style.top = el.style.left = '-10000px';
 +		document.body.appendChild(el);
 +	});
 +	
 +	afterEach(function() {
 +		document.body.removeChild(el);
 +	});
 +	
 +	describe('#addListener', function() {
 +		it('should add a listener and call it on event', function() {
 +			var listener1 = jasmine.createSpy('listener1'), 
 +				listener2 = jasmine.createSpy('listener2');
 +		
 +			L.DomEvent.addListener(el, 'click', listener1);
 +			L.DomEvent.addListener(el, 'click', listener2);
 +			
 +			simulateClick(el);
 +			
 +			expect(listener1).toHaveBeenCalled();
 +			expect(listener2).toHaveBeenCalled();
 +		});
 +		
 +		it('should have "this" keyword point to the given context', function() {
 +			var obj = {foo: 'bar'},
 +				result;
 +			
 +			L.DomEvent.addListener(el, 'click', function() {
 +				result = this;
 +			}, obj);
 +			
 +			simulateClick(el);
 +			
 +			expect(result).toEqual(obj);
 +		});
 +		
 +		it('should pass an event object to the listener', function() {
 +			var type;
 +			
 +			L.DomEvent.addListener(el, 'click', function(e) {
 +				type = e && e.type;
 +			});
 +			simulateClick(el);
 +			
 +			expect(type).toEqual('click');
 +		});
 +	});
 +	
 +	describe('#removeListener', function() {
 +		it('should remove prevously added listener', function() {
 +			var listener = jasmine.createSpy('listener');
 +			
 +			L.DomEvent.addListener(el, 'click', listener);
 +			L.DomEvent.removeListener(el, 'click', listener);
 +			
 +			simulateClick(el);
 +			
 +			expect(listener).not.toHaveBeenCalled();
 +		});
 +	});
 +	
 +	describe('#stopPropagation', function() {
 +		it('should stop propagation of the given event', function() {
 +			var child = document.createElement('div'),
 +				listener = jasmine.createSpy('listener');
 +			
 +			el.appendChild(child);
 +			
 +			L.DomEvent.addListener(child, 'click', L.DomEvent.stopPropagation);
 +			L.DomEvent.addListener(el, 'click', listener);
 +			
 +			simulateClick(child);
 +			
 +			expect(listener).not.toHaveBeenCalled();
 +			
 +			el.removeChild(child);
 +		});
 +	});
 +	describe('#preventDefault', function() {
 +		it('should prevent the default action of event', function() {
 +			L.DomEvent.addListener(el, 'click', L.DomEvent.preventDefault);
 +
 +			expect(simulateClick(el)).toBe(false);
 +		});
 +	});
 +});
\ No newline at end of file diff --git a/extlib/leaflet/spec/suites/dom/DomUtilSpec.js b/extlib/leaflet/spec/suites/dom/DomUtilSpec.js new file mode 100644 index 00000000..60de22fe --- /dev/null +++ b/extlib/leaflet/spec/suites/dom/DomUtilSpec.js @@ -0,0 +1,29 @@ +describe('DomUtil', function() {
 +	var el;
 +	
 +	beforeEach(function() {
 +		el = document.createElement('div');
 +		el.style.position = 'absolute';
 +		el.style.top = el.style.left = '-10000px';
 +		document.body.appendChild(el);
 +	});
 +	
 +	afterEach(function() {
 +		document.body.removeChild(el);
 +	});
 +	
 +	describe('#get', function() {
 +		it('should get element by id if the given argument is string', function() {
 +			el.id = 'testId';
 +			expect(L.DomUtil.get(el.id)).toBe(el);
 +		});
 +		
 +		it('should return the element if it is given as an argument', function() {
 +			expect(L.DomUtil.get(el)).toBe(el);
 +		});
 +	});
 +	
 +	describe('#setPosition', noSpecs);
 +	
 +	describe('#getStyle', noSpecs);
 +});
\ No newline at end of file diff --git a/extlib/leaflet/spec/suites/geo/LatLngBoundsSpec.js b/extlib/leaflet/spec/suites/geo/LatLngBoundsSpec.js new file mode 100644 index 00000000..be9bf12b --- /dev/null +++ b/extlib/leaflet/spec/suites/geo/LatLngBoundsSpec.js @@ -0,0 +1 @@ +describe('LatLngBounds', noSpecs);
\ No newline at end of file diff --git a/extlib/leaflet/spec/suites/geo/LatLngSpec.js b/extlib/leaflet/spec/suites/geo/LatLngSpec.js new file mode 100644 index 00000000..a7498e71 --- /dev/null +++ b/extlib/leaflet/spec/suites/geo/LatLngSpec.js @@ -0,0 +1,70 @@ +describe('LatLng', function() {
 +	describe('constructor', function() {
 +		it("should set lat and lng", function() {
 +			var a = new L.LatLng(25, 74);
 +			expect(a.lat).toEqual(25);
 +			expect(a.lng).toEqual(74);
 +	
 +			var a = new L.LatLng(-25, -74);
 +			expect(a.lat).toEqual(-25);
 +			expect(a.lng).toEqual(-74);
 +		});
 +		
 +		it("should clamp latitude to lie between -90 and 90", function() {
 +			var a = new L.LatLng(150, 0).lat;
 +			expect(a).toEqual(90);
 +			
 +			var b = new L.LatLng(-230, 0).lat;
 +			expect(b).toEqual(-90);
 +		});
 +		
 +		it("should clamp longtitude to lie between -180 and 180", function() {
 +			var a = new L.LatLng(0, 190).lng;
 +			expect(a).toEqual(-170);
 +	
 +			var b = new L.LatLng(0, 360).lng;
 +			expect(b).toEqual(0);
 +			
 +			var c = new L.LatLng(0, 380).lng;
 +			expect(c).toEqual(20);
 +	
 +			var d = new L.LatLng(0, -190).lng;
 +			expect(d).toEqual(170);
 +	
 +			var e = new L.LatLng(0, -360).lng;
 +			expect(e).toEqual(0);
 +	
 +			var f = new L.LatLng(0, -380).lng;
 +			expect(f).toEqual(-20);
 +		});
 +		
 +		it("should not clamp latitude and longtitude if unbounded flag set to true", function() {
 +			var a = new L.LatLng(150, 0, true).lat;
 +			expect(a).toEqual(150);
 +			
 +			var b = new L.LatLng(-230, 0, true).lat;
 +			expect(b).toEqual(-230);
 +	
 +			var c = new L.LatLng(0, 250, true).lng;
 +			expect(c).toEqual(250);
 +	
 +			var d = new L.LatLng(0, -190, true).lng;
 +			expect(d).toEqual(-190);
 +		});
 +	});
 +	
 +	describe('#equals', function() {
 +		it("should return true if compared objects are equal within a certain margin", function() {
 +			var a = new L.LatLng(10, 20);
 +			var b = new L.LatLng(10 + 1.0E-10, 20 - 1.0E-10);
 +			expect(a.equals(b)).toBe(true);
 +		});
 +		
 +		it("should return false if compared objects are not equal within a certain margin", function() {
 +			var a = new L.LatLng(10, 20);
 +			var b = new L.LatLng(10, 23.3);
 +			expect(a.equals(b)).toBe(false);
 +		});
 +	});
 +});
 +
 diff --git a/extlib/leaflet/spec/suites/geo/ProjectionSpec.js b/extlib/leaflet/spec/suites/geo/ProjectionSpec.js new file mode 100644 index 00000000..6b9c7b61 --- /dev/null +++ b/extlib/leaflet/spec/suites/geo/ProjectionSpec.js @@ -0,0 +1,42 @@ +describe("Projection.Mercator", function() {
 +	var p = L.Projection.Mercator;
 +	
 +	beforeEach(function() {
 +		function almostEqual(a, b, p) {
 +			return Math.abs(a - b) <= (p || 1.0E-12);
 +		};
 +		this.addMatchers({
 +			toAlmostEqual: function(expected, margin) {
 +				var p1 = this.actual,
 +					p2 = expected;
 +				return almostEqual(p1.x, p2.x, margin) && almostEqual(p1.y, p2.y, margin);
 +			}
 +		});
 +	});
 +	
 +
 +	describe("#project", function() {
 +		it("should do projection properly", function() {
 +			//edge cases
 +			expect(p.project(new L.LatLng(0, 0))).toAlmostEqual(new L.Point(0, 0));
 +			expect(p.project(new L.LatLng(90, 180))).toAlmostEqual(new L.Point(-Math.PI, Math.PI));
 +			expect(p.project(new L.LatLng(-90, -180))).toAlmostEqual(new L.Point(-Math.PI, -Math.PI));
 +			
 +			expect(p.project(new L.LatLng(50, 30))).toAlmostEqual(new L.Point(0.523598775598, 1.010683188683));
 +		});
 +	});
 +
 +	describe("#unproject", function() {
 +		it("should do unprojection properly", function() {
 +			function pr(point) {
 +				return p.project(p.unproject(point));
 +			}
 +			
 +			expect(pr(new L.Point(0, 0))).toAlmostEqual(new L.Point(0, 0));
 +			expect(pr(new L.Point(-Math.PI, Math.PI))).toAlmostEqual(new L.Point(-Math.PI, Math.PI));
 +			expect(pr(new L.Point(-Math.PI, -Math.PI))).toAlmostEqual(new L.Point(-Math.PI, -Math.PI));
 +			
 +			expect(pr(new L.Point(0.523598775598, 1.010683188683))).toAlmostEqual(new L.Point(0.523598775598, 1.010683188683));
 +		});
 +	});
 +});
\ No newline at end of file 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 diff --git a/extlib/leaflet/spec/suites/layer/TileLayerSpec.js b/extlib/leaflet/spec/suites/layer/TileLayerSpec.js new file mode 100644 index 00000000..28517ad9 --- /dev/null +++ b/extlib/leaflet/spec/suites/layer/TileLayerSpec.js @@ -0,0 +1 @@ +describe('TileLayer', noSpecs);
\ No newline at end of file diff --git a/extlib/leaflet/spec/suites/map/MapSpec.js b/extlib/leaflet/spec/suites/map/MapSpec.js new file mode 100644 index 00000000..7908b1a9 --- /dev/null +++ b/extlib/leaflet/spec/suites/map/MapSpec.js @@ -0,0 +1 @@ +describe("Map", noSpecs);
\ No newline at end of file | 
