jeudi 8 février 2018

Unit testing React component that renders google-map-react component

I'm trying to create a test suit to cover the behavior of LocationHistoryMap react component using Jest and I want to ask how to guide my specs in order to check that LocationHistoryMap component works fine.

It renders <GoogleMap/> component using google-map-react dependency.

It has some properties like this.props.zoom that is passed to <GoogleMap/> component calling a specific method. It passes a callback function to onGoogleApiLoaded or it defines yesIWantToUseGoogleMapApiInternals true. I'm not sure these things have to be tested in this case.

import GoogleMap from 'google-map-react';
...

export default class LocationHistoryMap extends Component {
  ...

  _renderHeatMap(map, maps, points) {...}

  _getDefaultCenter() {...}

  _getDefaultZoom() {...}

  _getBootstrapURLKeys() {...};

  render() {
    return (
      <GoogleMap
        defaultCenter={this._getDefaultCenter()}
        defaultZoom={this._getDefaultZoom()}
        bootstrapURLKeys={this._getBootstrapURLKeys()}
        onGoogleApiLoaded={({map, maps}) => this._renderHeatMap(map, maps, this.props.coordinates)}
        yesIWantToUseGoogleMapApiInternals={true}
      />
    );
  }
}

Aucun commentaire:

Enregistrer un commentaire