Я не могу получить какие-либо узлы из компонента GoogleMap - PullRequest
1 голос
/ 03 мая 2020

Я хочу проверить свой компонент карты. Я использую реагирующую библиотеку с Jest. Я не знаю, как получить какие-либо узлы от <GoogleMap></GoogleMap> (этот компонент слишком глубоко). Я пытался получить маркер и кнопку удаления, но это не работает. Я добавил комментарий рядом с кнопкой удаления (проще для поиска). Может кто-нибудь дать мне какие-нибудь советы?

export const MapWithAMakredInfoWindow = compose(
  withProps({
     googleMapURL: `https://maps.googleapis.com/maps/api/js?key=${apiKey}&v=3.exp&libraries=geometry,drawing,places`,
     containerElement: ( ... ),
     withStateHandlers( ... ),
     withScriptjs,
     withGoogleMap,
     lifecycle({
      componentDidMount() {
      const refs = {};
      this.setState(...)
)(props => {
  return (
    <GoogleMap
      ...props
    >
      {props.indicators
        .filter( ... )
        .map((indicator, index) => {
          return (
            <Marker
              data-testid="marker" // I cannot get it
              ...props
            >
              {props.isOpen &&
                props.id === indicator.id && (
                  <InfoBox
                    ...props
                  >
                    <InfoBoxContainer>
                      <InfoContent>{indicator.name}</InfoContent>
                      <InfoContent>{indicator.street}</InfoContent>
                      <InfoContent>{indicator.city}</InfoContent>
                      <InfoContent>{indicator.country}</InfoContent>
                      <InfoBtn onClick={() => props.remove(indicator.id)} data-testid="removeBtn"> //it doesn't work
                        Remove Marker
                      </InfoBtn>
                    </InfoBoxContainer>
                  </InfoBox>
                )}
            </Marker>
          );
        })}
export class Map extends Component {

  constructor(props) {...}
  componentDidMount() {...}
  addIndicator = (event, geocode) => {...};
  remove = id => {...};
  render() {
    return (
      <Wrapper>
        <MapWithAMakredInfoWindow
          ...
        />
      </Wrapper>
    );
  }
}
...