title: Jasmine test for input type file
body: <p>I am trying to write the unit test for file upload but I am not able to satisfy below condition to bypass the validation. Can someone help me to complete the test.</p>
  
  <pre><code>if($scope.selected.files == undefined || $scope.selected.files == null || $scope.selected.files.length == 0){
      $window.alert("Please select upload file.");
      return;
  }
  </code></pre>
  
  <p>I want to satisfy the above condition so it should not display alert message.</p>
  
  <p>I tried below test but it is not passing the length validation.</p>
  
  <pre><code>it("should validate the selected file size.",
      function() {
         debugger
          $scope.fileSelection = true;
  
         var file= {
              "lastModified": 1438583972000,
              "lastModifiedDate": "2015-08-03T06:39:32.000Z",
              "name": "gitignore_global.txt",
              "size": 236,
              "type": "text/plain",
              "data": "data:text/plain;base64,DQojaWdub3JlIHRodW1ibmFpbHMgY3JlYXRlZCBieSB3aW5kb3dz…xoDQoqLmJhaw0KKi5jYWNoZQ0KKi5pbGsNCioubG9nDQoqLmRsbA0KKi5saWINCiouc2JyDQo="
          }
          var files = [];
          files[0] = { file,fileType:{id:'1'}};
          $scope.selected = {files};
  
          spyOn(window, 'alert');
          createController();
          $scope.transferFile();
          expect(window.alert).toHaveBeenCalledWith("The selected upload file is empty. Please upload the valid file.");
  
      });
  </code></pre>