Sha256: 0f13b4e5847badbe39f5b9add01eacffd0f47f732c1509f85ce21a993133a2bc

Contents?: true

Size: 953 Bytes

Versions: 208

Compression:

Stored size: 953 Bytes

Contents

import BinarySearch from './binary-search';

describe('BinarySearch', () => {

  const sortedArray = [1, 2, 3, 4, 5, 6];
  const sortedArrayOfOddLength = [0, 1, 2, 2, 3, 10, 12];
  const unsortedArray = [10, 2, 5, 1];

  it ('should require a sorted array', () => {
    const invalidBinarySearch = new BinarySearch(unsortedArray);
    const validBinarySearch = new BinarySearch(sortedArray);

    expect(typeof invalidBinarySearch.array).toEqual('undefined');
    expect(Array.isArray(validBinarySearch.array)).toEqual(true);
  });

  xit('should find the correct index of an included value', () => {
    expect(new BinarySearch(sortedArray).indexOf(3)).toEqual(2);
  });

  xit('should search the middle of the array', () => {
    expect(new BinarySearch(sortedArrayOfOddLength).indexOf(2)).toEqual(3);
  });

  xit('should return -1 for a value not in the array', () => {
    expect(new BinarySearch(sortedArray).indexOf(10)).toEqual(-1);
  });

});

Version data entries

208 entries across 208 versions & 1 rubygems

Version Path
trackler-2.1.0.53 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.52 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.51 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.50 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.49 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.48 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.47 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.46 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.45 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.44 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.43 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.42 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.41 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.40 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.39 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.38 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.37 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.36 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.34 tracks/ecmascript/exercises/binary-search/binary-search.spec.js
trackler-2.1.0.33 tracks/ecmascript/exercises/binary-search/binary-search.spec.js