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

  it('should be truthy', function() {
    expect(books).toBeTruthy();
  });

  it('should ensure books.json exists', function() {
    expect(books).toBeDefined();
  });

  it('should have a data-type of object', function() {
    expect(books).toEqual(jasmine.any(Object));
  });

});

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

  it('should confirm that the array has the correct index number', function() {
    expect(books.length).toEqual(2);
  });

  it('should match index[0] to the first element/object in the array', function() {
    expect(books[0]).toEqual(jasmine.objectContaining({ 
      "title": "Alice in Wonderland",
      "text": "Alice falls into a rabbit hole and enters a world full of imagination."
    }));
  });

  it('should match index[1] to the second element/object in the array', function() {
    expect(books[1]).toEqual(jasmine.objectContaining({ 
      "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."
    }));
  });

  it('should maps the string keys to the correct objects in the JSON array', function() {
    expect(books[0].title).toEqual("Alice in Wonderland");
  });

  it('should maps the string keys to the correct objects in the JSON array', function() {
    expect(books[1].text).toEqual("An unusual alliance of man, elf, dwarf, wizard and hobbit seek to destroy a powerful ring.");
  });

});

describe('Search index', function() {
  
  it('should return an array of indices of the correct objects that contain the searched words', function() {
    expect(Index.prototype.searchIndex('and')).toEqual([0, 1]);
  });

  it('should return an array of the index of the correct object that contain the searched word', function() {
    expect(Index.prototype.searchIndex('alice')).toEqual([0]);
  });

  it('should return an array of the index of the correct object that contain the searched word', function() {
    expect(Index.prototype.searchIndex('lord')).toEqual([1]);
  });

  it('should not return an array of indices if the word is not found', function() {
    expect(Index.prototype.searchIndex('andela')).toEqual('Not In Any Document');
  });

});

@@ -26,32 +26,95 @@
 , function() %7B%0A%0A
+  beforeEach(function () %7B%0A   var books = getBooks();%0A  %7D);%0A  %0A
   it('should be 
@@ -388,38 +388,38 @@
 %0A%0Adescribe('
-Read book data
+Populate Index
 ', function(
@@ -429,81 +429,27 @@
 %0A%0A  
-it('should confirm that the array has the correct index number', 
+beforeEach(
 function
 () %7B
@@ -440,32 +440,33 @@
 ach(function
+ 
 () %7B%0A   
  expect(book
@@ -457,811 +457,392 @@
 %0A   
- expect(books.length).toEqual(2);%0A  %7D);%0A%0A  it('should match index%5B0%5D to the first element/object in the array', function() %7B%0A    expect(books%5B0%5D).toEqual(jasmine.objectContaining(%7B %0A      %22title%22: %22Alice in Wonderland%22,%0A      %22text%22: %22Alice falls into a rabbit hole and enters a world full of imagination.%22%0A    %7D));%0A  %7D);%0A%0A  it('should match index%5B1%5D to the second element/object in the array', function() %7B%0A    expect(books%5B1%5D).toEqual(jasmine.objectContaining(%7B %0A      %22title%22: %22The Lord of the Rings: The Fellowship of the Ring.%22,%0A      %22text%22: %22An unusual alliance of man, elf, dwarf, wizard and hobbit seek to destroy a powerful ring.%22%0A    %7D));%0A  %7D);%0A%0A  it('should maps the string keys to the correct objects in the JSON array', function() %7B%0A    expect(books%5B0%5D.title).toEqual(%22Alice in Wonderland%22
+var getIndex = indexChild.createIndex();%0A  %7D);%0A%0A  it('should verify that the index is created once the JSON file has been read', function() %7B%0A    expect(getIndex).toBeDefined();%0A  %7D);%0A%0A  it('should ensure that index is correct', function() %7B%0A    expect(getIndex.rabbit).toEqual(%5B0%5D);%0A  %7D);%0A%0A  it('should ensure that index is correct', function() %7B%0A    expect(getIndex.man).toEqual(%5B1%5D
 );%0A 
@@ -958,15 +958,16 @@
 oks%5B
-1%5D.text
+0%5D.title
 ).to
@@ -976,100 +976,29 @@
 ual(
-%22An unusual alliance of man, elf, dwarf, wizard and hobbit seek to destroy a powerful ring.%22
+'Alice in Wonderland'
 );%0A 
@@ -1025,17 +1025,17 @@
 'Search 
-i
+I
 ndex', f
@@ -1202,13 +1202,15 @@
 dex(
+%5B
 'and'
+%5D
 )).t
@@ -1221,12 +1221,18 @@
 al(%5B
+ %5B 
 0, 1
+ %5D 
 %5D);%0A
@@ -1391,15 +1391,17 @@
 dex(
+%5B
 'alice'
+%5D
 )).t
@@ -1400,33 +1400,39 @@
 ce'%5D)).toEqual(%5B
-0
+ %5B 0 %5D 
 %5D);%0A  %7D);%0A%0A  it(
@@ -1454,78 +1454,62 @@
 an a
-rray of the index of the correct object that contain the searched word
+ppropriate message if searched word is not in the book
 ', f
@@ -1563,14 +1563,18 @@
 dex(
-'lord'
+%5B'andela'%5D
 )).t
@@ -1573,33 +1573,51 @@
 la'%5D)).toEqual(%5B
-1
+ 'Word Not Found!' 
 %5D);%0A  %7D);%0A%0A  it(
@@ -1628,18 +1628,12 @@
 uld 
-not return
+take
  an 
@@ -1645,39 +1645,63 @@
  of 
-indices if
+search terms and return
  the 
-word is not foun
+correct indices of each wor
 d', 
@@ -1752,24 +1752,33 @@
 chIndex(
+%5B'hole', 
 'andela'
 )).toEqu
@@ -1769,16 +1769,23 @@
 'andela'
+, 'of'%5D
 )).toEqu
@@ -1791,29 +1791,46 @@
 ual(
-'Not In Any Document'
+%5B %5B 0 %5D, 'Word Not Found!', %5B 0, 1 %5D %5D
 );%0A 

refactor tests