<commit_before>var should   = require("should");
var NodeTree = require("../lib/NodeTree")
var Tree     = require("../lib/Tree")

var root = new NodeTree(null, '', []);

describe('Testing Nodes: ', function() {
  describe('Root element', function() {
    it('Should create a new node', function(){
      root.getFather().should.eql('');
    }),

    it('Is Root?', function() {
      root.isRoot().should.be.true;
    })
  }),

  describe('Seed tree', function() {
    var node = '';
    for (var i = 0; i < 10; i++) {
      node = new NodeTree(i, root, []);
      root.addChild(node);
    };
    it('Children Number', function(){
      root.childrenNumber().should.eql(10);
    }),

    it('Child exists', function() {
      root.existsChild(root.getChild(0)).should.be.true;
    }),

    it('Get child', function() {
      root.getChild(0).should.eql(root.children[0]);
    }),

    it('Get sibling', function() {
      root.firstChild().nextSibling().should.eql(root.getChild(1));
    }),

    it('Remove child', function() {
      root.removeChild(root.firstChild());
      root.childrenNumber().should.eql(9);
    })
  })
})

describe('Testing Tree: ', function() {
  describe('Tree element', function() {
    var root = new NodeTree(null, '', []);
    var tree = new Tree(root);
    var node = '';
    var i, j, k = 0;
    for (i; i < 10; i++) {
      node = new NodeTree(i, root, []);
      tree.getRoot().addChild(node);
    };
    it('Preorder', function() {
      console.log(tree);
    })
  })
})
<commit_msg>created tests for the resource manager<commit_after>var should   = require("should");
var NodeTree = require("../lib/NodeTree");
var Tree     = require("../lib/Tree");
var Resource = require("../lib/Resource");
var ResourceManager = require("../lib/ResourceManager");

var root = new NodeTree(null, '', []);

describe('Testing Nodes: ', function() {
  describe('Root element', function() {
    it('Should create a new node', function(){
      root.getFather().should.eql('');
    }),

    it('Is Root?', function() {
      root.isRoot().should.be.true;
    })
  }),

  describe('Seed tree', function() {
    var node = '';
    for (var i = 0; i < 10; i++) {
      node = new NodeTree(i, root, []);
      root.addChild(node);
    };
    it('Children Number', function(){
      root.childrenNumber().should.eql(10);
    }),

    it('Child exists', function() {
      root.existsChild(root.getChild(0)).should.be.true;
    }),

    it('Get child', function() {
      root.getChild(0).should.eql(root.children[0]);
    }),

    it('Get sibling', function() {
      root.firstChild().nextSibling().should.eql(root.getChild(1));
    }),

    it('Remove child', function() {
      root.removeChild(root.firstChild());
      root.childrenNumber().should.eql(9);
    })
  })
})

describe('Testing Tree: ', function() {
  describe('Tree element', function() {
    var root = new NodeTree('', '', []);
    var tree = new Tree(root);
    var node = '';
    var son  = '';
    var i = 0;
    var j = 0;

    it('Preorder', function() {
      for (i; i < 10; i++) {
        node = new NodeTree(i, root, []);
        tree.getRoot().addChild(node);
        for (j; j < 10; j+=2) {
          son = new NodeTree(j, node, []);
          node.addChild(son);
        }
      };
      tree.preorder(root, console.log);
    })
  })
})


describe('Testing resources: ', function() {
  describe('Loading file', function() {
    var rm = new ResourceManager('test/prueba.txt');
    it('Load File', function() {
      rm.getFileContent()[0].should.eql('first#');
    }),
    it('Read name', function() {
      rm.readName('first#data').should.eql('first');
    }),
    it('Add resource', function() {
      var r = new Resource('name', 'data');
      rm.writeResource(r);
      rm.getFileContent()[1].should.eql('name#data');
    }),
    it('Search resource', function() {
      rm.searchResource('name').should.eql('name#data');
    })
  })
})

{'fraction_non_alphanumeric': 0.20670391061452514, 'fraction_numerical': 0.008125952260030472, 'mean_word_length': 2.7875, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7096820', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1269, 'n_words': 261}