Interactive interface for browsing global, full-resolution satellite imagery
make test account for debounce #2420
Benjamin Kingac31beab7793
diff --git a/package.json b/package.jsonindex 31261ca9f..0f49b210b 100644--- a/package.json+++ b/package.json@@ -226,4 +226,4 @@"prettier": {"singleQuote": true}-}\ No newline at end of file+}diff --git a/web/js/containers/map-interactions.js b/web/js/containers/map-interactions.jsindex 74ce3bf4f..d5bcf5e52 100644--- a/web/js/containers/map-interactions.js+++ b/web/js/containers/map-interactions.js@@ -12,7 +12,6 @@ import { changeCursor } from '../modules/map/actions';export class MapInteractions extends React.Component {constructor(props) {super(props);- this.mouseMove = this.mouseMove.bind(this);this.mouseMove = lodashDebounce(this.mouseMove.bind(this), 8);this.singleClick = this.singleClick.bind(this);this.registerMouseListeners();diff --git a/web/js/containers/map-interactions.test.js b/web/js/containers/map-interactions.test.jsindex 1b3330e4a..c72132c99 100644--- a/web/js/containers/map-interactions.test.js+++ b/web/js/containers/map-interactions.test.js@@ -27,6 +27,7 @@ beforeEach(() => {openVectorDiaglog={openVectorDiaglog}selectVectorFeatures={selectVectorFeatures}lastSelected={{}}+ measureIsActive={false}onCloseModal={jest.fn()}modalState={{ id: [], isOpen: false }}/>,@@ -48,7 +49,7 @@ beforeEach(() => {test('if there is a feature at pixel dispatch changeCursor action', () => {map.hasFeatureAtPixel = () => true;events.trigger('mousemove', {}, map, 'EPSG:3413');- expect(changeCursor.mock.calls.length).toBe(1);+ doAsync(() => expect(changeCursor.mock.calls.length).toBe(1));});test('if there is a feature at pixel on click get dialog', () => {events.trigger('singleclick', { pixel: [0, 0] }, map, 'EPSG:4326');@@ -59,13 +60,18 @@ test('if there is a feature at pixel on click get dialog', () => {test('if there is not a feature at pixel do not dispatch changeCursor action', () => {map.hasFeatureAtPixel = () => false;events.trigger('mousemove', { pixel: [0, 0] }, map, 'EPSG:4326');- expect(changeCursor.mock.calls.length).toBe(0);+ doAsync(() => expect(changeCursor.mock.calls.length).toBe(0));});test('Check that hover changes', () => {map.hasFeatureAtPixel = () => false;events.trigger('mousemove', { pixel: [0, 0] }, map, 'EPSG:4326');- expect(changeCursor.mock.calls.length).toBe(0);+ doAsync(() => expect(changeCursor.mock.calls.length).toBe(0));});test('Check that cursor-hover class is not present', () => {expect(component.toJSON()).toMatchSnapshot();});+function doAsync(c) {+ setTimeout(() => {+ c(true);+ }, 10);+}