Mock file input for unit test
<p>I got something like these lines of code:</p>

<pre><code>jQuery('.js-img-input').on('change', handleNewFiles);   

var handleNewFiles = function(event) {
    var fileList = event.target.files;
    loadFileList(fileList);
};

var loadFileList = function(fileList) {
    jQuery(fileList).each(function(key, file) {
        readFileAsync(file);
    });
}

var readFileAsync = function(file) {
    var fileReader = new FileReader();
    fileReader.addEventListener("load", function(event) {
        file.result = event.target.result;
        saveFile(file);
    });
    fileReader.readAsDataURL(file);
};
</code></pre>

<p>All of the methods are private inside a jQuery-function and I don't whant to make "handleNewFiles" public just for testing purpose.<br>
I would love to test these lines with something like this:</p>

<pre><code>it('should create a fileReader', function(){
    spyOn(window, 'FileReader').and.returnValue({
        addEventListener: function(){},
        readAsDataURL: function(){}
    });
    jQuery('.js-img-input').trigger('change');
    expect(window.FileReader).toHaveBeenCalled();
});
</code></pre>

<p>But how did I get some dummy data into <strong>event.target.files</strong>?</p>