normalize html before compare in tests whitespace forgiving.

This commit is contained in:
avim 2014-11-11 16:55:32 +02:00
parent 4aa26c0dea
commit 2b38b0ca31
2 changed files with 16 additions and 3 deletions

View File

@ -1 +1,9 @@
<div><div><span>Item:#0 = a</span><span>Item:#1 = b</span><span>Item:#2 = c</span></div><span>items not in scope</span><span>item not in scope</span></div>
<div>
<div>
<span>Item:#0 = a</span>
<span>Item:#1 = b</span>
<span>Item:#2 = c</span>
</div>
<span>items not in scope</span>
<span>item not in scope</span>
</div>

View File

@ -5,6 +5,7 @@ var fs = require('fs');
var _ = require('lodash');
var path = require('path');
var React = require('react');
var cheerio = require('cheerio');
var dataPath = path.resolve(__dirname, '..', 'data');
@ -27,6 +28,10 @@ test('conversion test', function (t) {
}
});
function normalizeHtml(html) {
return cheerio.load(html,{normalizeWhitespace:true}).html();
}
test('html tests', function (t) {
var files = ['scope.rt'];
t.plan(files.length);
@ -50,13 +55,13 @@ test('html tests', function (t) {
render: eval(code)
}));
var actual = React.renderToStaticMarkup(comp());
console.log(actual);
actual = normalizeHtml(actual);
expected = normalizeHtml(actual);
t.equal(actual, expected);
if (actual !== expected) {
fs.writeFileSync(filename + '.actual.html', actual);
}
}
});
test('util.isStale', function (t) {