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?

3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.