describe('filetree', function(){
  var controller;
  var $filetreeService;
  var filetreeCtrl;
  var httpBackend;
  var dirs = [{
        "filepath": "/home/saurabh/dir2",
        "filename": "dir2",
        "group": "saurabh",
        "is_accessible": true,
        "perm": "-rw-rw-r--",
        "perm_string": "664",
        "size": "4.0 KiB",
        "type": "dir"
      }, {
        "filepath": "/home/saurabh/dir2",
        "filename": "dir2",
        "group": "root",
        "is_accessible": false,
        "perm": "-rw-r--r--",
        "perm_string": "644",
        "size": "4.0 KiB",
        "type": "dir"
      },
      {
        "filepath": "/home/saurabh/dir3",
        "filename": "dir3",
        "group": "saurabh",
        "is_accessible": true,
        "perm": "-rw-rw-r--",
        "perm_string": "664",
        "size": "4.0 KiB",
        "type": "dir"
      }];
  beforeEach(module('oide'));
  beforeEach(module('oide.editor'));

  beforeEach(inject(function($controller, $rootScope, $log, $document, FiletreeService, $httpBackend){
    scope = $rootScope.$new();
    httpBackend = $httpBackend;
    httpBackend.whenGET('/filebrowser/filetree/a/dir').respond(function(){
      return [200, dirs];
    });
    controller = $controller;
    $filetreeService = FiletreeService;
    filetreeCtrl = $controller('FiletreeCtrl', {
      $scope: scope,
      $document: $document,
      $log: $log,
      FileTreeService: $filetreeService
    });
    scope.ctrl = controller;
    scope.$apply();
  }));

  //Expect Filetree service to be defined
  describe('Whether the filetree is working as expected or not', function(){
    it('Controller initialization should be proper', function(){
      httpBackend.flush();
      expect($filetreeService).toBeDefined();
      expect($filetreeService.treeData).toBeDefined();
    });
  });

});

@@ -873,16 +873,572 @@
     %7D%5D;%0A
+%0A    var files = %5B%7B%0A          %22filepath%22: %22/home/saurabh/file1%22,%0A          %22filename%22: %22file1%22,%0A          %22group%22: %22saurabh%22,%0A          %22is_accessible%22: true,%0A          %22perm%22: %22-rw-rw-r--%22,%0A          %22perm_string%22: %22664%22,%0A          %22size%22: %224.0 KiB%22,%0A          %22type%22: %22dir%22%0A        %7D, %7B%0A          %22filepath%22: %22/home/saurabh/file2%22,%0A          %22filename%22: %22file2%22,%0A          %22group%22: %22root%22,%0A          %22is_accessible%22: false,%0A          %22perm%22: %22-rw-r--r--%22,%0A          %22perm_string%22: %22644%22,%0A          %22size%22: %224.0 KiB%22,%0A          %22type%22: %22dir%22%0A        %7D%5D;%0A%0A
   before
@@ -1846,28 +1846,26 @@
 ce;%0A    
-filetreeCtrl
+controller
  = $cont
@@ -2065,50 +2065,8 @@
 );%0A%0A
-  //Expect Filetree service to be defined%0A
   de
@@ -2134,24 +2134,68 @@
 function()%7B%0A
+    //Expect Filetree service to be defined%0A
     it('Cont
@@ -2337,47 +2337,791 @@
 ect(
-$filetreeService.treeData).toBeDefined(
+scope.ctrl.treeData).toBeDefined();%0A      expect(scope.ctrl.treeData.filetreeContents).toBeDefined();%0A      expect(scope.ctrl.treeData.filetreeContents.length).toBe(3);%0A    %7D);%0A%0A    it('should return directory contents', function()%7B%0A      httpBackend.flush();%0A      httpBackend.whenGET(/%5C/filebrowser%5C/filetree%5C/a%5C/dir%5C?dirpath=.*/).respond(function()%7B%0A        return %5B200, files%5D;%0A      %7D);%0A      scope.ctrl.getDirContents(scope.ctrl.treeData.filetreeContents%5B0%5D);%0A      httpBackend.flush();%0A      // Retrieved files should be set as the childrens object of the 0th node%0A      expect(scope.ctrl.treeData.filetreeContents%5B0%5D.children).toBeDefined();%0A      // Length of the children for the node should be 2%0A      expect(scope.ctrl.treeData.filetreeContents%5B0%5D.children.length).toBe(2
 );%0A 
@@ -3127,16 +3127,17 @@
     %7D);%0A
+%0A
   %7D);%0A%0A%7D

add spec to test getDirContents method of controller