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.159 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.158 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.157 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.156 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.155 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.154 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.153 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.152 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.151 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.150 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.149 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.148 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.147 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.146 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.145 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.144 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.143 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.142 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.141 tracks/ecmascript/exercises/hamming/hamming.spec.js
trackler-2.2.1.140 tracks/ecmascript/exercises/hamming/hamming.spec.js