diff --git a/web/client/components/geostory/common/enhancers/__tests__/map-test.jsx b/web/client/components/geostory/common/enhancers/__tests__/map-test.jsx index f0e5d96255..9cb1f6b49e 100644 --- a/web/client/components/geostory/common/enhancers/__tests__/map-test.jsx +++ b/web/client/components/geostory/common/enhancers/__tests__/map-test.jsx @@ -13,7 +13,8 @@ import ReactTestUtils from 'react-dom/test-utils'; import {createSink} from 'recompose'; import Toolbar from '../../../../misc/toolbar/Toolbar'; -import {withLocalMapState, withMapEditingAndLocalMapState, withToolbar} from '../map'; +import withMapEnhancer, { withLocalMapState, withMapEditingAndLocalMapState, withToolbar } from '../map'; +import { Provider } from 'react-redux'; describe("geostory media map component enhancers", () => { beforeEach((done) => { @@ -25,6 +26,20 @@ describe("geostory media map component enhancers", () => { document.body.innerHTML = ''; setTimeout(done); }); + it('withMapEnhancer generate correct props', (done) => { + const resources = [{id: "1", type: "map", data: {id: "2", layers: [], context: "1"}}]; + const store = { + subscribe: () => {}, getState: () => ({geostory: {currentStory: {resources}}}) + }; + const resourceId = "1"; + const Sink = withMapEnhancer(createSink( props => { + expect(props).toBeTruthy(); + expect(props.map).toBeTruthy(); + expect(props.map).toEqual({id: "2", layers: []}); + done(); + })); + ReactDOM.render(, document.getElementById("container")); + }); it('withLocalMapState generate correct props', (done) => { const Sink = withLocalMapState(createSink( props => { expect(props).toExist(); diff --git a/web/client/components/geostory/common/enhancers/map.jsx b/web/client/components/geostory/common/enhancers/map.jsx index 8951fc13ef..1d87438884 100644 --- a/web/client/components/geostory/common/enhancers/map.jsx +++ b/web/client/components/geostory/common/enhancers/map.jsx @@ -6,7 +6,7 @@ * LICENSE file in the root directory of this source tree. */ -import { find, isEqual } from 'lodash'; +import { find, isEqual, omit } from 'lodash'; import React from 'react'; import {connect} from 'react-redux'; import {branch, compose, createEventHandler, mapPropsStream, withHandlers, withProps, withPropsOnChange, withStateHandlers} from 'recompose'; @@ -39,7 +39,7 @@ export default compose( ({ resources, resourceId, map = {}}) => { const cleanedMap = {...map, layers: (map.layers || []).map(l => l ? l : undefined)}; const resource = find(resources, { id: resourceId }) || {}; - return { map: createMapObject(resource.data, cleanedMap)}; + return { map: createMapObject(omit(resource.data, ['context']), cleanedMap)}; } )); /**