forked from geosolutions-it/MapStore2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kappu
committed
Mar 9, 2018
1 parent
dece305
commit fcf02db
Showing
13 changed files
with
145 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
web/client/components/data/query/enhancers/__tests__/geometrydetails-test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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 geometrydetails = require('../geometrydetails'); | ||
|
||
describe('geometrydetails 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('geometrydetails onChangeDrawingStatus debounce', (done) => { | ||
const action = (status, method, owner, features) => { | ||
expect(status).toExist(); | ||
expect(status).toBe("replace"); | ||
expect(method).toNotExist(); | ||
expect(owner).toExist(); | ||
expect(owner).toBe("queryform"); | ||
expect(features).toExist(); | ||
expect(features).toBe("geom1"); | ||
done(); | ||
} | ||
const Sink = geometrydetails(createSink( props => { | ||
expect(props).toExist(); | ||
expect(props.onChangeDrawingStatus).toExist(); | ||
props.onChangeDrawingStatus({geometry: "geom"}); | ||
props.onChangeDrawingStatus({geometry: "geom1"}); | ||
})); | ||
ReactDOM.render((<Sink onChangeDrawingStatus={action} | ||
/>), document.getElementById("container")); | ||
|
||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
web/client/components/data/query/enhancers/geometrydetails.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* 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 {compose, createEventHandler, defaultProps} = require('recompose'); | ||
|
||
const propsStreamFactory = require('../../../misc/enhancers/propsStreamFactory'); | ||
|
||
|
||
const dataStreamFactory = $props => { | ||
const {handler: onChangeDrawingStatus, stream: onChangeDrawingStatus$} = createEventHandler(); | ||
return $props.map(o => ({...o, onChangeDrawingStatus$ })).switchMap(({onChangeDrawingStatus$, onChangeDrawingStatus}) => onChangeDrawingStatus$.debounceTime(1000).map(({geometry}) => onChangeDrawingStatus("replace", undefined, "queryform", geometry))) | ||
.startWith({}).map( o => ({...o, onChangeDrawingStatus})); | ||
}; | ||
|
||
|
||
module.exports = compose( | ||
defaultProps({ | ||
dataStreamFactory | ||
}), | ||
propsStreamFactory); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters