vendredi 25 mars 2016

How to set HTML5 file type input with ReactTestUtils

I have an HTML5 file type input in a React form similar to the following

<input type='file' ref='fileInput' onChange={this.onChange} multiple/>

and once a file is uploaded this.onChange accesses the selected files, validates them and transitions the form.

I'm trying to figure out how to test this functionality using ReactTestUtils.Simulate but cant figure out how to set the files that should be sent to the onChange callback in event.currentTarget.files.

Can anybody help guide me in the right direction to how I can mock/test this effectively?

Aucun commentaire:

Enregistrer un commentaire