forked from hexlet-exercises/words-count
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
33 lines (26 loc) · 862 Bytes
/
test.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
/* global require process describe it */
var assert = require("assert");
var fs = require("fs");
describe("Word Count", function() { "use strict";
var files = [];
if (process.env.SOLUTION) {
files = [process.env.SOLUTION];
} else {
files = fs.readdirSync("./solutions");
}
files.forEach(function(file) {
if (!file.match(/.+\.js$/)) { return; }
var functions = require("./solutions/" + file);
describe("from " + file, function() {
Object.keys(functions).forEach(function(funcName) {
var func = functions[funcName];
it("should works using '" + funcName + "' way", function() {
assert.equal(0, func(""));
assert.equal(1, func("one"));
assert.equal(3, func("one, two three"));
assert.equal(4, func(" one, two three# ehu&, "));
});
});
});
});
});