/
test-doc.js
56 lines (44 loc) · 1.62 KB
/
test-doc.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* eslint-env node*/
'use strict';
// --------------------------------------------------------------------
// Imports
// --------------------------------------------------------------------
const markscript = require('markscript');
const path = require('path');
const test = require('ava');
// --------------------------------------------------------------------
// Private stuff
// --------------------------------------------------------------------
const markscriptConfig = {
// Allow require calls to work properly from inside Markdown.
moduleAliases: {
'ohm-js': scriptRel('..'),
'ohm-js/extras': scriptRel('../extras'),
},
workingDir: scriptRel('data'),
};
function scriptRel(relPath) {
return path.join(__dirname, relPath);
}
// --------------------------------------------------------------------
// Tests
// --------------------------------------------------------------------
// The tests below use Markscript to execute any code that is inside fenced
// code blocks in a Markdown document. This allows us to ensure that examples
// in the documentation run without errors.
test('doc/README.md', t => {
markscript.evaluateFile(scriptRel('../../../doc/README.md'), markscriptConfig);
t.pass();
});
test('doc/api-reference.md', t => {
markscript.evaluateFile(scriptRel('../../../doc/api-reference.md'), markscriptConfig);
t.pass();
});
test('doc/syntax-reference.md', t => {
markscript.evaluateFile(scriptRel('../../../doc/syntax-reference.md'), markscriptConfig);
t.pass();
});
test('doc/extras.md', t => {
markscript.evaluateFile(scriptRel('../../../doc/extras.md'), markscriptConfig);
t.pass();
});