FineUploader / fine-uploader-wrappers

ES6 classes that wrap a Fine Uploader S3, Azure, or Traditional instance & provide additional features.
MIT License
28 stars 12 forks source link

Question: how can addFiles be accessed within a test in node.js #9

Closed fairbairn closed 6 years ago

fairbairn commented 6 years ago

More of a question than a feature request or issue..

Trying to write a local test with mocha and jsdom using the wrapper .addFiles() functionality, but can't seem to get a combination to pass into addFiles() that will take without error.

I originally tried to use file-api with it's FileList and File objects but it seems to be in some conflict.

Then I attempted to manually create a BlobWrapper, placed within an array, and pass that in, but I get an internal error of TypeError: fileInput.setAttribute is not a function.

It was a primitive attempt like so..

const filename = path.resolve('./test/api/files/empty3.pdf');
let blob_file = {
    name: path.basename(filename),
    blob: fs.readFileSync(filename).buffer
};

const files = [blob_file];
---
uploader.methods.addFiles(files)

but clearly I'm on the wrong path.

What would be the easiest way to create a test within node.js and not within a browser?

Thanks.

rnicholus commented 6 years ago

Have a look at some of the unit tests in the fine-uploader project for inspiration. For example: https://github.com/FineUploader/fine-uploader/blob/master/test/unit/simple-file-uploads.js#L57