-
Notifications
You must be signed in to change notification settings - Fork 8
/
hamming.spec.js
40 lines (30 loc) · 1.15 KB
/
hamming.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var Hamming = require('./hamming');
describe('Hamming', function () {
var hamming = new Hamming();
it('no difference between identical strands', function () {
expect(hamming.compute('A', 'A')).toEqual(0);
});
it('complete hamming distance for single nucleotide strand', function () {
expect(hamming.compute('A','G')).toEqual(1);
});
it('complete hamming distance for small strand', function () {
expect(hamming.compute('AG','CT')).toEqual(2);
});
it('small hamming distance', function () {
expect(hamming.compute('AT','CT')).toEqual(1);
});
it('small hamming distance in longer strand', function () {
expect(hamming.compute('GGACG', 'GGTCG')).toEqual(1);
});
it('large hamming distance', function () {
expect(hamming.compute('GATACA', 'GCATAA')).toEqual(4);
});
it('hamming distance in very long strand', function () {
expect(hamming.compute('GGACGGATTCTG', 'AGGACGGATTCT')).toEqual(9);
});
xit('throws error when strands are not equal length', function() {
expect(function() { hamming.compute('GGACGGATTCTG', 'AGGAC'); }).toThrow(
new Error('DNA strands must be of equal length.')
);
});
});