mirror of
https://github.com/google-map-react/google-map-react.git
synced 2025-12-08 18:26:32 +00:00
Add tests for defaultCenter and defaultZoom
This commit is contained in:
parent
fdd74c9987
commit
6c1601228c
@ -104,6 +104,54 @@ describe('Components', () => {
|
||||
expect(marker.parentNode.style.top).toEqual('-12.62811732746195px');
|
||||
});
|
||||
|
||||
it('Should accept defaultCenter and defaultZoom props', () => {
|
||||
const mapMarkerClassName = 'mapMarkerClassName';
|
||||
|
||||
class MapMarker extends Component { // eslint-disable-line react/no-multi-comp
|
||||
render() {
|
||||
return (
|
||||
<div className={mapMarkerClassName}>Marker</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MapHolder extends Component { // eslint-disable-line react/no-multi-comp
|
||||
static propTypes = {
|
||||
center: PropTypes.array,
|
||||
zoom: PropTypes.number,
|
||||
greatPlaceCoords: PropTypes.any,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
center: {lat: 59.938043, lng: 30.337157},
|
||||
zoom: 9,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<GoogleMap
|
||||
defaultCenter={this.props.center}
|
||||
defaultZoom={this.props.zoom}
|
||||
>
|
||||
<MapMarker lat={59.955413} lng={30.337844} />
|
||||
</GoogleMap>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapHolder = TestUtils.renderIntoDocument(
|
||||
<MapHolder />
|
||||
);
|
||||
|
||||
const marker = TestUtils.findRenderedDOMComponentWithClass(mapHolder, 'mapMarkerClassName');
|
||||
expect(marker.parentNode.style.left).toEqual('0.250129066669615px');
|
||||
expect(marker.parentNode.style.top).toEqual('-12.62811732746195px');
|
||||
});
|
||||
|
||||
|
||||
it('Should call custom loader', () => {
|
||||
const API_KEY = 'API_KEY';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user