aboutsummaryrefslogtreecommitdiffstats
path: root/extlib/leaflet/spec/suites/geometry/BoundsSpec.js
blob: eee05e4bf2675dc169ca603eb5d0a43ad42d1405 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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));
		});
	});
});