Skip to content

Commit f568351

Browse files
committed
Make sure window.proj4 is always restored
1 parent a924908 commit f568351

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

test/spec/ol/proj/proj.test.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ describe('ol.proj', function() {
209209

210210
describe('Proj4js integration', function() {
211211

212+
var proj4 = window.proj4;
213+
214+
afterEach(function() {
215+
delete proj4.defs['EPSG:21781'];
216+
window.proj4 = proj4;
217+
ol.proj.setProj4(window.proj4);
218+
});
219+
212220
it('creates ol.proj.Projection instance from EPSG:21781', function() {
213221
proj4.defs('EPSG:21781',
214222
'+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' +
@@ -218,8 +226,6 @@ describe('ol.proj', function() {
218226
expect(proj.getCode()).to.eql('EPSG:21781');
219227
expect(proj.getUnits()).to.eql('m');
220228
expect(proj.getMetersPerUnit()).to.eql(1);
221-
222-
delete proj4.defs['EPSG:21781'];
223229
});
224230

225231
it('can use an alternative namespace for proj4', function() {
@@ -235,10 +241,6 @@ describe('ol.proj', function() {
235241
expect(proj.getCode()).to.eql('EPSG:21781');
236242
expect(proj.getUnits()).to.eql('m');
237243
expect(proj.getMetersPerUnit()).to.eql(1);
238-
239-
delete proj4new.defs['EPSG:21781'];
240-
window.proj4 = proj4;
241-
ol.proj.setProj4(window.proj4);
242244
});
243245

244246
it('creates ol.proj.Projection instance from EPSG:3739', function() {
@@ -250,8 +252,6 @@ describe('ol.proj', function() {
250252
expect(proj.getCode()).to.eql('EPSG:3739');
251253
expect(proj.getUnits()).to.eql('us-ft');
252254
expect(proj.getMetersPerUnit()).to.eql(1200 / 3937);
253-
254-
delete proj4.defs['EPSG:3739'];
255255
});
256256

257257
it('allows Proj4js projections to be used transparently', function() {
@@ -270,7 +270,6 @@ describe('ol.proj', function() {
270270
'EPSG:4326', 'EPSG:21781');
271271
expect(point[0]).to.roughlyEqual(600072.300, 1);
272272
expect(point[1]).to.roughlyEqual(200146.976, 1);
273-
delete proj4.defs['EPSG:21781'];
274273
});
275274

276275
it('works with ol.proj.fromLonLat and ol.proj.toLonLat', function() {
@@ -285,7 +284,6 @@ describe('ol.proj', function() {
285284
point = ol.proj.toLonLat(point, 'EPSG:21781');
286285
expect(point[0]).to.roughlyEqual(lonLat[0], 1);
287286
expect(point[1]).to.roughlyEqual(lonLat[1], 1);
288-
delete proj4.defs['EPSG:21781'];
289287
});
290288

291289
it('caches the new Proj4js projections given their srsCode', function() {
@@ -300,7 +298,6 @@ describe('ol.proj', function() {
300298
var proj2 = ol.proj.get(srsCode);
301299
expect(ol.proj.equivalent(proj2, proj)).to.be(true);
302300
delete proj4.defs[code];
303-
delete proj4.defs[srsCode];
304301
});
305302

306303
it('numerically estimates point scale at the equator', function() {

0 commit comments

Comments
 (0)