forked from marko-js/marko
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvdom-create-test.js
47 lines (40 loc) · 1.4 KB
/
vdom-create-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
var path = require('path');
var fs = require('fs');
var toHTML = require('./util/toHTML');
var jsdom = require("jsdom").jsdom;
var document = jsdom('<html><body></body></html>');
var HTMLElement = require('../runtime/vdom/HTMLElement');
var Text = require('../runtime/vdom/Text');
var Comment = require('../runtime/vdom/Comment');
var DocumentFragment = require('../runtime/vdom/DocumentFragment');
var vdomHelpers = {
createElement: function(tagName, attrs, childCount, constId) {
return new HTMLElement(tagName, attrs, childCount, constId);
},
createText: function(value) {
return new Text(value);
},
createComment: function(value) {
return new Comment(value);
},
createDocumentFragment: function() {
return new DocumentFragment();
}
};
describe('marko-vdom', () => {
require('./autotest').scanDir(
path.join(__dirname, 'autotests/vdom-create'),
function(dir, helpers, done) {
helpers.vdom = vdomHelpers;
helpers.document = document;
var mainPath = path.join(dir, 'index.js');
if (fs.existsSync(mainPath)) {
var main = require(mainPath);
var rootNode = main(helpers);
var rootNodeHTML = rootNode != null ? toHTML(rootNode) : '(null)';
helpers.compare(rootNodeHTML, '.html');
}
done();
}
);
});