Sha256: e0289a87be41f8d3f18118c59d5105752ccba1d1744055f034afc65efef9e900

Contents?: true

Size: 1.11 KB

Versions: 185

Compression:

Stored size: 1.11 KB

Contents

import Hamming from './hamming';

describe('Hamming', () => {
  const hamming = new Hamming();

  test('no difference between identical strands', () => {
    expect(hamming.compute('A', 'A')).toEqual(0);
  });

  xtest('complete hamming distance for single nucleotide strand', () => {
    expect(hamming.compute('A', 'G')).toEqual(1);
  });

  xtest('complete hamming distance for small strand', () => {
    expect(hamming.compute('AG', 'CT')).toEqual(2);
  });

  xtest('small hamming distance', () => {
    expect(hamming.compute('AT', 'CT')).toEqual(1);
  });

  xtest('small hamming distance in longer strand', () => {
    expect(hamming.compute('GGACG', 'GGTCG')).toEqual(1);
  });

  xtest('large hamming distance', () => {
    expect(hamming.compute('GATACA', 'GCATAA')).toEqual(4);
  });

  xtest('hamming distance in very long strand', () => {
    expect(hamming.compute('GGACGGATTCTG', 'AGGACGGATTCT')).toEqual(9);
  });

  xtest('throws error when strands are not equal length', () => {
    expect(() => hamming.compute('GGACGGATTCTG', 'AGGAC')).toThrow(
      new Error('DNA strands must be of equal length.'),
    );
  });
});

Version data entries

185 entries across 185 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.179 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.178 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.177 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.176 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.175 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.174 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.173 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.172 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.171 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.170 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.169 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.167 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.166 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.165 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.164 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.163 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.162 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.161 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.160 tracks/ecmascript/exercises/hamming/hamming.spec.js