Skip to content

Commit

Permalink
Fix geosolutions-it#2794 Force update of map widget position on save (g…
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz authored and kappu committed Apr 26, 2018
1 parent 64867a8 commit 5d38f31
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
10 changes: 2 additions & 8 deletions web/client/components/widgets/builder/wizard/map/PreviewMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,5 @@
* LICENSE file in the root directory of this source tree.
*/


const { compose, withHandlers} = require('recompose');

module.exports = compose(
withHandlers({
onMapViewChanges: ({onChange = () => {}}) => map => onChange('map', map)
})
)(require('../../../widget/MapView'));
const previewMap = require('./enhancers/previewMap');
module.exports = previewMap(require('../../../widget/MapView'));
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2018, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
const React = require('react');
const ReactDOM = require('react-dom');
const {createSink} = require('recompose');
const expect = require('expect');
const previewMap = require('../previewMap');

describe('previewMap enhancer', () => {
beforeEach((done) => {
document.body.innerHTML = '<div id="container"></div>';
setTimeout(done);
});
afterEach((done) => {
ReactDOM.unmountComponentAtNode(document.getElementById("container"));
document.body.innerHTML = '';
setTimeout(done);
});
it('previewMap enhancer callbacks', (done) => {
const actions = {
callback: () => { }
};
const spyCallback = expect.spyOn(actions, 'callback');
const Sink = previewMap(createSink( props => {
props.onMapViewChanges({mapStateSource: "TEST"});
expect(spyCallback).toHaveBeenCalled();
expect(spyCallback.calls.length).toBe(2);
expect(spyCallback.calls[0].arguments[0]).toBe("map");
expect(spyCallback.calls[1].arguments[0]).toBe("mapStateSource");
expect(spyCallback.calls[1].arguments[1]).toBe("TEST");
done();

}));
ReactDOM.render(<Sink onChange={actions.callback}/>, document.getElementById("container"));
});

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { compose, withHandlers } = require('recompose');

module.exports = compose(
withHandlers({
onMapViewChanges: ({ onChange = () => { } }) => map => {
onChange('map', map);
onChange('mapStateSource', map.mapStateSource);
}
})
);

0 comments on commit 5d38f31

Please sign in to comment.