var test = require('tape');
var utils = require('./utils');

test('utils.js', function(t) {
  var dic = require('../dictionary.json');
  t.equal(
    utils.findFirstElement(dic.data, 'z'),
    368711,
    'should found index of first matches'
  );
  t.equal(
    utils.findFirstElement(dic.data, 'ze'),
    368932,
    'should found index of first matches'
  );
  t.equal(
    utils.findFirstElement(dic.data, 'zeb'),
    368958,
    'should found index of first matches'
  );
  t.equal(
    utils.findFirstElement(dic.data, 'zebr'),
    368963,
    'should found index of first matches'
  );
  t.equal(
    utils.findFirstElement(dic.data, 'zebra'),
    368963,
    'should found index of first matches'
  );
  t.equal(
    utils.findFirstElement(dic.data, 'zzzzzzzzzzzzzzzzzzzzebra'),
    -1,
    'should not throw exception when target text length is larger than any words in dictionary.'
  );
  t.equal(
    utils.findFirstElement(dic.data, 'Zebra', true),
    -1,
    'should not found when case-sensitive is on.'
  );
  t.end();
});

@@ -65,19 +65,37 @@
 t('utils
-.js
+ - findFirstElement()
 ', funct
@@ -1050,8 +1050,474 @@
 ();%0A%7D);%0A
+%0Atest('utils - getItemsFromArray()', function(t) %7B%0A  t.same(%0A    utils.getItemsFromArray(%5B1, 2, 3, 4, 5%5D, 0, 3),%0A    %5B1, 2, 3%5D,%0A    'should return expected array elements'%0A  );%0A  t.same(%0A    utils.getItemsFromArray(%5B1, 2, 3, 4, 5%5D, 2, 3),%0A    %5B3, 4, 5%5D,%0A    'should return expected array elements'%0A  );%0A  t.same(%0A    utils.getItemsFromArray(%5B1, 2, 3, 4, 5%5D, 2, 5),%0A    %5B3, 4, 5, undefined, undefined%5D,%0A    'should return expected array elements'%0A  );%0A  t.end();%0A%7D);%0A

Add test cases for getItemsFromArray method