From b2d18d1ebef342ea3448cedc0182d9804f125f18 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Wed, 18 Aug 2021 12:40:51 -0400 Subject: [PATCH] Fix hash tests in Chrome, avoid loading imagery tiles --- test/spec/behavior/hash.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/spec/behavior/hash.js b/test/spec/behavior/hash.js index c1af7adbe..f6d52b896 100644 --- a/test/spec/behavior/hash.js +++ b/test/spec/behavior/hash.js @@ -4,6 +4,7 @@ describe('iD.behaviorHash', function () { var hash, context; beforeEach(function () { + window.location.hash = '#background=none'; // Try not to load imagery var container = d3.select(document.createElement('div')); context = iD.coreContext().assetPath('../dist/').init().container(container); container.call(context.map()); @@ -12,17 +13,18 @@ describe('iD.behaviorHash', function () { afterEach(function () { hash.off(); - location.hash = ''; + window.location.hash = '#background=none'; // Try not to load imagery }); - it('sets hadHash if location.hash is present', function () { - location.hash = 'map=20.00/38.87952/-77.02405'; + + it('sets hadHash if window.location.hash is present', function () { + window.location.hash = '#background=none&map=20.00/38.87952/-77.02405'; hash(); expect(hash.hadHash).to.be.true; }); it('centerZooms map to requested level', function () { - location.hash = 'map=20.00/38.87952/-77.02405'; + window.location.hash = '#background=none&map=20.00/38.87952/-77.02405'; hash(); expect(context.map().center()[0]).to.be.closeTo(-77.02405, 0.1); expect(context.map().center()[1]).to.be.closeTo(38.87952, 0.1); @@ -38,16 +40,15 @@ describe('iD.behaviorHash', function () { d3.select(window).on('hashchange', null); done(); }); - location.hash = 'map=20.00/38.87952/-77.02405'; + window.location.hash = '#background=none&map=20.00/38.87952/-77.02405'; }); - it('stores the current zoom and coordinates in location.hash on map move events', function (done) { - location.hash = ''; + it('stores the current zoom and coordinates in window.location.hash on map move events', function (done) { hash(); context.map().center([-77.0, 38.9]); context.map().zoom(2.0); window.setTimeout(function() { - expect(location.hash).to.equal('#map=2.00/38.9/-77.0'); + expect(window.location.hash).to.equal('#background=none&map=2.00/38.9/-77.0'); done(); }, 300); });