<commit_before>"use strict";
describe('InvertedIndex',function(){
  let index = require('../src/inverted-index');
  let book_path = 'C:/Users/Cyrielo/Documents/CYRIELO DOCUMENTS/Development/'+
    'Web Apps/invertedIndex/jasmine/books.json';
  index.createIndex(book_path).then( data =>{

  });

  describe("Read book data", function() {

    it("should reads the JSON file and asserts that it is not empty", function(done){
      index.readJsonFile(book_path).then( data =>{
        expect( index.isEmpty(data) ).toBe(false);
        done();
      });

    });

    /*Ensure each object in JSON array contains a property whose
     value is a string.*/
    it('should ensure each object in JSON array contains a property whose' +
      ' value is a string', function(done){
      index.readJsonFile(book_path).then( data =>{
        for(let obj of data){
          expect( typeof obj.title ).toEqual('string');
          expect( typeof obj.text ).toEqual('string');
        }
        done();
      });
    });

  });

  describe('Populate Index', function(){

    it('should verify that the index is created', function(){
      expect( Object.keys(index.invertedIndexes).length ).toBeGreaterThan(0);
    });

    it('should verifies the index maps the string keys to the correct' +
      ' objects in the JSON array', function(){

    });

  });

  describe('Search index', function(){
    it('should ensure search does not take too long to execute',function(){
      let runtime_threshold = 1000;
      let current_millisecond =  new Date().getMilliseconds();

      index.searchIndex('Alice', ['Fellowship', ['dwarf'], 'in'  ]);

      let final_milliseconds =  new Date().getMilliseconds();
      let time_difference = final_milliseconds - current_millisecond;
<commit_msg>Add more tests and change absolute paths to relative for books.json<commit_after>"use strict";
describe('InvertedIndex',function(){
  let index = require('../src/inverted-index');
  let book_path = 'jasmine/books.json';
  let doc_path = 'jasmine/document.json';
  index.createIndex(book_path).then( data =>{

  });

  describe("Read book data", function() {

    it("should reads the JSON file and asserts that it is not empty", function(done){
      index.readJsonFile(book_path).then( data =>{
        expect( index.isEmpty(data) ).toBe(false);
        done();
      });

    });

    /*Ensure each object in JSON array contains a property whose
     value is a string.*/
    it('should ensure each object in JSON array contains a property whose' +
      ' value is a string', function(done){
      index.readJsonFile(book_path).then( data =>{
        for(let obj of data){
          expect( typeof obj.title ).toEqual('string');
          expect( typeof obj.text ).toEqual('string');
        }
        done();
      });
    });

  });

  describe('Populate Index', function(){

    it('should verify that the index is created', function(){
      expect( Object.keys(index.invertedIndexes).length ).toBeGreaterThan(0);
    });

    it('should verifies the index maps the string keys to the correct' +
      ' objects in the JSON array', function(){
      expect( index.searchIndex('Alice', 'elf') ).toEqual(['0', '1']);
    });

    it('Should verify data multiple index could be built', function(done){
      index.createIndex(doc_path).then(()=>{
        expect( Object.keys(index.invertedIndexes).length ).toEqual(2);
        done();
      });
    });

    it('Should be able to delete an invertedIndex object by it\'s file path', function(){
      index.removeIndex(doc_path);
      expect( Object.keys(index.invertedIndexes).length ).toEqual(1);
    });
  });

  describe('Search index', function(){
    it('should ensure search does not take too long to execute',function(){
      let runtime_threshold = 1000;
      let current_millisecond =  new Date().getMilliseconds();

      index.searchIndex('Alice', ['Fellowship', ['dwarf'], 'in'  ]);

      let final_milliseconds =  new Date().getMilliseconds();
      let time_difference = final_milliseconds - current_millisecond;

{'fraction_non_alphanumeric': 0.14081733136386015, 'fraction_numerical': 0.0034465780403741997, 'mean_word_length': 3.188659793814433, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3683472', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1124, 'n_words': 336}