Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Update coordinate tests #2551

Benjamin King8da0a8ccacdd
diff --git a/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap b/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap
new file mode 100644
index 000000000..2a088b2c9
--- /dev/null
+++ b/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap
@@ -0,0 +1,111 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`clears coordinates when mouse moves off the map 1`] = `
+<div
+ id="ol-coords-case"
+/>
+`;
+
+exports[`reprojects (0,0) to (-45, 90) for EPSG:3413 1`] = `
+<div
+ id="ol-coords-case"
+>
+ <div
+ className="wv-coords-map wv-coords-map-btn"
+ onClick={[Function]}
+ >
+ <span
+ className="map-coord"
+ >
+ 90.0000°, -45.0000°
+
+ EPSG:3413
+ </span>
+ <div
+ className="coord-btn"
+ >
+ <i
+ className="coord-switch"
+ />
+ </div>
+ </div>
+</div>
+`;
+
+exports[`shows 20°00.000'N, 10°00.000'E when set to degrees and minutes format 1`] = `
+<div
+ id="ol-coords-case"
+>
+ <div
+ className="wv-coords-map wv-coords-map-btn"
+ onClick={[Function]}
+ >
+ <span
+ className="map-coord"
+ >
+ 20°00.000'N, 10°00.000'E
+
+ EPSG:4326
+ </span>
+ <div
+ className="coord-btn"
+ >
+ <i
+ className="coord-switch"
+ />
+ </div>
+ </div>
+</div>
+`;
+
+exports[`shows coordinates of (-160, 20) when moving the mouse over wrapped 1`] = `
+<div
+ id="ol-coords-case"
+>
+ <div
+ className="wv-coords-map wv-coords-map-btn"
+ onClick={[Function]}
+ >
+ <span
+ className="map-coord"
+ >
+ 20.0000°, -160.0000°
+
+ EPSG:4326
+ </span>
+ <div
+ className="coord-btn"
+ >
+ <i
+ className="coord-switch"
+ />
+ </div>
+ </div>
+</div>
+`;
+
+exports[`shows coordinates of (10, 20) when moving the mouse 1`] = `
+<div
+ id="ol-coords-case"
+>
+ <div
+ className="wv-coords-map wv-coords-map-btn"
+ onClick={[Function]}
+ >
+ <span
+ className="map-coord"
+ >
+ 20.0000°, 10.0000°
+
+ EPSG:4326
+ </span>
+ <div
+ className="coord-btn"
+ >
+ <i
+ className="coord-switch"
+ />
+ </div>
+ </div>
+</div>
+`;
diff --git a/web/js/components/map/ol-coordinates-test.js b/web/js/components/map/ol-coordinates.test.js
similarity index 82%
rename from web/js/components/map/ol-coordinates-test.js
rename to web/js/components/map/ol-coordinates.test.js
index 8e7419797..6da1304a1 100644
--- a/web/js/components/map/ol-coordinates-test.js
+++ b/web/js/components/map/ol-coordinates.test.js
@@ -28,7 +28,13 @@ test('shows coordinates of (10, 20) when moving the mouse', () => {
expect(component.toJSON()).toMatchSnapshot();
});
-test('shows 10°00.000\'N, 20°00.000\'E when set to degrees and minutes format', () => {
+test('shows coordinates of (-160, 20) when moving the mouse over wrapped', () => {
+ map.getCoordinateFromPixel = () => [200, 20];
+ events.trigger('mousemove', {}, map, 'EPSG:4326');
+ expect(component.toJSON()).toMatchSnapshot();
+});
+
+test('shows 20°00.000\'N, 10°00.000\'E when set to degrees and minutes format', () => {
util.setCoordinateFormat('latlon-dm');
map.getCoordinateFromPixel = () => [10, 20];
events.trigger('mousemove', {}, map, 'EPSG:4326');
diff --git a/web/js/util/util.test.js b/web/js/util/util.test.js
index 93643e374..4f6ac939b 100644
--- a/web/js/util/util.test.js
+++ b/web/js/util/util.test.js
@@ -389,6 +389,14 @@ describe('formatDM', () => {
});
});
+test('Convert wrapped longitude to value between -180 & 180', () => {
+ expect(util.normalizeWrappedLongitude(-181)).toBe(179);
+ expect(util.normalizeWrappedLongitude(181)).toBe(-179);
+ expect(util.normalizeWrappedLongitude(-721)).toBe(-1);
+ expect(util.normalizeWrappedLongitude(721)).toBe(1);
+ expect(util.normalizeWrappedLongitude(541)).toBe(-179);
+ expect(util.normalizeWrappedLongitude(-541)).toBe(179);
+});
describe('encodeId/decodeId', () => {
const tests = [
{ decoded: '', encoded: '' },