title: unit testing file upload in angular
body: <p>I am using the nf-file-upload module to upload a file to my backend. The code for the file upload is as follows:</p>
  
  <pre><code>    $scope.upload = function (file) {
              console.log(file)
  
              Upload.upload({
                  url: 'http://localhost:3000/fileupload',
                  data: {file: file[0]},
              }).then(function (resp) {
                  console.log('Success ' + resp.config.data.file.name + ' uploaded. Response: ' + resp.data);
  }
  </code></pre>
  
  <p>The file uploading works great. however, when I create my unit test:</p>
  
  <pre><code>  it('should send file to backend for processing', function(){
      var mockFile = {file:[{"name":"file.bin", "size":1018, "type":"application/binary"}]};
      httpBackend.when('POST', 'http://localhost:3000/fileupload').respond(200, {"filePath":"http://localhost:3000/uploads/file.txt"});
      scope.upload(mockFile);
      httpBackend.flush();
    });
  </code></pre>
  
  <p>I get an error:</p>
  
  <pre><code>TypeError: undefined is not an object (evaluating 'resp.config.data.file.name')
  </code></pre>
  
  <p>What am I doing wrong?</p>