-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
d14aae5
commit 1f45a3f
Showing
31 changed files
with
666 additions
and
1,399 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
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
106 changes: 106 additions & 0 deletions
106
web/client/components/data/identify/enhancers/__tests__/zoomToFeatureHandler-test.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,106 @@ | ||
/* | ||
* Copyright 2019, 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 zoomToFeatureHandler = require('../zoomToFeatureHandler'); | ||
|
||
const SAMPLE_FEATURES = [ | ||
{ | ||
"type": "Feature", | ||
"id": "", | ||
"geometry": null, | ||
"properties": { | ||
"GRAY_INDEX": 336 | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[ | ||
2.4609375, | ||
55.27911529201561 | ||
], | ||
[ | ||
3.515625, | ||
45.1510532655634 | ||
], | ||
[ | ||
12.83203125, | ||
45.089035564831036 | ||
], | ||
[ | ||
12.568359375, | ||
55.3791104480105 | ||
], | ||
[ | ||
2.4609375, | ||
55.27911529201561 | ||
] | ||
] | ||
] | ||
} | ||
} | ||
]; | ||
|
||
describe('zoomToFeatureHandler 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('zoomToFeatureHandler rendering with defaults', (done) => { | ||
const Sink = zoomToFeatureHandler(createSink( props => { | ||
expect(props.zoomToFeature).toExist(); | ||
done(); | ||
})); | ||
ReactDOM.render(<Sink />, document.getElementById("container")); | ||
}); | ||
it('callback to zoomToExtent', () => { | ||
const actions = { | ||
zoomToExtent: () => {} | ||
}; | ||
const spy = expect.spyOn(actions, 'zoomToExtent'); | ||
|
||
const Sink = zoomToFeatureHandler(createSink( props => { | ||
props.zoomToFeature(); | ||
})); | ||
ReactDOM.render(<Sink | ||
zoomToExtent={actions.zoomToExtent} | ||
currentFeatureCrs="EPSG:3857" | ||
currentFeature={SAMPLE_FEATURES}/>, document.getElementById("container")); | ||
expect(spy).toHaveBeenCalled(); | ||
expect(spy.calls[0].arguments[0]).toBeAn(Array); | ||
expect(spy.calls[0].arguments[1]).toBe("EPSG:3857"); | ||
}); | ||
it('not zoom if at least one geometry is not available', () => { | ||
const actions = { | ||
zoomToExtent: () => { } | ||
}; | ||
const spy = expect.spyOn(actions, 'zoomToExtent'); | ||
|
||
const Sink = zoomToFeatureHandler(createSink(props => { | ||
props.zoomToFeature(); | ||
})); | ||
ReactDOM.render(<Sink | ||
zoomToExtent={actions.zoomToExtent} | ||
currentFeatureCrs="EPSG:3857" | ||
currentFeature={[SAMPLE_FEATURES[0]]} />, document.getElementById("container")); | ||
expect(spy).toNotHaveBeenCalled(); | ||
|
||
}); | ||
}); |
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
Oops, something went wrong.