<commit_before>'use strict';

const book = [
  {
    "title": "Alice in Wonderland",
    "text": "Alice falls into a rabbit hole and enters a world full of imagination."
  },

  {
    "title": "The Lord of the Rings: The Fellowship of the Ring.",
    "text": "An unusual alliance of man, elf, dwarf, wizard and hobbit seek to destroy a powerful ring."
  }
]


describe("Read Book Data", function() {
  beforeEach(function () {
    this.inverted = new Index();
    // this.index = this.inverted.Index(book);
  });

    describe("Json is valid", ()=> {
      it("should check that uploaded file content is a valid json file", function() {
        expect(this.inverted.isValidJson(book)).toBeTruthy();
      });
    });

    describe("Json not empty", ()=> {
      it("should see that the uploaded file is not empty", function() {
        expect(this.inverted.isValidJson([])).toBeFalsy();
      });
    });

});


describe("Populate Data", function() {
  beforeEach(function () {
    this.inverted = new Index();
    // this.index = this.inverted.Index(book);
  });

    describe("Ensures that index is created once json file is read", ()=> {
      it("should return an object once index is created", function() {
        expect(typeof this.inverted.getIndex()).toBe("object");
      });
    });
    
    describe("Ensures that string object is mapped to the correct index", ()=> {
      it("should return index of the object string", function() {
        let index = this.inverted.createIndex(book);
        expect(index.alice).toEqual([0]);
      });
    });

});

describe("Search Index", function() {
  beforeEach(function () {
    this.inverted = new Index();
    // this.index = this.inverted.Index(book);
  });

    describe("Ensures that search return the correct indices of the object", ()=> {
      it("should return indeces of the object", function() {
        let index = this.inverted.createIndex(book);
        expect(this.inverted.searchIndex("of")).toEqual([0]);
      });
    });

});<commit_msg>re-write test suites and cases correctly<commit_after>'use strict';

const book = [
  {
    "title": "Alice in Wonderland",
    "text": "Alice falls into a rabbit hole and enters a world full of imagination."
  },

  {
    "title": "The Lord of the Rings: The Fellowship of the Ring.",
    "text": "An unusual alliance of man, elf, dwarf, wizard and hobbit seek to destroy a powerful ring."
  }
]

describe("Inverted Index", ()=> {
  const inverted = new InvertedIndex();
  inverted.createIndex(book);

  describe("Read Book Data", ()=> {
    it("should check that uploaded file content is a valid json file", ()=> {
      expect(inverted.isValidJson(book)).toBeTruthy();
    });

    it("should read json file and assert it is not empty", ()=> {
      expect(inverted.isValidJson([])).toBeFalsy();
    });
  });

  describe("Populate Index", ()=> {
    it("should verify that index has been created", ()=> {
      expect(Object.keys(inverted.indexes).length).toBeGreaterThan(0);
    });
    it("should check that index maps the string to the correct objects in json array", ()=> {
      expect(inverted.getIndex()["alice"]).toEqual([0]);
    });
  });  

  describe("Search Index", ()=> {
    it("should return an arrray of objects indexes of the searched words", ()=> {
      expect(inverted.searchIndex("of")).toEqual([[0,1]]);
      expect(inverted.searchIndex("alice powerful is")).toEqual([[0],[1]]);
    });
  });

})
{'fraction_non_alphanumeric': 0.16128093158660844, 'fraction_numerical': 0.0023289665211062593, 'mean_word_length': 3.2263222632226323, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 17, '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': '1193988', 'n_tokens_mistral': 1030, 'n_tokens_neox': 1019, 'n_words': 302}