My react component has a File input (upload) element.
When an xlsx
file is uploaded by the user, a component method is called, which reads the xlsx
file converts into JSON and puts it into the redux table. The method is "convertFileDataToJSON" which accepts the File
object and does the above.
I need to test this method.
I am not able to use "new File("file://path/to/file")". I get the following error
TypeError: FileConstructor is not a constructor (evaluating 'new File')
I am using "new Blob" to create a blob object and sending it to the instance method to the instance method.
var myBlob = new Blob(["application_id,Statement " +
"Received Date,Statement Requested Date,"+
"1,10/10/70,10/10/70,10/10/70"+
"2,12/20/71,12/20/71,12/20/71"], {type : "text/plain"});
const json = component.instance().convertFileDataToJSON(myBlob);
Any help would be appreciated, in how to test this method.