1 describe('LatLng', function() {
2 describe('constructor', function() {
3 it("should set lat and lng", function() {
4 var a
= new L
.LatLng(25, 74);
5 expect(a
.lat
).toEqual(25);
6 expect(a
.lng
).toEqual(74);
8 var a
= new L
.LatLng(-25, -74);
9 expect(a
.lat
).toEqual(-25);
10 expect(a
.lng
).toEqual(-74);
13 it("should clamp latitude to lie between -90 and 90", function() {
14 var a
= new L
.LatLng(150, 0).lat
;
15 expect(a
).toEqual(90);
17 var b
= new L
.LatLng(-230, 0).lat
;
18 expect(b
).toEqual(-90);
21 it("should clamp longtitude to lie between -180 and 180", function() {
22 var a
= new L
.LatLng(0, 190).lng
;
23 expect(a
).toEqual(-170);
25 var b
= new L
.LatLng(0, 360).lng
;
28 var c
= new L
.LatLng(0, 380).lng
;
29 expect(c
).toEqual(20);
31 var d
= new L
.LatLng(0, -190).lng
;
32 expect(d
).toEqual(170);
34 var e
= new L
.LatLng(0, -360).lng
;
37 var f
= new L
.LatLng(0, -380).lng
;
38 expect(f
).toEqual(-20);
41 it("should not clamp latitude and longtitude if unbounded flag set to true", function() {
42 var a
= new L
.LatLng(150, 0, true).lat
;
43 expect(a
).toEqual(150);
45 var b
= new L
.LatLng(-230, 0, true).lat
;
46 expect(b
).toEqual(-230);
48 var c
= new L
.LatLng(0, 250, true).lng
;
49 expect(c
).toEqual(250);
51 var d
= new L
.LatLng(0, -190, true).lng
;
52 expect(d
).toEqual(-190);
56 describe('#equals', function() {
57 it("should return true if compared objects are equal within a certain margin", function() {
58 var a
= new L
.LatLng(10, 20);
59 var b
= new L
.LatLng(10 + 1.0E-10, 20 - 1.0E-10);
60 expect(a
.equals(b
)).toBe(true);
63 it("should return false if compared objects are not equal within a certain margin", function() {
64 var a
= new L
.LatLng(10, 20);
65 var b
= new L
.LatLng(10, 23.3);
66 expect(a
.equals(b
)).toBe(false);