]> git.openstreetmap.org Git - rails.git/blobdiff - test/javascripts/osm_test.js
Merge remote-tracking branch 'upstream/pull/5942'
[rails.git] / test / javascripts / osm_test.js
index 877af5ad71adf783aaadc38e54447af99ffd34cd..10d562959f39bd5a0d9a7284a5b8a1a5764b5162 100644 (file)
@@ -4,7 +4,6 @@
 //= require leaflet/dist/leaflet-src
 //= require leaflet.osm
 //= require leaflet.map
-//= require i18n/translations
 
 describe("OSM", function () {
   describe(".apiUrl", function () {
@@ -21,19 +20,11 @@ describe("OSM", function () {
     });
   });
 
-  describe(".params", function () {
-    it("parses params", function () {
-      const params = OSM.params("?foo=a&bar=b");
-      expect(params).to.have.property("foo", "a");
-      expect(params).to.have.property("bar", "b");
-    });
-  });
-
   describe(".mapParams", function () {
     beforeEach(function () {
       delete OSM.home;
       delete OSM.location;
-      document.location.hash = "";
+      location.hash = "";
       document.cookie = "_osm_location=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
 
       // Test with another cookie set.
@@ -83,7 +74,7 @@ describe("OSM", function () {
     });
 
     it("parses lat/lon/zoom from the hash", function () {
-      document.location.hash = "#map=16/57.6247/-3.6845";
+      location.hash = "#map=16/57.6247/-3.6845";
       const params = OSM.mapParams("?");
       expect(params).to.have.property("lat", 57.6247);
       expect(params).to.have.property("lon", -3.6845);
@@ -133,7 +124,7 @@ describe("OSM", function () {
       params = OSM.mapParams("?");
       expect(params).to.have.property("layers", "C");
 
-      document.location.hash = "#map=5/57.6247/-3.6845&layers=M";
+      location.hash = "#map=5/57.6247/-3.6845&layers=M";
       params = OSM.mapParams("?");
       expect(params).to.have.property("layers", "M");
     });
@@ -229,14 +220,15 @@ describe("OSM", function () {
 
   describe(".locationCookie", function () {
     it("creates a location cookie value", function () {
-      $("body").html($("<div id='map'>"));
+      $("body").append("<div id='map'>");
       const 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").remove();
     });
 
     it("respects zoomPrecision", function () {
-      $("body").html($("<div id='map'>"));
+      $("body").append("<div id='map'>");
       const 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");
@@ -244,6 +236,7 @@ describe("OSM", function () {
       // 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");
+      $("#map").remove();
     });
   });