forked from marko-js/marko
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vdom-compiler-test.js
50 lines (38 loc) · 1.29 KB
/
vdom-compiler-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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'use strict';
require('./util/patch-module');
var chai = require('chai');
chai.config.includeStack = true;
var path = require('path');
var compiler = require('../compiler');
var autotest = require('./autotest');
var fs = require('fs');
require('marko/node-require').install();
describe('compiler (vdom)', function() {
var autoTestDir = path.join(__dirname, 'autotests/vdom-compiler');
autotest.scanDir(autoTestDir, function run(dir, helpers, done) {
var templatePath = path.join(dir, 'template.marko');
var mainPath = path.join(dir, 'test.js');
var main;
if (fs.existsSync(mainPath)) {
main = require(mainPath);
}
var compilerOptions = { output: 'vdom' };
if (main && main.checkError) {
var e;
try {
compiler.compileFile(templatePath, compilerOptions);
} catch(_e) {
e = _e;
}
if (!e) {
throw new Error('Error expected');
}
main.checkError(e);
done();
} else {
var compiledSrc = compiler.compileFile(templatePath, Object.assign(compilerOptions, main && main.compilerOptions));
helpers.compare(compiledSrc, '.js');
done();
}
});
});