Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

fix unit test, remove redux from ol coord

Ed Platoa4c4cfebce77
diff --git a/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap b/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap
index 2a088b2c9..9f3e70497 100644
--- a/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap
+++ b/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap
@@ -3,12 +3,22 @@
exports[`clears coordinates when mouse moves off the map 1`] = `
<div
id="ol-coords-case"
+ style={
+ Object {
+ "display": "block",
+ }
+ }
/>
`;
exports[`reprojects (0,0) to (-45, 90) for EPSG:3413 1`] = `
<div
id="ol-coords-case"
+ style={
+ Object {
+ "display": "block",
+ }
+ }
>
<div
className="wv-coords-map wv-coords-map-btn"
@@ -35,6 +45,11 @@ exports[`reprojects (0,0) to (-45, 90) for EPSG:3413 1`] = `
exports[`shows 20°00.000'N, 10°00.000'E when set to degrees and minutes format 1`] = `
<div
id="ol-coords-case"
+ style={
+ Object {
+ "display": "block",
+ }
+ }
>
<div
className="wv-coords-map wv-coords-map-btn"
@@ -61,6 +76,11 @@ exports[`shows 20°00.000'N, 10°00.000'E when set to degrees and minutes format
exports[`shows coordinates of (-160, 20) when moving the mouse over wrapped 1`] = `
<div
id="ol-coords-case"
+ style={
+ Object {
+ "display": "block",
+ }
+ }
>
<div
className="wv-coords-map wv-coords-map-btn"
@@ -87,6 +107,11 @@ exports[`shows coordinates of (-160, 20) when moving the mouse over wrapped 1`]
exports[`shows coordinates of (10, 20) when moving the mouse 1`] = `
<div
id="ol-coords-case"
+ style={
+ Object {
+ "display": "block",
+ }
+ }
>
<div
className="wv-coords-map wv-coords-map-btn"
diff --git a/web/js/components/map/coordinates.js b/web/js/components/map/coordinates.js
index 74f381393..db808083e 100644
--- a/web/js/components/map/coordinates.js
+++ b/web/js/components/map/coordinates.js
@@ -9,7 +9,7 @@ const formatOrder = {
'latlon-dms': 'latlon-dd'
};
-class Coordinates extends React.Component {
+export class Coordinates extends React.Component {
constructor(props) {
super(props);
this.changeFormat = this.changeFormat.bind(this);
diff --git a/web/js/components/map/ol-coordinates.js b/web/js/components/map/ol-coordinates.js
index 29dcdc14e..e90b7f058 100644
--- a/web/js/components/map/ol-coordinates.js
+++ b/web/js/components/map/ol-coordinates.js
@@ -1,11 +1,10 @@
import React from 'react';
import PropTypes from 'prop-types';
-import { connect } from 'react-redux';
import Coordinates from './coordinates';
import util from '../../util/util';
import { transform } from 'ol/proj';
-class OlCoordinates extends React.Component {
+export class OlCoordinates extends React.Component {
constructor(props) {
super(props);
this.state = {
@@ -99,19 +98,9 @@ class OlCoordinates extends React.Component {
}
}
-function mapStateToProps(state) {
- return {
- isDistractionFreeModeActive: state.ui.isDistractionFreeModeActive
- };
-}
-
OlCoordinates.propTypes = {
mouseEvents: PropTypes.object.isRequired,
isDistractionFreeModeActive: PropTypes.bool
};
-// export default OlCoordinates;
-
-export default connect(
- mapStateToProps
-)(OlCoordinates);
+export default OlCoordinates;
diff --git a/web/js/components/map/ol-coordinates.test.js b/web/js/components/map/ol-coordinates.test.js
index 6da1304a1..44a686910 100644
--- a/web/js/components/map/ol-coordinates.test.js
+++ b/web/js/components/map/ol-coordinates.test.js
@@ -1,8 +1,8 @@
import React from 'react';
-import renderer from 'react-test-renderer';
import util from '../../util/util';
-import OlCoordinates from './ol-coordinates';
+import { OlCoordinates } from './ol-coordinates';
import { registerProjections } from '../../fixtures';
+import renderer from 'react-test-renderer';
let events;
let component;
@@ -11,7 +11,12 @@ let map;
beforeEach(() => {
registerProjections();
events = util.events();
- component = renderer.create(<OlCoordinates mouseEvents={events} />);
+ component = renderer.create(
+ <OlCoordinates
+ mouseEvents={events}
+ distractionFreeMode={false}
+ />
+ );
map = {
getEventPixel: jest.fn(),
getCoordinateFromPixel: () => [0, 0]
diff --git a/web/js/containers/map-interactions.js b/web/js/containers/map-interactions.js
index 0a720796c..6156be792 100644
--- a/web/js/containers/map-interactions.js
+++ b/web/js/containers/map-interactions.js
@@ -73,13 +73,20 @@ export class MapInteractions extends React.Component {
}
render() {
- const { isShowingClick, mouseEvents } = this.props;
+ const {
+ isDistractionFreeModeActive,
+ isShowingClick,
+ mouseEvents
+ } = this.props;
const mapClasses = isShowingClick ? 'wv-map' + ' cursor-pointer' : 'wv-map';
return (
<React.Fragment>
<div id="wv-map" className={mapClasses} />
- <OlCoordinates mouseEvents={mouseEvents} />
+ <OlCoordinates
+ mouseEvents={mouseEvents}
+ isDistractionFreeModeActive={isDistractionFreeModeActive}
+ />
</React.Fragment>
);
}
@@ -127,7 +134,7 @@ const mapDispatchToProps = dispatch => ({
}
});
function mapStateToProps(state) {
- const { modal, map, measure, vectorStyles, browser, compare, proj } = state;
+ const { modal, map, measure, vectorStyles, browser, compare, proj, ui } = state;
let swipeOffset;
if (compare.active && compare.mode === 'swipe') {
const percentOffset = state.compare.value || 50;
@@ -136,6 +143,7 @@ function mapStateToProps(state) {
return {
modalState: modal,
isShowingClick: map.isClickable,
+ isDistractionFreeModeActive: ui.isDistractionFreeModeActive,
getDialogObject: (pixels, map) => onMapClickGetVectorFeatures(pixels, map, state, swipeOffset),
lastSelected: vectorStyles.selected,
measureIsActive: measure.isActive,
@@ -148,6 +156,7 @@ function mapStateToProps(state) {
MapInteractions.propTypes = {
changeCursor: PropTypes.func.isRequired,
getDialogObject: PropTypes.func.isRequired,
+ isDistractionFreeModeActive: PropTypes.bool.isRequired,
isShowingClick: PropTypes.bool.isRequired,
measureIsActive: PropTypes.bool.isRequired,
modalState: PropTypes.object.isRequired,
diff --git a/web/js/containers/map-interactions.test.js b/web/js/containers/map-interactions.test.js
index c72132c99..7d2d998d3 100644
--- a/web/js/containers/map-interactions.test.js
+++ b/web/js/containers/map-interactions.test.js
@@ -30,6 +30,7 @@ beforeEach(() => {
measureIsActive={false}
onCloseModal={jest.fn()}
modalState={{ id: [], isOpen: false }}
+ isDistractionFreeModeActive={false}
/>,
{
createNodeMock: (element) => {