mardi 16 mai 2017

Jest testing React component input type="file"

I'd like to test onChange function with Jest, any suggestions? (I'm trying but always with problem related to
jest.fn() value must be a mock function or spy. )

  <label style={this.getOwnStyles()}>
    {fullName || placeholder &&
      <div style={styles.fileName}>
        {!fullName && placeholder}
        {fullName}
      </div>
    }
    <input
      {...this.getProps()}
      onChange={(e: any) => this.onChange(e)}
      style={styles.fileInput}
    />
    <Icon
      style={styles.fileIcon}
      kind="attachment"
      size={16}
    />
  </label>
);
};

onChange(event: any) {
const path = event.target.value;
} 

Aucun commentaire:

Enregistrer un commentaire