text: let chai = require('chai');
  let should = chai.should();
  
  var test_data = {
      "_id":{
         "$oid":"5cc0790ac49c5e03a6ceecc4"
      },
      "favourites":[
   
      ],
      "recent":[
   
      ],
      "shared_with_me":[
   
      ],
      "deleted":[
   
      ],
      "email":"maxshugar@hotmail.co.uk",
      "resources":{
         "items":[
            {
               "guid":"1f0c0500-66a1-11e9-8b72-41419694d7b6",
               "name":"x",
               "type":"folder",
               "items":[
                  {
                     "guid":"228bb5e0-66a1-11e9-8b72-41419694d7b6",
                     "name":"y",
                     "type":"folder",
                     "items":[
                        {
                           "guid":"26b7fa70-66a1-11e9-8b72-41419694d7b6",
                           "name":"z",
                           "type":"folder",
                           "items":[
                              {
                                 "guid":"2ced7c80-66a1-11e9-8b72-41419694d7b6",
                                 "name":"a",
                                 "type":"folder",
                                 "items":[
   
                                 ],
                                 "revisions":[
   
                                 ],
                                 "sharing":[
   
                                 ],
                                 "activity":[
   
                                 ]
                              },
                              {
                                 "guid":"30f262f0-66a1-11e9-8b72-41419694d7b6",
                                 "name":"b",
                                 "type":"folder",
                                 "items":[
   
                                 ],
                                 "revisions":[
   
                                 ],
                                 "sharing":[
   
                                 ],
                                 "activity":[
   
                                 ]
                              },
                              {
                                 "guid":"3595d350-66a1-11e9-8b72-41419694d7b6",
                                 "name":"c",
                                 "type":"folder",
                                 "items":[
   
                                 ],
                                 "revisions":[
   
                                 ],
                                 "sharing":[
   
                                 ],
                                 "activity":[
   
                                 ]
                              }
                           ],
                           "revisions":[
   
                           ],
                           "sharing":[
   
                           ],
                           "activity":[
   
                           ]
                        },
                        {
                           "guid":"39889150-66a1-11e9-8b72-41419694d7b6",
                           "name":"a",
                           "type":"folder",
                           "items":[
   
                           ],
                           "revisions":[
   
                           ],
                           "sharing":[
   
                           ],
                           "activity":[
   
                           ]
                        },
                        {
                           "guid":"3b9e51f0-66a1-11e9-8b72-41419694d7b6",
                           "name":"b",
                           "type":"folder",
                           "items":[
   
                           ],
                           "revisions":[
   
                           ],
                           "sharing":[
   
                           ],
                           "activity":[
   
                           ]
                        }
                     ],
                     "revisions":[
   
                     ],
                     "sharing":[
   
                     ],
                     "activity":[
   
                     ]
                  },
                  {
                     "guid":"4bdad070-66a1-11e9-8b72-41419694d7b6",
                     "name":"x",
                     "type":"folder",
                     "items":[
   
                     ],
                     "revisions":[
   
                     ],
                     "sharing":[
   
                     ],
                     "activity":[
   
                     ]
                  }
               ],
               "revisions":[
   
               ],
               "sharing":[
   
               ],
               "activity":[
   
               ]
            },
            {
               "guid":"400c5a70-66a1-11e9-8b72-41419694d7b6",
               "name":"w",
               "type":"folder",
               "items":[
   
               ],
               "revisions":[
   
               ],
               "sharing":[
   
               ],
               "activity":[
   
               ]
            },
            {
               "guid":"41ffc600-66a1-11e9-8b72-41419694d7b6",
               "name":"r",
               "type":"folder",
               "items":[
   
               ],
               "revisions":[
   
               ],
               "sharing":[
   
               ],
               "activity":[
   
               ]
            },
            {
               "guid":"44d0e760-66a1-11e9-8b72-41419694d7b6",
               "name":"j",
               "type":"folder",
               "items":[
   
               ],
               "revisions":[
   
               ],
               "sharing":[
   
               ],
               "activity":[
   
               ]
            },
            {
               "guid":"4740d5f0-66a1-11e9-8b72-41419694d7b6",
               "name":"c",
               "type":"folder",
               "items":[
   
               ],
               "revisions":[
   
               ],
               "sharing":[
   
               ],
               "activity":[
   
               ]
            }
         ],
         "revisions":[
   
         ],
         "sharing":[
   
         ],
         "activity":[
   
         ],
         "_id":{
            "$oid":"5cc0790ac49c5e03a6ceecc5"
         },
         "type":"folder",
         "guid":"root",
         "name":"maxshugar@hotmail.co.uk"
      },
      "salt":"81ce2629931b1458b0729b7ec3c99da9",
      "hash":"09ff9635e7acf4810f95cf34e8637a1d53b42fb0a36c4af73860da6b8c5583f64e77704fd9ff401fcde9f09eaae1433f6979807117478d6d6a32969fe00375cd0459699943f48e0534be1ca4674724dfe4969b1a2c4114f989a27dd305947f92d833c6a78bb5feb74f01431a5434816189979ba89ea1c27939291787248a9b1a29ac938c52aa75b8163a2643aabfa8f42bb5b4ebd1e2800946c068c00bff18a8cee4ac75563f93cd3f9c8c54a9789c01277be25c4772ad94ed9ab19b41625192c00bb03a930e226d6f7aad4ff26379813eac439f70b3e81a06daacea9864481d58d1ffc27d1f008d7b8b9ffe4745fe1e855253bad8aac7ee4c3e1688376b876a7de9c824b5db0d7fc8133115a00aec449809b8b5732ea7c5051179cf7699de0a1945ed32fca8af985419c8ac6841e42992de4180c461df5073f51344280f135e31015609f749e8f0857fa56b3360e07b8e138e9377bb86ffa9ad7d9f60b6105c8ef41da989d291acbae14a42f32b2f1ec98867cd2bf5e7ce2bf7639ac9b15b6249827954d4984aab730bdb49db877c459408d8f404b284d2741ad9e43090721f1ef175b3cf1699b87c45cf1c826e121931a90aeab0b210c0b1d84cefca68152c969a63728c7d34dc4d53e3db7bde00921d0b484873a4139e32c84e951b9e8e7bedfe79eb23ebea49dea98aa239093ea6fb6a0e70e3e854e23cf6213dbedc8ef3",
      "__v":{
         "$numberInt":"13"
      }
   };
  
  function find_resource(obj, target_id){
      var res = null;
      /* Is the folder the target. */
      if(obj.guid == target_id){
          res = obj;
      } else {
          for(var i = 0; i < obj.items.length; i++){
              /* Is the item the target? */
              if(obj.items[i].guid == target_id){
                  breadcrumbs.unshift(obj.items[i]);
                  res = obj.items[i];
              }
              else if(obj.items[i].type == 'folder'){
                  var ret = find_resource(obj.items[i], target_id);
                  if(ret != null) {
                      breadcrumbs.unshift(obj.items[i]);
                      res = ret;
                  }
              }
          }
      }
      return res;
  }
  
  var target_folder_id = "26b7fa70-66a1-11e9-8b72-41419694d7b6";
  var target_folder_name = "z";
  var breadcrumbs = [];
  describe('find_resource', () => {
      it('It should find the resource with id ' + target_folder_id, (done) => {
  
          var folder = find_resource(test_data.resources, target_folder_id);
  
          /* Push root to beginning to breadcurmbs array. */
          breadcrumbs.unshift(test_data.resources);
  
          folder.guid.should.be.eql(target_folder_id);
          folder.name.should.be.eql(target_folder_name);
          folder.items[0].name.should.be.eql("a");
          folder.items[1].name.should.be.eql("b");
          folder.items[2].name.should.be.eql("c");
  
          done();
      });
  });