-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathspec.js
More file actions
45 lines (36 loc) · 1 KB
/
spec.js
File metadata and controls
45 lines (36 loc) · 1 KB
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
41
42
43
44
45
var generateTest = function(func, input1, input2, expected) {
it("Testing: '" + input1 + "' and '" + input2 + "'", function() {
expect(func).to.be.a("function");
var result = func(input1, input2);
expect(result).to.equal(expected);
});
};
var edTest = generateTest.bind(null, editDistance);
var fsTest = generateTest.bind(null, fuzzyStringMatch);
describe("edit distance", function() {
var tests = [
["", "", 0],
["", "a", 1],
["a", "", 1],
["a", "b", 1],
["cap", "taps", 2],
["sitting", "kitten", 3],
["absolutely", "positively", 6]
];
tests.forEach(function(test) {
edTest.apply(null, test);
});
});
describe("fuzzy string match", function() {
var tests = [
["abcdefgh", "cdef", 1],
["abcdefgh", "cedf", 0.5],
["abcdefgh", "wxyz", 0],
["hello operator", "hell", 1],
["hello operator", "hullo", 0.8],
["when in the course of human events", "seven", 0.8],
];
tests.forEach(function(test) {
fsTest.apply(null, test);
});
});