From 42b7c5802db2b295ee3a3ed09fbc8c234bd65248 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 28 Feb 2014 00:28:26 +0000 Subject: [PATCH] Add tests for OSM.locationCookie --- test/javascripts/osm_test.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/javascripts/osm_test.js b/test/javascripts/osm_test.js index 5e982fc4d..d7fe4a2fd 100644 --- a/test/javascripts/osm_test.js +++ b/test/javascripts/osm_test.js @@ -2,6 +2,9 @@ //= require jquery.cookie //= require osm //= require leaflet +//= require leaflet.osm +//= require leaflet.map +//= require i18n/translations //= require querystring var querystring = require('querystring-component'); @@ -227,4 +230,23 @@ describe("OSM", function () { expect(OSM.zoomPrecision(20)).to.eq(5); }); }); + + describe(".locationCookie", function () { + it("creates a location cookie value", function () { + $("body").html($("
")); + var map = new L.OSM.Map("map", { center: [57.6247, -3.6845], zoom: 9 }); + map.updateLayers(""); + expect(OSM.locationCookie(map)).to.eq("-3.6845|57.6247|9|M"); + }); + + it("respects zoomPrecision", function () { + $("body").html($("
")); + var map = new L.OSM.Map("map", { center: [57.6247, -3.6845], zoom: 9 }); + map.updateLayers(""); + expect(OSM.locationCookie(map)).to.eq("-3.6845|57.6247|9|M"); + + map.setZoom(5); + expect(OSM.locationCookie(map)).to.eq("-3.685|57.625|5|M"); + }); + }); }); -- 2.43.2