mercredi 15 août 2018

Jest test validate data prop

I am new to jest and wanted to learn basics of how the test is written. How to write a simple test that validates uri contains/returns value?

renderProfileImage () {
    const apiUrl = 'site.com'
    const profileImagePath = this.props.data.field_profile_image

    if (profileImagePath !== '') {
      return <Image
        style={styles.profile}
        source={this.state.imageLoading ? require('../img/profileImagePlaceholder.png') : { uri: `${apiUrl}${profileImagePath}` }}
        onLoadEnd={(e) => this.setState({ imageLoading: false })}
      />
    }

say this.props.data.field_profile_image returns /photo.png

Aucun commentaire:

Enregistrer un commentaire