diff --git a/src/google_map_markers.js b/src/google_map_markers.js index 543e111..e606938 100644 --- a/src/google_map_markers.js +++ b/src/google_map_markers.js @@ -247,7 +247,11 @@ export default class GoogleMapMarkers extends Component { }; return ( -
+
{React.cloneElement(child, { $hover: childKey === this.state.hoverKey, $getDimensions: this._getDimensions, diff --git a/test/components/GoogleMap.spec.js b/test/components/GoogleMap.spec.js index 8325948..a5e6397 100644 --- a/test/components/GoogleMap.spec.js +++ b/test/components/GoogleMap.spec.js @@ -175,4 +175,86 @@ describe('Components', () => { key: API_KEY, }); }); + + it('Should add a className to the marker from $markerHolderClassName', () => { + const markerHolderClassName = 'marker-holder-class-name'; + + 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: [59.938043, 30.337157], + zoom: 9, + }; + + constructor(props) { + super(props); + } + + render() { + return ( + +
+ + ); + } + } + + const mapHolder = TestUtils.renderIntoDocument( + + ); + + const marker = TestUtils + .findRenderedDOMComponentWithClass(mapHolder, 'marker-holder-class-name'); + expect(marker.className).toEqual('marker-holder-class-name'); + expect(marker.style.left).toEqual('0.250129066669615px'); + expect(marker.style.top).toEqual('-12.62811732746195px'); + }); + + it('Should not add a className to the marker if $markerHolderClassName is not present', () => { + 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: [59.938043, 30.337157], + zoom: 9, + }; + + constructor(props) { + super(props); + } + + render() { + return ( + +
+ + ); + } + } + + const mapHolder = TestUtils.renderIntoDocument( + + ); + + const marker = TestUtils + .findRenderedDOMComponentWithClass(mapHolder, 'marker-class-name'); + expect(marker.parentNode.className).toNotExist(); + expect(marker.parentNode.style.left).toEqual('0.250129066669615px'); + expect(marker.parentNode.style.top).toEqual('-12.62811732746195px'); + }); });