'use strict';

const data = require('../data/search');

module.exports = (name, search) => {
  describe(`${name} search`, () => {
    it('should not find element in empty array', () => {
      const { emptyArray } = data;

      search(emptyArray, 0).should.be.eql(-1);
    });

    it('should find element index in array with one element', () => {
      const { smallArray } = data;

      search(smallArray, smallArray[0]).should.be.eql(0);
    });

    it('should find element index in integers array', () => {
      const { integers, intIndexToSearch } = data;

      search(integers, integers[intIndexToSearch]).should.be.eql(intIndexToSearch);
    });

    it('should not find element index in integers array', () => {
      const { integers, notExistedIntValue } = data;

      search(integers, notExistedIntValue).should.be.eql(-1);
    });

    it('should find element index in objects array', () => {
      const { objects, objIndexToSearch, objExtractor } = data;

      search(objects, objects[objIndexToSearch], {
        extract: objExtractor
      }).should.be.eql(objIndexToSearch);
    });

    it('should not find element index in objects array', () => {
      const { objects, notExistedObjValue, objExtractor } = data;

      search(objects, notExistedObjValue, {
        extract: objExtractor
      }).should.be.eql(-1);
    });
  });
};
@@ -119,24 +119,333 @@
 h%60, () =%3E %7B%0A
+    it('should generate error because first parameter is not an array', () =%3E %7B%0A      try %7B%0A        search(null);%0A        throw new Error('Make search despite on incorrect parameter.');%0A      %7D catch (err) %7B%0A        err.should.have.property('message', 'First parameter should be an array.');%0A      %7D%0A    %7D);%0A%0A
     it('shou

make coverage 100%.