Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Test hash. Fixes #92

  • Loading branch information...
commit ddc073b6802bf5272fb3b6e7dde0a6a6d0fd421f 1 parent 25cfffb
@tmcw tmcw authored
Showing with 39 additions and 0 deletions.
  1. +1 −0  test/browser/index.html
  2. +38 −0 test/browser/spec/Hash.js
View
1  test/browser/index.html
@@ -19,6 +19,7 @@
<script type="text/javascript" src="spec/Point.js"></script>
<script type="text/javascript" src="spec/Map.js"></script>
<script type="text/javascript" src="spec/Layer.js"></script>
+ <script type="text/javascript" src="spec/Hash.js"></script>
<script type="text/javascript" src="spec/Location.js"></script>
<script type="text/javascript" src="spec/Extent.js"></script>
<script type="text/javascript" src="spec/DragHandler.js"></script>
View
38 test/browser/spec/Hash.js
@@ -0,0 +1,38 @@
+describe('Hash', function() {
+ var map, initial_zoom = 10;
+
+ beforeEach(function() {
+ var div = document.createElement('div');
+
+ window.location.hash = '';
+
+ map = new MM.Map(div, new MM.TemplatedLayer(
+ 'http://{S}tile.openstreetmap.org/{Z}/{X}/{Y}.png', ['a.']),
+ new MM.Point(10, 10));
+
+ new MM.Hash(map);
+ });
+
+ it('should not mess with map movement', function() {
+ runs(function() {
+ map.setCenterZoom(new MM.Location(25, 25), 2);
+ });
+ waits(600);
+ runs(function() {
+ var center = map.getCenter();
+ expect(Math.round(center.lat)).toEqual(25);
+ expect(Math.round(center.lon)).toEqual(25);
+ expect(map.getZoom()).toEqual(2);
+ });
+ });
+
+ it('sets the right location hash', function() {
+ runs(function() {
+ map.setCenterZoom(new MM.Location(25, 25), 2);
+ });
+ waits(1000);
+ runs(function() {
+ expect(window.location.hash).toEqual('#2/25.0/25.0');
+ });
+ });
+});
Please sign in to comment.
Something went wrong with that request. Please try again.