2

I need to unit test a number of functions on an object that is designed to hold a file.

However, as a part of setting up the unit test, I need to get my hands on an a file object in the same directory as the test. This test is supposed to be run automatically, without ever loading a browser, and so can't be reliant on a user clicking a button to load the file.

Below is an example of a function I need to unit-test.

    getExtension: function () {
        return this.attributes.file.name.split(".").pop().toLowerCase();
    }

So can anyone tell me how to create that JavaScript file object without using the file chooser?

I'm using the Jasmine framework.

Edit: I searched before I created this question, since I was earnestly trying to find an answer, but now that I've created it, I found another question with partial answers already on it: How to instantiate a File object in JavaScript?

Community
  • 1
  • 1
Josh the Aspie
  • 493
  • 4
  • 7

0 Answers0