forked from marko-js/marko
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vdom-virtualize-test.js
31 lines (27 loc) · 1.26 KB
/
vdom-virtualize-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
var path = require('path');
var virtualize = require('../runtime/vdom/virtualize');
var fs = require('fs');
var toHTML = require('./util/toHTML');
var jsdom = require("jsdom").jsdom;
describe('vdom/virtualize', () => {
require('./autotest').scanDir(
path.join(__dirname, 'autotests/vdom-virtualize'),
function(dir, helpers, done) {
helpers.virtualize = virtualize;
var inputPath = path.join(dir, 'input.html');
if (fs.existsSync(inputPath)) {
var inputHtml = fs.readFileSync(inputPath, { encoding: 'utf8' });
var document = jsdom('<html><body>' + inputHtml + '</body></html>');
var domNode = document.body.firstChild;
var vdomNode = virtualize(domNode);
var vdomHTML = toHTML(vdomNode);
helpers.compare(vdomHTML, { suffix: '.html', prefix: 'virtualized-' });
var actualDOM = vdomNode.actualize(document);
fs.writeFileSync(path.join(dir, 'actualized-expected.html'), vdomHTML, { encoding: 'utf8' });
var actualDOMHTML = toHTML(actualDOM);
helpers.compare(actualDOMHTML, { suffix: '.html', prefix: 'actualized-' });
}
done();
}
);
});