-
-
Notifications
You must be signed in to change notification settings - Fork 373
/
Copy pathutils.js
39 lines (32 loc) · 1.02 KB
/
utils.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
import fs from 'fs';
import path from 'path';
import assert from 'assert';
export function addTests(fPath, markdown, skip) {
var input,
stat = fs.statSync(fPath);
if (stat.isFile()) {
input = fs.readFileSync(fPath, 'utf8');
input = input.replace(/→/g, '\t');
describe(fPath, function () {
input.replace(/^\.\n([\s\S]*?)^\.\n([\s\S]*?)^\.$/gm, function(__, md, html, offset, orig) {
var line = orig.slice(0, offset).split(/\r?\n/g).length;
// Also skip tests if file name starts with "_"
if (!skip && path.basename(fPath)[0] !== '_') {
it('line ' + line, function () {
assert.strictEqual(html, markdown.render(md));
});
} else {
it.skip('line ' + line, function () {
assert.strictEqual(html, markdown.render(md));
});
}
});
});
return;
}
if (stat.isDirectory()) {
fs.readdirSync(fPath).forEach(function (name) {
addTests(path.join(fPath, name), markdown, skip);
});
}
}