+ it("suggests 5 digits for z13-16", function () {
+ expect(OSM.zoomPrecision(13)).to.eq(5);
+ expect(OSM.zoomPrecision(14)).to.eq(5);
+ expect(OSM.zoomPrecision(15)).to.eq(5);
+ expect(OSM.zoomPrecision(16)).to.eq(5);
+ });
+
+ it("suggests 6 digits for z17-19", function () {
+ expect(OSM.zoomPrecision(17)).to.eq(6);
+ expect(OSM.zoomPrecision(18)).to.eq(6);
+ expect(OSM.zoomPrecision(19)).to.eq(6);
+ });
+
+ it("suggests 7 digits for z20", function () {
+ expect(OSM.zoomPrecision(20)).to.eq(7);
+ });
+ });
+
+ describe(".locationCookie", function () {
+ it("creates a location cookie value", function () {
+ $("body").html($("<div id='map'>"));
+ var map = new L.OSM.Map("map", { center: [57.6247, -3.6845], zoom: 9 });
+ map.updateLayers("");
+ expect(OSM.locationCookie(map)).to.eq("-3.685|57.625|9|M");
+ });
+
+ it("respects zoomPrecision", function () {
+ $("body").html($("<div id='map'>"));
+ var map = new L.OSM.Map("map", { center: [57.6247, -3.6845], zoom: 9 });
+ map.updateLayers("");
+ expect(OSM.locationCookie(map)).to.eq("-3.685|57.625|9|M");
+ // map.setZoom() doesn't update the zoom level for some reason
+ // using map._zoom here to update the zoom level manually
+ map._zoom = 5;
+ expect(OSM.locationCookie(map)).to.eq("-3.68|57.62|5|M");
+ });
+ });
+
+ describe(".distance", function () {
+ it("computes distance between points", function () {
+ var latlng1 = L.latLng(51.76712, -0.00484),
+ latlng2 = L.latLng(51.7675159, -0.0078329);
+
+ expect(OSM.distance(latlng1, latlng2)).to.be.closeTo(210.664, 0.005);
+ expect(OSM.distance(latlng2, latlng1)).to.be.closeTo(210.664, 0.005);