Interactive interface for browsing global, full-resolution satellite imagery
update coordinates tests and snapshots
Jason Kentd8fde6dee6d8
diff --git a/web/js/components/map/__snapshots__/coordinates.test.js.snap b/web/js/components/map/__snapshots__/coordinates.test.js.snapindex 635f7cae4..8e7f928f8 100644--- a/web/js/components/map/__snapshots__/coordinates.test.js.snap+++ b/web/js/components/map/__snapshots__/coordinates.test.js.snap@@ -1,67 +1,7 @@// Jest Snapshot v1, https://goo.gl/fbAQLP-exports[`formats coordinate in latlon-dd format 1`] = `-<div- className="wv-coords-map wv-coords-map-btn"- onClick={[Function]}->- <span- className="map-coord"- >- 0.0000°, 0.0000°-- EPSG:4326- </span>- <div- className="coord-btn"- >- <i- className="coord-switch"- />- </div>-</div>-`;+exports[`formats coordinate in latlon-dd format 1`] = `"<div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\">0.0000°, 0.0000° EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div>"`;-exports[`formats coordinate in latlon-dm format 1`] = `-<div- className="wv-coords-map wv-coords-map-btn"- onClick={[Function]}->- <span- className="map-coord"- >- 0°00.000'N, 0°00.000'E-- EPSG:4326- </span>- <div- className="coord-btn"- >- <i- className="coord-switch"- />- </div>-</div>-`;+exports[`formats coordinate in latlon-dm format 1`] = `"<div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\"> 0°00.000'N, 0°00.000'E EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div>"`;-exports[`formats coordinate in latlon-dms format 1`] = `-<div- className="wv-coords-map wv-coords-map-btn"- onClick={[Function]}->- <span- className="map-coord"- >- 0°00'00"N, 0°00'00"E-- EPSG:4326- </span>- <div- className="coord-btn"- >- <i- className="coord-switch"- />- </div>-</div>-`;+exports[`formats coordinate in latlon-dms format 1`] = `"<div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\"> 0°00'00\\"N, 0°00'00\\"E EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div>"`;diff --git a/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap b/web/js/components/map/__snapshots__/ol-coordinates.test.js.snapindex 2a088b2c9..523f13e10 100644--- a/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap+++ b/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap@@ -1,111 +1,11 @@// Jest Snapshot v1, https://goo.gl/fbAQLP-exports[`clears coordinates when mouse moves off the map 1`] = `-<div- id="ol-coords-case"-/>-`;+exports[`clears coordinates when mouse moves off the map 1`] = `"<div id=\\"ol-coords-case\\"></div>"`;-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[`reprojects (0,0) to (-45, 90) for EPSG:3413 1`] = `"<div id=\\"ol-coords-case\\"><div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\">90.0000°, -45.0000° EPSG:3413</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></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 20°00.000'N, 10°00.000'E when set to degrees and minutes format 1`] = `"<div id=\\"ol-coords-case\\"><div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\">20°00.000'N, 10°00.000'E EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></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 (-160, 20) when moving the mouse over wrapped 1`] = `"<div id=\\"ol-coords-case\\"><div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\">20.0000°, -160.0000° EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></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>-`;+exports[`shows coordinates of (10, 20) when moving the mouse 1`] = `"<div id=\\"ol-coords-case\\"><div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\">20.0000°, 10.0000° EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div></div>"`;diff --git a/web/js/components/map/coordinates.test.js b/web/js/components/map/coordinates.test.jsindex b71c7b176..da3079c0e 100644--- a/web/js/components/map/coordinates.test.js+++ b/web/js/components/map/coordinates.test.js@@ -1,35 +1,53 @@/* eslint-disable no-restricted-syntax */import React from 'react';-import renderer from 'react-test-renderer';+import { render, unmountComponentAtNode } from 'react-dom';+import { act } from 'react-dom/test-utils';import Coordinates from './coordinates';+let container;++beforeEach(() => {+ container = document.createElement('div');+ document.body.appendChild(container);+});++afterEach(() => {+ unmountComponentAtNode(container);+ container.remove();+ container = null;+});+describe('formats', () => {const formats = ['latlon-dd', 'latlon-dm', 'latlon-dms'];for (const format of formats) {+ // eslint-disable-next-line no-loop-functest(`coordinate in ${format} format`, () => {- const component = renderer.create(<Coordinates- format={format}- latitude={0}- longitude={0}- crs="EPSG:4326"- onFormatChange={jest.fn()}- />);- expect(component.toJSON()).toMatchSnapshot();+ act(() => {+ render(<Coordinates+ format={format}+ latitude={0}+ longitude={0}+ crs="EPSG:4326"+ onFormatChange={jest.fn()}+ />, container);+ });+ expect(container.innerHTML).toMatchSnapshot();});}});test('change format from latlon-dd to latlon-dm', () => {const callback = jest.fn();- const component = renderer.create(<Coordinates- format="latlon-dd"- latitude={0}- longitude={0}- crs="EPSG:4326"- onFormatChange={callback}- />);+ act(() => {+ const component = render(<Coordinates+ format="latlon-dd"+ latitude={0}+ longitude={0}+ crs="EPSG:4326"+ onFormatChange={callback}+ />, container);- const tree = component.toJSON();- tree.props.onClick();- expect(callback).toBeCalledWith('latlon-dm');+ component.changeFormat();+ expect(callback).toBeCalledWith('latlon-dm');+ });});diff --git a/web/js/components/map/ol-coordinates.test.js b/web/js/components/map/ol-coordinates.test.jsindex 580b5db03..c286cd91c 100644--- a/web/js/components/map/ol-coordinates.test.js+++ b/web/js/components/map/ol-coordinates.test.js@@ -1,59 +1,63 @@import React from 'react';-import renderer from 'react-test-renderer';+import { render, unmountComponentAtNode } from 'react-dom';+import { act } from 'react-dom/test-utils';import util from '../../util/util';import OlCoordinates from './ol-coordinates';import { registerProjections } from '../../fixtures';let events;-let component;+let container;let map;beforeEach(() => {+ container = document.createElement('div');+ document.body.appendChild(container);registerProjections();events = util.events();- component = renderer.create(- <OlCoordinates- mouseEvents={events}- />,- );map = {getEventPixel: jest.fn(),getCoordinateFromPixel: () => [0, 0],};+ act(() => {+ render(<OlCoordinates mouseEvents={events} />, container);+ });});afterEach(() => {util.setCoordinateFormat('latlon-dd');+ unmountComponentAtNode(container);+ container.remove();+ container = null;});test('shows coordinates of (10, 20) when moving the mouse', () => {map.getCoordinateFromPixel = () => [10, 20];events.trigger('mousemove', {}, map, 'EPSG:4326');- expect(component.toJSON()).toMatchSnapshot();+ expect(container.innerHTML).toMatchSnapshot();});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();+ expect(container.innerHTML).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');- expect(component.toJSON()).toMatchSnapshot();+ expect(container.innerHTML).toMatchSnapshot();});test('clears coordinates when mouse moves off the map', () => {map.getCoordinateFromPixel = () => [10, 20];events.trigger('mousemove', {}, map, 'EPSG:4326');events.trigger('mouseout', {}, map, 'EPSG:4326');- expect(component.toJSON()).toMatchSnapshot();+ expect(container.innerHTML).toMatchSnapshot();});test('reprojects (0,0) to (-45, 90) for EPSG:3413', () => {map.getCoordinateFromPixel = () => [0, 0];events.trigger('mousemove', {}, map, 'EPSG:3413');- expect(component.toJSON()).toMatchSnapshot();+ expect(container.innerHTML).toMatchSnapshot();});